home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / utilities / utilss / sockets / include / sys / h / msg < prev    next >
Encoding:
Text File  |  1995-01-11  |  3.6 KB  |  128 lines

  1. /*
  2.  * $Header: /ax/networking:include/sys/msg.h:networking  1.1  $
  3.  * $Source: /ax/networking:include/sys/msg.h: $
  4.  *
  5.  * Copyright (c) 1988 Acorn Computers Ltd., Cambridge, England
  6.  *
  7.  * $Log:    msg.h,v $
  8.  * Revision 1.1  95/01/11  10:19:25  kwelton
  9.  * Initial revision
  10.  * 
  11.  * Revision 1.3  88/06/17  20:19:53  beta
  12.  * Acorn Unix initial beta version
  13.  * 
  14.  */
  15. /*
  16. **    IPC Message Facility.
  17. */
  18.  
  19. /*
  20. **    Implementation Constants and system limits.
  21. */
  22.  
  23. #define    NMSQID        (5)        /* Max no. of msg queues in system */
  24. #define NMESSAGES    (5)        /* Max no. of messages in system */
  25. #define NMSQBYTES    (1024)        /* Max bytes on one message queue */
  26. #define MSGMAXBYTES    (512)        /* Max bytes in one message */
  27. #define    PMSG        (PZERO + 2)    /* message facility sleep priority */
  28.  
  29. /*
  30. **    Permission Definitions.
  31. */
  32.  
  33. #define    MSG_R    0400    /* read permission */
  34. #define    MSG_W    0200    /* write permission */
  35.  
  36. /*
  37. **    ipc_perm Mode Definitions.
  38. */
  39.  
  40. #define    MSG_RWAIT    01000    /* a reader is waiting for a message */
  41. #define    MSG_WWAIT    02000    /* a writer is waiting to send */
  42.  
  43. /*
  44. **    Message Operation Flags.
  45. */
  46.  
  47. #define    MSG_NOERROR    010000    /* no error if big message */
  48.  
  49. /*
  50. **    Structure Definitions.
  51. */
  52.  
  53. /*
  54. **    There is one msg queue id data structure for each q in the system.
  55. */
  56.  
  57. struct msqid_ds {
  58.     struct ipc_perm    msg_perm;    /* operation permission struct */
  59.     ushort        msg_qnum;    /* # of messages on q */
  60.     ushort        msg_qbytes;    /* max # of bytes on q */
  61.     ushort        msg_lspid;    /* pid of last msgsnd */
  62.     ushort        msg_lrpid;    /* pid of last msgrcv */
  63.     time_t        msg_stime;    /* last msgsnd time */
  64.     time_t        msg_rtime;    /* last msgrcv time */
  65.     time_t        msg_ctime;    /* last change time */
  66.     /* End of part defined in the SVID */
  67.     struct msg    *msg_first;    /* ptr to first message on q */
  68.     struct msg    *msg_last;    /* ptr to last message on q */
  69.     ushort        msg_cbytes;    /* current # bytes on q */
  70. };
  71.  
  72. /*
  73.  *    There is one msg structure for each message that may be in the system.
  74.  *    Note that the SVID does not list 'running out of message text 
  75.  *    space' as a possible error. Therefore, we must have space for
  76.  *    NMESSAGES messages of maximum size. A simple way to achieve this is
  77.  *    allocate the buffer within each msg structure - OK as long as all 
  78.  *    the limits are kept small, otherwise we should allocate dynamically.
  79.  */
  80.  
  81. struct msg {
  82.     struct msg    *msg_next;    /* ptr to next message on q */
  83.     struct msg    *msg_prev;    /* ptr to previous message on q */
  84.     long        msg_type;    /* message type */
  85.     int        msg_ts;        /* message text size */
  86.     char        msg_text[MSGMAXBYTES];    /* message text */
  87. };
  88.  
  89. /*
  90. **    User message buffer template for msgsnd and msgrecv system calls.
  91. */
  92.  
  93. struct msgbuf {
  94.     long    mtype;        /* message type */
  95.     char    mtext[1];    /* message text */
  96. };
  97.  
  98. /*
  99. **    Message information structure.
  100. */
  101.  
  102. struct msginfo {
  103.     int    msgmap,    /* # of entries in msg map */
  104.         msgmax,    /* max message size */
  105.         msgmnb,    /* max # bytes on queue */
  106.         msgmni,    /* # of message queue identifiers */
  107.         msgssz,    /* msg segment size (should be word size multiple) */
  108.         msgtql;    /* # of system message headers */
  109.     ushort    msgseg;    /* # of msg segments (MUST BE < 32768) */
  110. };
  111.  
  112. /*    We have to be able to lock a message queue since we can
  113. **    sleep during message processing due to a page fault in
  114. **    copyin/copyout or iomove.  We cannot add anything to the
  115. **    msqid_ds structure since this is used in user programs
  116. **    and any change would break object file compatibility.
  117. **    Therefore, we allocate a parallel array, msglock, which
  118. **    is used to lock a message queue.  The array is defined
  119. **    in the msg master file.  The following macro takes a
  120. **    pointer to a message queue and returns a pointer to the
  121. **    lock entry.  The argument must be a pointer to a msgqid
  122. **    structure.
  123. **/
  124.  
  125. #define    MSGLOCK(X)    &msglock[X - msgque]
  126.  
  127. /* EOF msg.h */
  128.