home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 202.img / SCO386N2.TD0 / usr / include / sys / sem.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-05-18  |  3.0 KB  |  125 lines

  1. /*
  2.  *    @(#) sem.h 2.1 88/05/18 
  3.  *
  4.  *    Copyright (C) The Santa Cruz Operation, 1984, 1985, 1986, 1987.
  5.  *    Copyright (C) Microsoft Corporation, 1984, 1985, 1986, 1987.
  6.  *    This Module contains Proprietary Information of
  7.  *    The Santa Cruz Operation, Microsoft Corporation
  8.  *    and AT&T, and should be treated as Confidential.
  9.  */
  10.  
  11. /*
  12.  * THIS FILE CONTAINS CODE WHICH IS SPECIFIC TO THE
  13.  * INTEL 80286 CPU AND MAY REQUIRE MODIFICATION
  14.  * WHEN ADAPTING XENIX TO NEW HARDWARE.
  15.  */
  16.  
  17. /*
  18.  *    Implementation Constants.
  19.  */
  20.  
  21. #define    PSEMN    (PZERO + 3)    /* sleep priority waiting for greater value */
  22. #define    PSEMZ    (PZERO + 2)    /* sleep priority waiting for zero */
  23.  
  24. /*
  25.  *    Permission Definitions.
  26.  */
  27.  
  28. #define    SEM_A    0200    /* alter permission */
  29. #define    SEM_R    0400    /* read permission */
  30.  
  31. /*
  32.  *    Semaphore Operation Flags.
  33.  */
  34.  
  35. #define    SEM_UNDO    010000    /* set up adjust on exit entry */
  36.  
  37. /*
  38.  *    Semctl Command Definitions.
  39.  */
  40.  
  41. #define    GETNCNT    3    /* get semncnt */
  42. #define    GETPID    4    /* get sempid */
  43. #define    GETVAL    5    /* get semval */
  44. #define    GETALL    6    /* get all semval's */
  45. #define    GETZCNT    7    /* get semzcnt */
  46. #define    SETVAL    8    /* set semval */
  47. #define    SETALL    9    /* set all semval's */
  48.  
  49. /*
  50.  *    Structure Definitions.
  51.  */
  52.  
  53. /*
  54.  *    There is one semaphore id data structure for each set of semaphores
  55.  *        in the system.
  56.  */
  57.  
  58. struct semid_ds {
  59.     struct ipc_perm    sem_perm;    /* operation permission struct */
  60. #ifdef M_I386
  61.     struct sem *sem_base;    /* ptr to first semaphore in set */
  62. #else
  63.     struct sem near *sem_base;    /* ptr to first semaphore in set */
  64. #endif
  65.     ushort        sem_nsems;    /* # of semaphores in set */
  66.     time_t        sem_otime;    /* last semop time */
  67.     time_t        sem_ctime;    /* last change time */
  68. };
  69.  
  70. /*
  71.  *    There is one semaphore structure for each semaphore in the system.
  72.  */
  73.  
  74. struct sem {
  75.     ushort    semval;        /* semaphore text map address */
  76.     short    sempid;        /* pid of last operation */
  77.     ushort    semncnt;    /* # awaiting semval > cval */
  78.     ushort    semzcnt;    /* # awaiting semval = 0 */
  79. };
  80.  
  81. /*
  82. **    There is one undo structure per process in the system.
  83. */
  84.  
  85. struct sem_undo {
  86. #ifdef M_I386
  87.     struct sem_undo     *un_np;    /* ptr to next active undo structure */
  88. #else
  89.     struct sem_undo     near *un_np;    /* ptr to next active undo structure */
  90. #endif
  91.     short        un_cnt;    /* # of active entries */
  92.     struct undo {
  93.         short    un_aoe;    /* adjust on exit values */
  94.         short    un_num;    /* semaphore # */
  95.         int    un_id;    /* semid */
  96.     }    un_ent[1];    /* undo entries (one minimum) */
  97. };
  98.  
  99. /*
  100. ** semaphore information structure
  101. */
  102. struct    seminfo    {
  103.     int    semmap,        /* # of entries in semaphore map */
  104.         semmni,        /* # of semaphore identifiers */
  105.         semmns,        /* # of semaphores in system */
  106.         semmnu,        /* # of undo structures in system */
  107.         semmsl,        /* max # of semaphores per id */
  108.         semopm,        /* max # of operations per semop call */
  109.         semume,        /* max # of undo entries per process */
  110.         semusz,        /* size in bytes of undo structure */
  111.         semvmx,        /* semaphore maximum value */
  112.         semaem;        /* adjust on exit max value */
  113. };
  114.  
  115. /*
  116.  *    User semaphore template for semop system calls.
  117.  */
  118.  
  119. struct sembuf {
  120.     ushort    sem_num;    /* semaphore # */
  121.     short    sem_op;        /* semaphore operation */
  122.     short    sem_flg;    /* operation flags */
  123. };
  124.  
  125.