home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / UNIX3862.ZIP / U386-06.ZIP / U386-6.TD0 / usr / include / sys / sem.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-06-26  |  2.7 KB  |  115 lines

  1. /*    Copyright (c) 1984, 1986, 1987, 1988 AT&T    */
  2. /*      All Rights Reserved      */
  3.  
  4. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T    */
  5. /*    The copyright notice above does not evidence any       */
  6. /*    actual or intended publication of such source code.    */
  7.  
  8.  
  9. #ident    "@(#)head.sys:sem.h    1.3"
  10.  
  11. /*
  12. **    IPC Semaphore Facility.
  13. */
  14.  
  15. /*
  16. **    Implementation Constants.
  17. */
  18.  
  19. #define    PSEMN    (PZERO + 3)    /* sleep priority waiting for greater value */
  20. #define    PSEMZ    (PZERO + 2)    /* sleep priority waiting for zero */
  21.  
  22. /*
  23. **    Permission Definitions.
  24. */
  25.  
  26. #define    SEM_A    0200    /* alter permission */
  27. #define    SEM_R    0400    /* read permission */
  28.  
  29. /*
  30. **    Semaphore Operation Flags.
  31. */
  32.  
  33. #define    SEM_UNDO    010000    /* set up adjust on exit entry */
  34.  
  35. /*
  36. **    Semctl Command Definitions.
  37. */
  38.  
  39. #define    GETNCNT    3    /* get semncnt */
  40. #define    GETPID    4    /* get sempid */
  41. #define    GETVAL    5    /* get semval */
  42. #define    GETALL    6    /* get all semval's */
  43. #define    GETZCNT    7    /* get semzcnt */
  44. #define    SETVAL    8    /* set semval */
  45. #define    SETALL    9    /* set all semval's */
  46.  
  47. /*
  48. **    Structure Definitions.
  49. */
  50.  
  51. /*
  52. **    There is one semaphore id data structure for each set of semaphores
  53. **        in the system.
  54. */
  55.  
  56. struct semid_ds {
  57.     struct ipc_perm    sem_perm;    /* operation permission struct */
  58.     struct sem    *sem_base;    /* ptr to first semaphore in set */
  59.     ushort        sem_nsems;    /* # of semaphores in set */
  60.     time_t        sem_otime;    /* last semop time */
  61.     time_t        sem_ctime;    /* last change time */
  62. };
  63.  
  64. /*
  65. **    There is one semaphore structure for each semaphore in the system.
  66. */
  67.  
  68. struct sem {
  69.     ushort    semval;        /* semaphore text map address */
  70.     short    sempid;        /* pid of last operation */
  71.     ushort    semncnt;    /* # awaiting semval > cval */
  72.     ushort    semzcnt;    /* # awaiting semval = 0 */
  73. };
  74.  
  75. /*
  76. **    There is one undo structure per process in the system.
  77. */
  78.  
  79. struct sem_undo {
  80.     struct sem_undo    *un_np;    /* ptr to next active undo structure */
  81.     short        un_cnt;    /* # of active entries */
  82.     struct undo {
  83.         short    un_aoe;    /* adjust on exit values */
  84.         short    un_num;    /* semaphore # */
  85.         int    un_id;    /* semid */
  86.     }    un_ent[1];    /* undo entries (one minimum) */
  87. };
  88.  
  89. /*
  90. ** semaphore information structure
  91. */
  92. struct    seminfo    {
  93.     int    semmap,        /* # of entries in semaphore map */
  94.         semmni,        /* # of semaphore identifiers */
  95.         semmns,        /* # of semaphores in system */
  96.         semmnu,        /* # of undo structures in system */
  97.         semmsl,        /* max # of semaphores per id */
  98.         semopm,        /* max # of operations per semop call */
  99.         semume,        /* max # of undo entries per process */
  100.         semusz,        /* size in bytes of undo structure */
  101.         semvmx,        /* semaphore maximum value */
  102.         semaem;        /* adjust on exit max value */
  103. };
  104.  
  105. /*
  106. **    User semaphore template for semop system calls.
  107. */
  108.  
  109. struct sembuf {
  110.     ushort    sem_num;    /* semaphore # */
  111.     short    sem_op;        /* semaphore operation */
  112.     short    sem_flg;    /* operation flags */
  113. };
  114.  
  115.