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 / msg.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-06-26  |  2.9 KB  |  111 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:msg.h    1.3"
  10.  
  11. /*
  12. **    IPC Message Facility.
  13. */
  14.  
  15. /*
  16. **    Implementation Constants.
  17. */
  18.  
  19. #define    PMSG    (PZERO + 2)    /* message facility sleep priority */
  20.  
  21. /*
  22. **    Permission Definitions.
  23. */
  24.  
  25. #define    MSG_R    0400    /* read permission */
  26. #define    MSG_W    0200    /* write permission */
  27.  
  28. /*
  29. **    ipc_perm Mode Definitions.
  30. */
  31.  
  32. #define    MSG_RWAIT    01000    /* a reader is waiting for a message */
  33. #define    MSG_WWAIT    02000    /* a writer is waiting to send */
  34.  
  35. /*
  36. **    Message Operation Flags.
  37. */
  38.  
  39. #define    MSG_NOERROR    010000    /* no error if big message */
  40.  
  41. /*
  42. **    Structure Definitions.
  43. */
  44.  
  45. /*
  46. **    There is one msg queue id data structure for each q in the system.
  47. */
  48.  
  49. struct msqid_ds {
  50.     struct ipc_perm    msg_perm;    /* operation permission struct */
  51.     struct msg    *msg_first;    /* ptr to first message on q */
  52.     struct msg    *msg_last;    /* ptr to last message on q */
  53.     ushort        msg_cbytes;    /* current # bytes on q */
  54.     ushort        msg_qnum;    /* # of messages on q */
  55.     ushort        msg_qbytes;    /* max # of bytes on q */
  56.     ushort        msg_lspid;    /* pid of last msgsnd */
  57.     ushort        msg_lrpid;    /* pid of last msgrcv */
  58.     time_t        msg_stime;    /* last msgsnd time */
  59.     time_t        msg_rtime;    /* last msgrcv time */
  60.     time_t        msg_ctime;    /* last change time */
  61. };
  62.  
  63. /*
  64. **    There is one msg structure for each message that may be in the system.
  65. */
  66.  
  67. struct msg {
  68.     struct msg    *msg_next;    /* ptr to next message on q */
  69.     long        msg_type;    /* message type */
  70.     short        msg_ts;        /* message text size */
  71.     short        msg_spot;    /* message text map address */
  72. };
  73.  
  74. /*
  75. **    User message buffer template for msgsnd and msgrecv system calls.
  76. */
  77.  
  78. struct msgbuf {
  79.     long    mtype;        /* message type */
  80.     char    mtext[1];    /* message text */
  81. };
  82.  
  83. /*
  84. **    Message information structure.
  85. */
  86.  
  87. struct msginfo {
  88.     int    msgmap,    /* # of entries in msg map */
  89.         msgmax,    /* max message size */
  90.         msgmnb,    /* max # bytes on queue */
  91.         msgmni,    /* # of message queue identifiers */
  92.         msgssz,    /* msg segment size (should be word size multiple) */
  93.         msgtql;    /* # of system message headers */
  94.     ushort    msgseg;    /* # of msg segments (MUST BE < 32768) */
  95. };
  96.  
  97. /*    We have to be able to lock a message queue since we can
  98. **    sleep during message processing due to a page fault in
  99. **    copyin/copyout or iomove.  We cannot add anything to the
  100. **    msqid_ds structure since this is used in user programs
  101. **    and any change would break object file compatibility.
  102. **    Therefore, we allocate a parallel array, msglock, which
  103. **    is used to lock a message queue.  The array is defined
  104. **    in the msg master file.  The following macro takes a
  105. **    pointer to a message queue and returns a pointer to the
  106. **    lock entry.  The argument must be a pointer to a msgqid
  107. **    structure.
  108. **/
  109.  
  110. #define    MSGLOCK(X)    &msglock[X - msgque]
  111.