POK(kernelpart)
Main Page
Data Structures
Files
File List
Globals
lockobj.h
Go to the documentation of this file.
1
/*
2
* POK header
3
*
4
* The following file is a part of the POK project. Any modification should
5
* made according to the POK licence. You CANNOT use this file or a part of
6
* this file is this part of a file for your own project
7
*
8
* For more information on the POK licence, please see our LICENCE FILE
9
*
10
* Please follow the coding guidelines described in doc/CODING_GUIDELINES
11
*
12
* Copyright (c) 2007-2009 POK team
13
*
14
* Created by julien on Thu Jan 15 23:34:13 2009
15
*/
16
17
18
#ifndef __POK_KERNEL_LOCKOBJ_H__
19
#define __POK_KERNEL_LOCKOBJ_H__
20
21
#include <types.h>
22
#include <
arch.h
>
23
24
#ifndef POK_CONFIG_NB_LOCKOBJECTS
25
#define POK_CONFIG_NB_LOCKOBJECTS 0
26
#endif
27
28
/*
29
* In POK, all locking objects are implemented in the same way. It avoids
30
* code duplication and save the environnement because we will consume less
31
* space on your disk and will save trees because stupid people that prints
32
* the code will consume less paper.
33
* Moreoever, if all lockobjects share the same code, it will be easy to
34
* certify and verify the behavior of all.
35
*/
36
37
38
typedef
enum
39
{
40
POK_LOCKOBJ_KIND_MUTEX
= 1,
41
POK_LOCKOBJ_KIND_SEMAPHORE
= 2,
42
POK_LOCKOBJ_KIND_EVENT
= 3
43
}
pok_lockobj_kind_t
;
44
45
/* All kind of lock objects we have in the kernel */
46
47
typedef
enum
48
{
49
POK_LOCKOBJ_POLICY_STANDARD
= 0,
50
POK_LOCKOBJ_POLICY_PIP
= 1,
51
POK_LOCKOBJ_POLICY_PCP
= 2
52
}
pok_locking_policy_t
;
53
54
55
typedef
enum
56
{
57
LOCKOBJ_STATE_LOCK
= 0,
58
LOCKOBJ_STATE_UNLOCK
= 1,
59
LOCKOBJ_STATE_WAITEVENT
= 2
60
}
pok_mutex_state_t
;
61
62
63
typedef
struct
64
{
65
pok_lockobj_kind_t
kind
;
66
pok_locking_policy_t
locking_policy
;
67
pok_queueing_discipline_t
queueing_policy
;
68
pok_sem_value_t
initial_value
;
69
pok_sem_value_t
max_value
;
70
}
pok_lockobj_attr_t
;
71
72
typedef
struct
73
{
74
pok_spinlock_t
spin
;
75
pok_spinlock_t
eventspin
;
76
/* spinlock to enfoce mutual exclusion */
77
78
bool_t
is_locked
;
79
/* Is the mutex locked ? */
80
81
pok_mutex_state_t
thread_state[
POK_CONFIG_NB_THREADS
+ 2];
82
/* Describe which thread is blocked in the mutex */
83
84
pok_locking_policy_t
locking_policy
;
85
/* Locking policy */
86
87
pok_queueing_discipline_t
queueing_policy
;
88
/* Locking policy */
89
90
pok_lockobj_kind_t
kind
;
91
92
bool_t
initialized
;
93
/* Is the mutex initialized ? */
94
95
uint16_t
current_value
;
96
uint16_t
max_value
;
97
}
pok_lockobj_t
;
98
99
100
typedef
enum
101
{
102
LOCKOBK_LOCK_REGULAR
= 1,
103
LOCKOBJ_LOCK_TIMED
= 2
104
}
pok_lockobj_lock_kind_t
;
105
106
typedef
enum
107
{
108
LOCKOBJ_OPERATION_LOCK
= 1,
109
LOCKOBJ_OPERATION_UNLOCK
= 2,
110
LOCKOBJ_OPERATION_WAIT
= 3,
111
LOCKOBJ_OPERATION_SIGNAL
= 4,
112
LOCKOBJ_OPERATION_BROADCAST
= 5
113
}
pok_lockobj_operation_t
;
114
115
typedef
struct
116
{
117
pok_lockobj_operation_t
operation
;
118
pok_lockobj_kind_t
obj_kind
;
119
pok_lockobj_lock_kind_t
lock_kind
;
120
uint64_t
time
;
121
}
pok_lockobj_lockattr_t
;
122
123
124
pok_ret_t
pok_lockobj_create
(
pok_lockobj_t
* obj,
const
pok_lockobj_attr_t
* attr);
125
pok_ret_t
pok_lockobj_init
();
126
pok_ret_t
pok_lockobj_partition_create
(
pok_lockobj_id_t
*
id
,
const
pok_lockobj_attr_t
* attr);
127
pok_ret_t
pok_lockobj_lock
(
pok_lockobj_t
* obj,
const
pok_lockobj_lockattr_t
* attr);
128
pok_ret_t
pok_lockobj_unlock
(
pok_lockobj_t
* obj,
const
pok_lockobj_lockattr_t
* attr);
129
pok_ret_t
pok_lockobj_eventwait
(
pok_lockobj_t
* obj,
const
uint64_t
timeout);
130
pok_ret_t
pok_lockobj_eventsignal
(
pok_lockobj_t
* obj);
131
pok_ret_t
pok_lockobj_eventbroadcast
(
pok_lockobj_t
* obj);
132
pok_ret_t
pok_lockobj_partition_wrapper
(
const
pok_lockobj_id_t
id
,
const
pok_lockobj_lockattr_t
* attr);
133
134
#endif
kernel
include
core
lockobj.h
Generated on Fri Jun 1 2012 19:07:12 for POK(kernelpart) by
1.8.1