⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 monitor_cache.h

📁 《移动Agent技术》一书的所有章节源代码。
💻 H
字号:
/*
 * @(#)monitor_cache.h	1.21 97/10/07
 *
 * Copyright (c) 1995, 1996 Sun Microsystems, Inc. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of Sun
 * Microsystems, Inc. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Sun.
 *
 * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
 * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
 * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
 * THIS SOFTWARE OR ITS DERIVATIVES.
 *
 * CopyrightVersion 1.1_beta
 *
 */

/*
 * Monitor cache definitions
 */

#ifndef _MONITOR_CACHE_H_
#define _MONITOR_CACHE_H_

#include "monitor.h"		/* For TIMEOUT_INFINITY */

/*
 * There is a distinct recursive lock (not necessarily a monitor) for
 * the monitor cache.
 */
#ifdef MON_FLAT /* ibm.3740 */
extern sys_mon_t *_moncache_lock;
#define CACHE_LOCK_INIT() monitorRegister(_moncache_lock, "Monitor cache lock");
#define CACHE_LOCK()	  sysMonitorEnter(_moncache_lock)
#define CACHE_LOCKED()	  sysMonitorEntered(_moncache_lock)
#define CACHE_UNLOCK()	  sysMonitorExit(_moncache_lock)
#define CACHE_NOTIFY_ALL() sysMonitorNotifyAll(_moncache_lock)  /*ibm.4154*/
#define CACHE_WAIT()	  if (sysMonitorWait(_moncache_lock, TIMEOUT_INFINITY, FALSE) != 0) /*ibm.5642*/ \
				{ CACHE_UNLOCK(); sysThreadYield(); CACHE_LOCK(); }	    /*ibm.5642*/
#else
#define CACHE_LOCK_INIT() sysCacheLockInit()
#define CACHE_LOCK()	  sysCacheLock()
#define CACHE_LOCKED()	  sysCacheLocked()
#define CACHE_UNLOCK()	  sysCacheUnlock()
#endif /* ibm.3740 */

/*
 * External routines.
 */
#ifdef MON_FLAT /* ibm.3740 */
void allocMonitor(struct Hjava_lang_Object *);
void monitorDealloc(struct Hjava_lang_Object *);

typedef struct monitor_index_cb_t {
  long count;
  long length;
  infl_mon_t **buf;
} monitor_index_cb_t;

extern monitor_index_cb_t micb;

infl_mon_t *monitorIndexToMonitor(int idx);
int monitorIndex(infl_mon_t *mon);
#else
monitor_t *lookupMonitor(unsigned int);
monitor_t *createMonitor(unsigned int);
monitor_t *findMonitor(sys_thread_t *tid, unsigned int key, bool_t create);
void monitorEnumerate(void (*)(monitor_t *, void *), void *);
void monitorEnumerate_unlocked(void (*)(monitor_t *, void *), void *);

/*
 * This should probably just be defined as a function but it seems that
 * most of the x86 compilers aren't very agressive inliners and I'd
 * really like this to be inlined.
 */

#define checkCache(mon, tid, key) \
{ \
    extern int systemIsMP; \
    sys_thread_t * _tid = (tid); \
    unsigned _key = (key); \
    monitor_t * _mon; \
    if (tid) { \
        /* \
         * Stash the key currently being looked up; the monitor in the \
         * global cache for it, even if otherwise unused, is never collected. \
         */ \
        sysCurrentCacheKey(tid) = key; \
        if (systemIsMP) { \
            sysMemoryFlush(); \
        } \
        _mon = sysLocalMonCache(tid, (((key) >> 3) & (SYS_TLS_MONCACHE-1))); \
        if ((_mon != 0) && (_mon->key == key)) { \
            mon = _mon; \
        } else { \
            mon = NULL; \
        } \
    } else \
	mon = NULL; \
}

#endif

#endif /* !_MONITOR_CACHE_H_ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -