~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/include/linux/sem.h

Version: ~ [ 2.4.0 ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #ifndef _LINUX_SEM_H
  2 #define _LINUX_SEM_H
  3 
  4 #include <linux/ipc.h>
  5 
  6 /* semop flags */
  7 #define SEM_UNDO        0x1000  /* undo the operation on exit */
  8 
  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 */
 17 
 18 /* ipcs ctl cmds */
 19 #define SEM_STAT 18
 20 #define SEM_INFO 19
 21 
 22 /* Obsolete, used only for backwards compatibility and libc5 compiles */
 23 struct semid_ds {
 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 */
 32 };
 33 
 34 /* Include the definition of semid64_ds */
 35 #include <asm/sembuf.h>
 36 
 37 /* semop system calls takes an array of these. */
 38 struct sembuf {
 39         unsigned short  sem_num;        /* semaphore index in array */
 40         short           sem_op;         /* semaphore operation */
 41         short           sem_flg;        /* operation flags */
 42 };
 43 
 44 /* arg for semctl system calls. */
 45 union semun {
 46         int val;                        /* value for SETVAL */
 47         struct semid_ds *buf;           /* buffer for IPC_STAT & IPC_SET */
 48         unsigned short *array;          /* array for GETALL & SETALL */
 49         struct seminfo *__buf;          /* buffer for IPC_INFO */
 50         void *__pad;
 51 };
 52 
 53 struct  seminfo {
 54         int semmap;
 55         int semmni;
 56         int semmns;
 57         int semmnu;
 58         int semmsl;
 59         int semopm;
 60         int semume;
 61         int semusz;
 62         int semvmx;
 63         int semaem;
 64 };
 65 
 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 
 72 /* unused */
 73 #define SEMUME  SEMOPM          /* max num of undo entries per process */
 74 #define SEMMNU  SEMMNS          /* num of undo structures system wide */
 75 #define SEMAEM  (SEMVMX >> 1)   /* adjust on exit max value */
 76 #define SEMMAP  SEMMNS          /* # of entries in semaphore map */
 77 #define SEMUSZ  20              /* sizeof struct sem_undo */
 78 
 79 #ifdef __KERNEL__
 80 
 81 /* One semaphore structure for each semaphore in the system. */
 82 struct sem {
 83         int     semval;         /* current value */
 84         int     sempid;         /* pid of last operation */
 85 };
 86 
 87 /* One sem_array data structure for each set of semaphores in the system. */
 88 struct sem_array {
 89         struct kern_ipc_perm    sem_perm;       /* permissions .. see ipc.h */
 90         time_t                  sem_otime;      /* last semop time */
 91         time_t                  sem_ctime;      /* last change time */
 92         struct sem              *sem_base;      /* ptr to first semaphore in array */
 93         struct sem_queue        *sem_pending;   /* pending operations to be processed */
 94         struct sem_queue        **sem_pending_last; /* last pending operation */
 95         struct sem_undo         *undo;          /* undo requests on this array */
 96         unsigned long           sem_nsems;      /* no. of semaphores in array */
 97 };
 98 
 99 /* One queue for each sleeping process in the system. */
100 struct sem_queue {
101         struct sem_queue *      next;    /* next entry in the queue */
102         struct sem_queue **     prev;    /* previous entry in the queue, *(q->prev) == q */
103         struct task_struct*     sleeper; /* this process */
104         struct sem_undo *       undo;    /* undo structure */
105         int                     pid;     /* process id of requesting process */
106         int                     status;  /* completion status of operation */
107         struct sem_array *      sma;     /* semaphore array for operations */
108         int                     id;      /* internal sem id */
109         struct sembuf *         sops;    /* array of pending operations */
110         int                     nsops;   /* number of operations */
111         int                     alter;   /* operation will alter semaphore */
112 };
113 
114 /* Each task has a list of undo requests. They are executed automatically
115  * when the process exits.
116  */
117 struct sem_undo {
118         struct sem_undo *       proc_next;      /* next entry on this process */
119         struct sem_undo *       id_next;        /* next entry on this semaphore set */
120         int                     semid;          /* semaphore set identifier */
121         short *                 semadj;         /* array of adjustments, one per semaphore */
122 };
123 
124 asmlinkage long sys_semget (key_t key, int nsems, int semflg);
125 asmlinkage long sys_semop (int semid, struct sembuf *sops, unsigned nsops);
126 asmlinkage long sys_semctl (int semid, int semnum, int cmd, union semun arg);
127 
128 #endif /* __KERNEL__ */
129 
130 #endif /* _LINUX_SEM_H */
131 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.