home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / main.bin / monitor_cache.h < prev    next >
C/C++ Source or Header  |  1997-11-24  |  3KB  |  84 lines

  1. /*
  2.  * @(#)monitor_cache.h    1.21 97/10/07
  3.  * 
  4.  * Copyright (c) 1995, 1996 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  * CopyrightVersion 1.1_beta
  20.  * 
  21.  */
  22.  
  23. /*
  24.  * Monitor cache definitions
  25.  */
  26.  
  27. #ifndef _MONITOR_CACHE_H_
  28. #define _MONITOR_CACHE_H_
  29.  
  30. #include "monitor.h"        /* For TIMEOUT_INFINITY */
  31.  
  32. /*
  33.  * There is a distinct recursive lock (not necessarily a monitor) for
  34.  * the monitor cache.
  35.  */
  36. #define CACHE_LOCK_INIT() sysCacheLockInit()
  37. #define CACHE_LOCK()      sysCacheLock()
  38. #define CACHE_LOCKED()      sysCacheLocked()
  39. #define CACHE_UNLOCK()      sysCacheUnlock()
  40.  
  41. /*
  42.  * External routines.
  43.  */
  44. monitor_t *lookupMonitor(unsigned int);
  45. monitor_t *createMonitor(unsigned int);
  46. monitor_t *findMonitor(sys_thread_t *tid, unsigned int key, bool_t create);
  47. void monitorEnumerate(void (*)(monitor_t *, void *), void *);
  48. void monitorEnumerate_unlocked(void (*)(monitor_t *, void *), void *);
  49.  
  50. /*
  51.  * This should probably just be defined as a function but it seems that
  52.  * most of the x86 compilers aren't very agressive inliners and I'd
  53.  * really like this to be inlined.
  54.  */
  55.  
  56. #define checkCache(mon, tid, key) \
  57. { \
  58.     extern int systemIsMP; \
  59.     sys_thread_t * _tid = (tid); \
  60.     unsigned _key = (key); \
  61.     monitor_t * _mon; \
  62.     if (tid) { \
  63.         /* \
  64.          * Stash the key currently being looked up; the monitor in the \
  65.          * global cache for it, even if otherwise unused, is never collected. \
  66.          */ \
  67.         sysCurrentCacheKey(tid) = key; \
  68.         if (systemIsMP) { \
  69.             sysMemoryFlush(); \
  70.         } \
  71.         _mon = sysLocalMonCache(tid, (((key) >> 3) & (SYS_TLS_MONCACHE-1))); \
  72.         if ((_mon != 0) && (_mon->key == key)) { \
  73.             mon = _mon; \
  74.         } else { \
  75.             mon = NULL; \
  76.         } \
  77.     } else \
  78.     mon = NULL; \
  79. }
  80.  
  81.  
  82.  
  83. #endif /* !_MONITOR_CACHE_H_ */
  84.