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 /* One semid data structure for each set of semaphores in the system. */
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 /* semop system calls takes an array of these. */
36 unsigned short sem_num
; /* semaphore index in array */
37 short sem_op
; /* semaphore operation */
38 short sem_flg
; /* operation flags */
41 /* arg for semctl system calls. */
43 int val
; /* value for SETVAL */
44 struct semid_ds
*buf
; /* buffer for IPC_STAT & IPC_SET */
45 unsigned short *array
; /* array for GETALL & SETALL */
46 struct seminfo
*__buf
; /* buffer for IPC_INFO */
63 #define SEMMNI 128 /* <= 32767 max # of semaphore identifiers */
64 #define SEMMSL 250 /* <= 512 max num of semaphores per id */
65 #define SEMMNS (SEMMNI*SEMMSL) /* <= MAX_INT max # of semaphores in system */
66 #define SEMOPM 32 /* <= 160 max num of ops per semop call */
67 #define SEMVMX 32767 /* <= 32767 semaphore maximum value */
70 #define SEMUME SEMOPM /* max num of undo entries per process */
71 #define SEMMNU SEMMNS /* num of undo structures system wide */
72 #define SEMAEM (SEMVMX >> 1) /* adjust on exit max value */
73 #define SEMMAP SEMMNS /* # of entries in semaphore map */
74 #define SEMUSZ 20 /* sizeof struct sem_undo */
78 /* One semaphore structure for each semaphore in the system. */
80 int semval
; /* current value */
81 int sempid
; /* pid of last operation */
84 /* One queue for each sleeping process in the system. */
86 struct sem_queue
* next
; /* next entry in the queue */
87 struct sem_queue
** prev
; /* previous entry in the queue, *(q->prev) == q */
88 struct task_struct
* sleeper
; /* this process */
89 struct sem_undo
* undo
; /* undo structure */
90 int pid
; /* process id of requesting process */
91 int status
; /* completion status of operation */
92 struct semid_ds
* sma
; /* semaphore array for operations */
93 int id
; /* internal sem id */
94 struct sembuf
* sops
; /* array of pending operations */
95 int nsops
; /* number of operations */
96 int alter
; /* operation will alter semaphore */
99 /* Each task has a list of undo requests. They are executed automatically
100 * when the process exits.
103 struct sem_undo
* proc_next
; /* next entry on this process */
104 struct sem_undo
* id_next
; /* next entry on this semaphore set */
105 int semid
; /* semaphore set identifier */
106 short * semadj
; /* array of adjustments, one per semaphore */
109 asmlinkage
long sys_semget (key_t key
, int nsems
, int semflg
);
110 asmlinkage
long sys_semop (int semid
, struct sembuf
*sops
, unsigned nsops
);
111 asmlinkage
long sys_semctl (int semid
, int semnum
, int cmd
, union semun arg
);
113 #endif /* __KERNEL__ */
115 #endif /* _LINUX_SEM_H */