]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - include/linux/sem.h
Merge tag 'linux-kselftest-4.13-rc6-fixes' of git://git.kernel.org/pub/scm/linux...
[mirror_ubuntu-artful-kernel.git] / include / linux / sem.h
1 #ifndef _LINUX_SEM_H
2 #define _LINUX_SEM_H
3
4 #include <linux/atomic.h>
5 #include <linux/rcupdate.h>
6 #include <linux/cache.h>
7 #include <uapi/linux/sem.h>
8
9 struct task_struct;
10
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
30 /* One sem_array data structure for each set of semaphores in the system. */
31 struct sem_array {
32 struct kern_ipc_perm sem_perm; /* permissions .. see ipc.h */
33 time_t sem_ctime; /* create/last semctl() time */
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 */
38 struct list_head list_id; /* undo requests on this array */
39 int sem_nsems; /* no. of semaphores in array */
40 int complex_count; /* pending complex operations */
41 unsigned int use_global_lock;/* >0: global lock required */
42
43 struct sem sems[];
44 } __randomize_layout;
45
46 #ifdef CONFIG_SYSVIPC
47
48 struct sysv_sem {
49 struct sem_undo_list *undo_list;
50 };
51
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
56
57 struct sysv_sem {
58 /* empty */
59 };
60
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
72 #endif /* _LINUX_SEM_H */