2
|
1 |
/*
|
5506
|
2 |
* Copyright (c) 1994, 1998, Oracle and/or its affiliates. All rights reserved.
|
2
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
5506
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
2
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
5506
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
2
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
5506
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
22 |
* or visit www.oracle.com if you need additional information or have any
|
|
23 |
* questions.
|
2
|
24 |
*/
|
|
25 |
|
|
26 |
/*
|
|
27 |
* Monitor interface 10/25/94
|
|
28 |
*
|
|
29 |
* Private data structures and interfaces used in the monitor code.
|
|
30 |
* This file is used to share declarations and such between the different
|
|
31 |
* files implementing monitors. It does not contain exported API.
|
|
32 |
*/
|
|
33 |
|
|
34 |
#ifndef _JAVASOFT_SOLARIS_MONITOR_MD_H_
|
|
35 |
#define _JAVASOFT_SOLARIS_MONITOR_MD_H_
|
|
36 |
|
|
37 |
#include <mutex_md.h>
|
|
38 |
#include <condvar_md.h>
|
|
39 |
#include <threads_md.h>
|
|
40 |
|
|
41 |
/*
|
|
42 |
* Type definitions.
|
|
43 |
*/
|
|
44 |
|
|
45 |
typedef struct monitor_waiter monitor_waiter_t;
|
|
46 |
typedef struct monitor_wait_queue monitor_wait_queue_t;
|
|
47 |
|
|
48 |
/* Element of the MonitorWaitQ - representing thread doing a monitor wait */
|
|
49 |
/*
|
|
50 |
* The only reason we do the queueing is for sysMonitorDumpInfo.
|
|
51 |
* The counting, though, is used to avoid extraneous calls to
|
|
52 |
* condvarBroadcast and condvarSignal, for instance.
|
|
53 |
*/
|
|
54 |
struct monitor_waiter {
|
|
55 |
monitor_waiter_t *next;
|
|
56 |
monitor_waiter_t **prev;
|
|
57 |
sys_thread_t *waiting_thread;
|
|
58 |
};
|
|
59 |
|
|
60 |
struct monitor_wait_queue {
|
|
61 |
monitor_waiter_t *head; /* linked list of waiting threads */
|
|
62 |
short count; /* number of waiters on the list */
|
|
63 |
};
|
|
64 |
|
|
65 |
#define ANY_WAITING(mwq) ((mwq).count > 0)
|
|
66 |
#define INIT_MONITOR_WAIT_QUEUE(mwq) { (mwq).head = NULL; (mwq).count = 0; }
|
|
67 |
|
|
68 |
/* The system-level monitor data structure */
|
|
69 |
struct sys_mon {
|
|
70 |
mutex_t mutex; /* The monitor's mutex */
|
|
71 |
condvar_t cv_monitor; /* Notify those doing monitorWait on
|
|
72 |
the monitor */
|
|
73 |
/*
|
|
74 |
* Threads waiting on either of the above condvars put themselves
|
|
75 |
* on one of these lists.
|
|
76 |
*/
|
|
77 |
monitor_wait_queue_t mwait_queue; /* Head of MonitorWaitQ */
|
|
78 |
|
|
79 |
/* Thread currently executing in this monitor */
|
|
80 |
sys_thread_t *monitor_owner;
|
|
81 |
long entry_count; /* Recursion depth */
|
|
82 |
int contention_count;
|
|
83 |
};
|
|
84 |
|
|
85 |
void initializeContentionCountMutex();
|
|
86 |
|
|
87 |
typedef enum {
|
|
88 |
ASYNC_REGISTER,
|
|
89 |
ASYNC_UNREGISTER
|
|
90 |
} async_action_t;
|
|
91 |
|
|
92 |
/*
|
|
93 |
* Macros
|
|
94 |
*/
|
|
95 |
|
|
96 |
#define SYS_MID_NULL ((sys_mon_t *) 0)
|
|
97 |
|
|
98 |
typedef enum {
|
|
99 |
SYS_ASYNC_MON_ALARM = 1,
|
|
100 |
SYS_ASYNC_MON_IO,
|
|
101 |
SYS_ASYNC_MON_EVENT,
|
|
102 |
SYS_ASYNC_MON_CHILD,
|
|
103 |
SYS_ASYNC_MON_MAX
|
|
104 |
} async_mon_key_t;
|
|
105 |
|
|
106 |
#define SYS_ASYNC_MON_INPUT SYS_ASYNC_MON_IO
|
|
107 |
#define SYS_ASYNC_MON_OUTPUT SYS_ASYNC_MON_IO
|
|
108 |
|
|
109 |
sys_mon_t *asyncMon(async_mon_key_t);
|
|
110 |
|
|
111 |
#endif /* !_JAVASOFT_SOLARIS_MONITOR_MD_H_ */
|