home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / os2sdk / os2sdk12 / share / share.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-20  |  942 b   |  27 lines

  1. /*
  2.  * This is a common include file used by examples share.c and shrchild.c.
  3.  * It contains the declaration of the shared memory segment.
  4.  */
  5.  
  6. /* Convert an unsigned selector and an unsigned offset into a far pointer */
  7.  
  8.  
  9. /* size of shared memory segment */
  10. #define    SHRSEGSIZE    sizeof(struct ShareRec)    
  11.  
  12. #define SHRSEGNAME    "\\SHAREMEM\\SHARESEG.DAT"      /* shared seg name */
  13. #define    CIRCBUFSIZE    20        /* size of circular buffer */
  14. #define WAITFOREVER    -1L        /* no timeout if semaphore is owned */
  15.  
  16. struct ShareRec {
  17.     ULONG        fullsem;    /* buffer access semaphore */
  18.     ULONG        emptysem;    /* buffer access semaphore */
  19.     ULONG        mutexsem;    /* buffer access semaphore */
  20.     int        head;        /* buffer write pointer */
  21.     int        tail;        /* buffer read pointer */
  22.     char         CircBuffer[CIRCBUFSIZE];    /* circular buffer */
  23. };
  24.  
  25. /* definition of buffer full condition */
  26. #define BUFFUL(p) ((p->head==p->tail-1)||((p->tail==0)&&(p->head==CIRCBUFSIZE-1)))
  27.