7 #define SEM_UNDO 0x1000 /* undo the operation on exit */
9 /* semctl Command Definitions. */
10 #define GETPID 11 /* get sempid */
11 #define GETVAL 12 /* get semval */
12 #define GETALL 13 /* get all semval's */
13 #define GETNCNT 14 /* get semncnt */
14 #define GETZCNT 15 /* get semzcnt */
15 #define SETVAL 16 /* set semval */
16 #define SETALL 17 /* set all semval's */
22 /* Obsolete, used only for backwards compatibility and libc5 compiles */
24 struct ipc_perm sem_perm
; /* permissions .. see ipc.h */
25 __kernel_time_t sem_otime
; /* last semop time */
26 __kernel_time_t sem_ctime
; /* last change time */
27 struct sem
*sem_base
; /* ptr to first semaphore in array */
28 struct sem_queue
*sem_pending
; /* pending operations to be processed */
29 struct sem_queue
**sem_pending_last
; /* last pending operation */
30 struct sem_undo
*undo
; /* undo requests on this array */
31 unsigned short sem_nsems
; /* no. of semaphores in array */
34 /* Include the definition of semid64_ds */
35 #include <asm/sembuf.h>
37 /* semop system calls takes an array of these. */
39 unsigned short sem_num
; /* semaphore index in array */
40 short sem_op
; /* semaphore operation */
41 short sem_flg
; /* operation flags */
44 /* arg for semctl system calls. */
46 int val
; /* value for SETVAL */
47 struct semid_ds __user
*buf
; /* buffer for IPC_STAT & IPC_SET */
48 unsigned short __user
*array
; /* array for GETALL & SETALL */
49 struct seminfo __user
*__buf
; /* buffer for IPC_INFO */
66 #define SEMMNI 128 /* <= IPCMNI max # of semaphore identifiers */
67 #define SEMMSL 250 /* <= 8 000 max num of semaphores per id */
68 #define SEMMNS (SEMMNI*SEMMSL) /* <= INT_MAX max # of semaphores in system */
69 #define SEMOPM 32 /* <= 1 000 max num of ops per semop call */
70 #define SEMVMX 32767 /* <= 32767 semaphore maximum value */
71 #define SEMAEM SEMVMX /* adjust on exit max value */
74 #define SEMUME SEMOPM /* max num of undo entries per process */
75 #define SEMMNU SEMMNS /* num of undo structures system wide */
76 #define SEMMAP SEMMNS /* # of entries in semaphore map */
77 #define SEMUSZ 20 /* sizeof struct sem_undo */
80 #include <asm/atomic.h>
81 #include <linux/rcupdate.h>
85 /* One semaphore structure for each semaphore in the system. */
87 int semval
; /* current value */
88 int sempid
; /* pid of last operation */
89 struct list_head sem_pending
; /* pending single-sop operations */
92 /* One sem_array data structure for each set of semaphores in the system. */
94 struct kern_ipc_perm sem_perm
; /* permissions .. see ipc.h */
95 time_t sem_otime
; /* last semop time */
96 time_t sem_ctime
; /* last change time */
97 struct sem
*sem_base
; /* ptr to first semaphore in array */
98 struct list_head sem_pending
; /* pending operations to be processed */
99 struct list_head list_id
; /* undo requests on this array */
100 int sem_nsems
; /* no. of semaphores in array */
101 int complex_count
; /* pending complex operations */
104 /* One queue for each sleeping process in the system. */
106 struct list_head simple_list
; /* queue of pending operations */
107 struct list_head list
; /* queue of pending operations */
108 struct task_struct
*sleeper
; /* this process */
109 struct sem_undo
*undo
; /* undo structure */
110 int pid
; /* process id of requesting process */
111 int status
; /* completion status of operation */
112 struct sembuf
*sops
; /* array of pending operations */
113 int nsops
; /* number of operations */
114 int alter
; /* does the operation alter the array? */
117 /* Each task has a list of undo requests. They are executed automatically
118 * when the process exits.
121 struct list_head list_proc
; /* per-process list: all undos from one process. */
123 struct rcu_head rcu
; /* rcu struct for sem_undo() */
124 struct sem_undo_list
*ulp
; /* sem_undo_list for the process */
125 struct list_head list_id
; /* per semaphore array list: all undos for one array */
126 int semid
; /* semaphore set identifier */
127 short * semadj
; /* array of adjustments, one per semaphore */
130 /* sem_undo_list controls shared access to the list of sem_undo structures
131 * that may be shared among all a CLONE_SYSVSEM task group.
133 struct sem_undo_list
{
136 struct list_head list_proc
;
140 struct sem_undo_list
*undo_list
;
143 #ifdef CONFIG_SYSVIPC
145 extern int copy_semundo(unsigned long clone_flags
, struct task_struct
*tsk
);
146 extern void exit_sem(struct task_struct
*tsk
);
149 static inline int copy_semundo(unsigned long clone_flags
, struct task_struct
*tsk
)
154 static inline void exit_sem(struct task_struct
*tsk
)
160 #endif /* __KERNEL__ */
162 #endif /* _LINUX_SEM_H */