]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #ifndef _LINUX_SEM_H |
2 | #define _LINUX_SEM_H | |
3 | ||
60063497 | 4 | #include <linux/atomic.h> |
380af1b3 | 5 | #include <linux/rcupdate.h> |
31a7c474 | 6 | #include <linux/cache.h> |
607ca46e | 7 | #include <uapi/linux/sem.h> |
1da177e4 | 8 | |
8c65b4a6 TS |
9 | struct task_struct; |
10 | ||
1a233956 MS |
11 | /* One semaphore structure for each semaphore in the system. */ |
12 | struct sem { | |
13 | int semval; /* current value */ | |
14 | /* | |
15 | * PID of the process that last modified the semaphore. For | |
16 | * Linux, specifically these are: | |
17 | * - semop | |
18 | * - semctl, via SETVAL and SETALL. | |
19 | * - at task exit when performing undo adjustments (see exit_sem). | |
20 | */ | |
21 | int sempid; | |
22 | spinlock_t lock; /* spinlock for fine-grained semtimedop */ | |
23 | struct list_head pending_alter; /* pending single-sop operations */ | |
24 | /* that alter the semaphore */ | |
25 | struct list_head pending_const; /* pending single-sop operations */ | |
26 | /* that do not alter the semaphore*/ | |
27 | time_t sem_otime; /* candidate for sem_otime */ | |
28 | } ____cacheline_aligned_in_smp; | |
29 | ||
1da177e4 LT |
30 | /* One sem_array data structure for each set of semaphores in the system. */ |
31 | struct sem_array { | |
60f3e00d | 32 | struct kern_ipc_perm sem_perm; /* permissions .. see ipc.h */ |
2cd648c1 | 33 | time_t sem_ctime; /* create/last semctl() time */ |
1a82e9e1 MS |
34 | struct list_head pending_alter; /* pending operations */ |
35 | /* that alter the array */ | |
36 | struct list_head pending_const; /* pending complex operations */ | |
37 | /* that do not alter semvals */ | |
4daa28f6 | 38 | struct list_head list_id; /* undo requests on this array */ |
b97e820f MS |
39 | int sem_nsems; /* no. of semaphores in array */ |
40 | int complex_count; /* pending complex operations */ | |
9de5ab8a | 41 | unsigned int use_global_lock;/* >0: global lock required */ |
1a233956 MS |
42 | |
43 | struct sem sems[]; | |
1da177e4 LT |
44 | }; |
45 | ||
f567a185 MS |
46 | #ifdef CONFIG_SYSVIPC |
47 | ||
1da177e4 LT |
48 | struct sysv_sem { |
49 | struct sem_undo_list *undo_list; | |
50 | }; | |
51 | ||
1da177e4 LT |
52 | extern int copy_semundo(unsigned long clone_flags, struct task_struct *tsk); |
53 | extern void exit_sem(struct task_struct *tsk); | |
54 | ||
55 | #else | |
f567a185 MS |
56 | |
57 | struct sysv_sem { | |
58 | /* empty */ | |
59 | }; | |
60 | ||
1da177e4 LT |
61 | static inline int copy_semundo(unsigned long clone_flags, struct task_struct *tsk) |
62 | { | |
63 | return 0; | |
64 | } | |
65 | ||
66 | static inline void exit_sem(struct task_struct *tsk) | |
67 | { | |
68 | return; | |
69 | } | |
70 | #endif | |
71 | ||
1da177e4 | 72 | #endif /* _LINUX_SEM_H */ |