home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume14 / sharedmem / part01 / src / cm_man.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-05-17  |  1.9 KB  |  59 lines

  1. /*
  2.  
  3. Common memory is local to the CMM process.  It is composed of:
  4.  
  5. An array of variables.  Each variable is a structure with elements such as
  6. a name, type, value, etc.
  7.  
  8. Variable values can be stored in the variable structure if they are small
  9. (such as an int) or in a piece of malloc'd memory if they are large (such
  10. as a string).
  11.  
  12. An array of process descriptors.  Each process descriptor is a structure.
  13. The most important element of this structure is the wakeup field.  If it is
  14. set, the process should be informed of new variable values.
  15. */
  16.  
  17. #define CM_MANAGER_NAME        "cm manager"
  18. #define CM_MAXVARIABLES        50
  19. #define CM_MAXPROCESSES        20
  20.  
  21. #define is_new(proc,var)        (var->role[proc].new)
  22. #define is_reader(proc,var)        (var->role[proc].reader)
  23. #define is_wakeup(proc,var)        (var->role[proc].wakeup)
  24. #define is_writer(proc,var)        (var->role[proc].writer)
  25. #define is_nonxwriter(proc,var)        (var->role[proc].writer && \
  26.                      var->xwriter != proc)
  27. #define is_xwriter(proc,var)        (var->xwriter == proc)
  28.  
  29. #define CM_NULL_PROCESS        -1
  30.  
  31. /* process descriptors */
  32. /* this table is indexed by corresponding file descriptors (or sockets) */
  33. struct process {
  34.     char name[CM_PROCESSNAMELENGTH];
  35.     int inuse;
  36.     int wakeup;            /* per process wakeup */
  37. };
  38.  
  39. /* this is how variables are stored internally to the cmm */
  40. struct variable {
  41.     char name[CM_VARIABLENAMELENGTH];
  42.     struct cm_value data;    /* data (and size, if necessary) */
  43.     unsigned long count;    /* nth definition of this var */
  44.     struct timeval timestamp;    /* when last written */
  45.     int command_association;
  46.     int xwriter;            /* name of exclusive writer */
  47.     int writers;            /* number of (any type of) writers */
  48.     int readers;            /* number of readers */
  49.     struct {
  50.         unsigned reader : 1;    /* reader */
  51.         unsigned writer : 1;    /* writer */
  52.         unsigned wakeup : 1;    /* a-wake me */
  53.         unsigned new    : 1;    /* changed but not read */
  54.     } role[CM_MAXPROCESSES];
  55. };
  56.  
  57. /* internal errors specific to CMM */
  58. #define E_GET_VARIABLE_NO_SPACE        -1
  59.