home *** CD-ROM | disk | FTP | other *** search
/ Curio City 6 / CURIO6.bin / pc / presents / igo / _setup.1 / monitor.h < prev    next >
C/C++ Source or Header  |  1996-05-03  |  3KB  |  100 lines

  1. /*
  2.  * @(#)monitor.h    1.25 96/02/07
  3.  *
  4.  * Copyright (c) 1994 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software
  7.  * and its documentation for NON-COMMERCIAL purposes and without
  8.  * fee is hereby granted provided that this copyright notice
  9.  * appears in all copies. Please refer to the file "copyright.html"
  10.  * for further important copyright and licensing information.
  11.  *
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  13.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  14.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  15.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  16.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  17.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  18.  */
  19.  
  20. /*
  21.  * Monitor interface
  22.  */
  23.  
  24. #ifndef    _MONITOR_H_
  25. #define    _MONITOR_H_
  26.  
  27. #include "sys_api.h"
  28.  
  29. /*
  30.  * Used by the monitor caching machanism to mark monitors as being
  31.  * in-use.
  32.  */
  33. #define MON_IN_USE            0x1
  34.  
  35. /* The monitor data structure */
  36. typedef struct monitor_t {
  37.     unsigned int    key;        /* monitor hash key */
  38.     struct monitor_t   *next;
  39.     short        flags;        /* flags used by the cache */
  40.     short        uninit_count;    /* monitors created, not entered */
  41.     char        mid[1];
  42. } monitor_t, *MID;
  43.  
  44. /* A macro for accessing the sys_mon_t from the monitor_t */
  45. #define sysmon(m)   (*(sys_mon_t *) m->mid)
  46.  
  47. typedef struct reg_mon_t {
  48.     sys_mon_t *mid;
  49.     char *name;
  50.     struct reg_mon_t *next;
  51. } reg_mon_t;
  52.  
  53. /*
  54.  * Macros
  55.  */
  56. #define MID_NULL         ((MID) 0)
  57. #define TIMEOUT_INFINITY    -1
  58.  
  59. /*
  60.  * Support for the monitor registry
  61.  */
  62. extern sys_mon_t *_registry_lock;
  63.  
  64. #define REGISTRY_LOCK_INIT()    monitorRegister(_registry_lock, \
  65.                         "Monitor registry")
  66. #define REGISTRY_LOCK()          sysMonitorEnter(_registry_lock)
  67. #define REGISTRY_LOCKED()    sysMonitorEntered(_registry_lock)
  68. #define REGISTRY_UNLOCK()    sysMonitorExit(_registry_lock)
  69.  
  70. /*
  71.  * External routines.
  72.  */
  73.  
  74. /*
  75.  * Synchronization interface
  76.  */
  77. void monitorInit(monitor_t *mon);
  78. void monitorCacheInit(void);
  79. void monitorEnter(unsigned int);
  80. void monitorExit(unsigned int);
  81. void monitorWait(unsigned int, int);
  82. void monitorNotify(unsigned int);
  83. void monitorNotifyAll(unsigned int);
  84.  
  85. /* Registry of static monitors */
  86. extern reg_mon_t *MonitorRegistry;
  87.  
  88. void monitorRegistryInit(void);
  89. void monitorRegister(sys_mon_t *, char *);
  90. void monitorUnregister(sys_mon_t *);
  91. void registeredEnumerate(void (*)(reg_mon_t *, void *), void *); 
  92. void registeredEnumerate_unlocked(void (*)(reg_mon_t *, void *), void *); 
  93.  
  94. /*
  95.  * Support for the async part of async GC
  96.  */
  97. #define INTERRUPTS_PENDING() sysInterruptsPending()
  98.  
  99. #endif    /* !_MONITOR_H_ */
  100.