include/linux/sem.h
16904 #ifndef _LINUX_SEM_H
16905 #define _LINUX_SEM_H
16906
16907 #include <linux/ipc.h>
16908
16909 /* semop flags */
16910 #define SEM_UNDO 0x1000 /* undo the operation on exit */
16911
16912 /* semctl Command Definitions. */
16913 #define GETPID 11 /* get sempid */
16914 #define GETVAL 12 /* get semval */
16915 #define GETALL 13 /* get all semval's */
16916 #define GETNCNT 14 /* get semncnt */
16917 #define GETZCNT 15 /* get semzcnt */
16918 #define SETVAL 16 /* set semval */
16919 #define SETALL 17 /* set all semval's */
16920
16921 /* ipcs ctl cmds */
16922 #define SEM_STAT 18
16923 #define SEM_INFO 19
16924
16925 /* One semid data structure for each set of semaphores in
16926 the system. */
16927 struct semid_ds {
16928 struct ipc_perm sem_perm; /* permissions; see ipc.h */
16929 __kernel_time_t sem_otime; /* last semop time */
16930 __kernel_time_t sem_ctime; /* last change time */
16931 struct sem *sem_base; /* ptr to 1st sem in arr */
16932 struct sem_queue *sem_pending; /* op to be processed */
16933 struct sem_queue **sem_pending_last; /* last op */
16934 struct sem_undo *undo; /* undo reqs on this arr */
16935 unsigned short sem_nsems; /* # sems in array */
16936 };
16937
16938 /* semop system calls takes an array of these. */
16939 struct sembuf {
16940 unsigned short sem_num; /* sem index in array */
16941 short sem_op; /* semaphore operation */
16942 short sem_flg; /* operation flags */
16943 };
16944
16945 /* arg for semctl system calls. */
16946 union semun {
16947 int val; /* value for SETVAL */
16948 struct semid_ds *buf; /* buf for IPC_STAT&IPC_SET */
16949 unsigned short *array; /* array for GETALL & SETALL */
16950 struct seminfo *__buf; /* buffer for IPC_INFO */
16951 void *__pad;
16952 };
16953
16954 struct seminfo {
16955 int semmap;
16956 int semmni;
16957 int semmns;
16958 int semmnu;
16959 int semmsl;
16960 int semopm;
16961 int semume;
16962 int semusz;
16963 int semvmx;
16964 int semaem;
16965 };
16966
16967 #define SEMMNI 128 /* ? max # of sem identifiers */
16968 #define SEMMSL 32 /* <= 512 max semaphores per id */
16969 #define SEMMNS (SEMMNI*SEMMSL) /* ? max sems in system*/
16970 #define SEMOPM 32 /* ~ 100 max ops per semop call */
16971 #define SEMVMX 32767 /* semaphore maximum value */
16972
16973 /* unused */
16974 #define SEMUME SEMOPM /* max undo entries per process */
16975 #define SEMMNU SEMMNS /* # undo structures sys-wide */
16976 #define SEMAEM (SEMVMX >> 1) /* adjust on exit max val*/
16977 #define SEMMAP SEMMNS /* # of entries in sem map */
16978 #define SEMUSZ 20 /* sizeof struct sem_undo */
16979
16980 #ifdef __KERNEL__
16981
16982 /* One sem structure for each sem in the system. */
16983 struct sem {
16984 int semval; /* current value */
16985 int sempid; /* pid of last operation */
16986 };
16987
16988 /* One queue for each semaphore set in the system. */
16989 struct sem_queue {
16990 /* next entry in the queue */
16991 struct sem_queue * next;
16992 /* previous entry in the queue, *(q->prev) == q */
16993 struct sem_queue ** prev;
16994 /* sleeping process */
16995 struct wait_queue * sleeper;
16996 /* undo structure */
16997 struct sem_undo * undo;
16998 /* process id of requesting process */
16999 int pid;
17000 /* completion status of operation */
17001 int status;
17002 /* semaphore array for operations */
17003 struct semid_ds * sma;
17004 /* array of pending operations */
17005 struct sembuf * sops;
17006 /* number of operations */
17007 int nsops;
17008 /* operation will alter semaphore */
17009 int alter;
17010 };
17011
17012 /* Each task has a list of undo requests. They are
17013 * executed automatically when the process exits. */
17014 struct sem_undo {
17015 /* next entry on this process */
17016 struct sem_undo * proc_next;
17017 /* next entry on this semaphore set */
17018 struct sem_undo * id_next;
17019 /* semaphore set identifier */
17020 int semid;
17021 /* array of adjustments, one per semaphore */
17022 short * semadj;
17023 };
17024
17025 asmlinkage int sys_semget (key_t key, int nsems,
17026 int semflg);
17027 asmlinkage int sys_semop (int semid, struct sembuf *sops,
17028 unsigned nsops);
17029 asmlinkage int sys_semctl (int semid, int semnum,
17030 int cmd, union semun arg);
17031
17032 #endif /* __KERNEL__ */
17033
17034 #endif /* _LINUX_SEM_H */
Сайт управляется системой
uCoz