home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / shmserve.zip / shmserve.h < prev    next >
Text File  |  1998-12-04  |  4KB  |  97 lines

  1. /*  shmserve.h
  2.  
  3.     This code sample illustrates the usage of suballocated shared memory
  4.     between two or more processes.
  5.  
  6. */
  7.  
  8. /* (c) Copyright IBM Corp. 1998  All rights reserved.
  9.  
  10. This sample program is owned by International Business Machines
  11. Corporation or one of its subsidiaries ("IBM") and is copyrighted
  12. and licensed, not sold.
  13.  
  14. You may copy, modify, and distribute this sample program in any
  15. form without payment to IBM,  for any purpose including developing,
  16. using, marketing or distributing programs that include or are
  17. derivative works of the sample program.
  18.  
  19. The sample program is provided to you on an "AS IS" basis, without
  20. warranty of any kind.  IBM HEREBY  EXPRESSLY DISCLAIMS ALL
  21. WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED
  22. TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  23. PARTICULAR PURPOSE.
  24.  
  25. Some jurisdictions do not allow for the exclusion or limitation of
  26. implied warranties, so the above limitations or exclusions may not
  27. apply to you.  IBM shall not be liable for any damages you suffer
  28. as a result of using, modifying or distributing the sample program
  29. or its derivatives.
  30.  
  31. Each copy of any portion of this sample program or any derivative
  32. work,  must include a the above copyright notice and disclaimer of
  33. warranty.
  34. */
  35.  
  36. /************************************
  37.  * Define Constants
  38.  ************************************/
  39.  
  40. #define SERVER_CONTROL_MEM_NAME     "\\SHAREMEM\\SHMSERVE.SHM"
  41.  
  42. /* Total size of Server Control (Shared) Memory (mostly non-committed/sparse) */
  43. #define SCR_MEM_SIZE            2550000L
  44.  
  45. /* Space at beginning of Server Control (Shared) Memory reserved for */
  46. /*   ServerControlRecord.  (SubAllocated memory starts after this):  */
  47. #define SHMEMINIT                0x1000L
  48.  
  49. /* Initial size of SubAlloc'd shared memory: */
  50. #define INIT_SUBALLOC_MEM_SIZE    32768L
  51.  
  52. /* Grow size of SubAlloc'd shared memory (in addition to current memory): */
  53. #define GROW_SUBALLOC_MEM_SIZE    32768L
  54.  
  55. #define GLOMNameLen            20
  56. #define GLOMValueLen           30
  57.  
  58.  
  59. /************************************
  60.  * Define Structures, Unions
  61.  ************************************/
  62.  
  63. /*----------------------------------------------------------------------------*/
  64. /* struct GLOM                                                                */
  65. /* Data Record of any type, for use by application.                           */
  66. /*----------------------------------------------------------------------------*/
  67.  
  68. typedef struct um_glom
  69.   {
  70.     UCHAR            GLOMName[GLOMNameLen+1];
  71.     UCHAR            GLOMValue[GLOMValueLen+1];
  72.     struct um_glom  *prev_ptr;
  73.     struct um_glom  *next_ptr;
  74.   } GLOM;
  75.  
  76. /*----------------------------------------------------------------------------*/
  77. /* struct SERVERCONTROLREC                                                    */
  78. /* Server Control Record:                                                     */
  79. /*   The Server Control Record is shared amoung all Server processes and      */
  80. /*   is the primary access point for all common Server data.  It is named     */
  81. /*   SERVER_CONTROL_MEM_NAME.                                                 */
  82. /*----------------------------------------------------------------------------*/
  83.  
  84. typedef struct
  85.   {
  86.     PVOID              SubAllocPool;          /* Address of memory pool       */
  87.     HMTX               SubAlloc_Lock;         /* Lock Handle for SubAllocation*/
  88.     ULONG              SubAllocUsage;         /* SubAllocPool current usage   */
  89.     ULONG              SubAllocAvail;         /* SubAllocPool current set size*/
  90.     USHORT             Server_Status;         /* status                       */
  91.                                               /*  0 = Running      */
  92.                                               /*  1 = ShuttingDown */
  93.                                               /*  2 = Starting     */
  94.     GLOM              *GLOM_List_ll_ptr;      /* Linklist of GLOM records     */
  95.     HMTX               GLOM_List_Lock;        /* Lock Handle for GLOM access  */
  96.   } SERVERCONTROLREC;
  97.