J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 1994-1999 Sun Microsystems, Inc. All Rights Reserved. |
| 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 |
| 7 | * published by the Free Software Foundation. Sun designates this |
| 8 | * particular file as subject to the "Classpath" exception as provided |
| 9 | * by Sun in the LICENSE file that accompanied this code. |
| 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 | * |
| 21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 23 | * have any questions. |
| 24 | */ |
| 25 | |
| 26 | /* |
| 27 | * Win32 implementation of Java threads |
| 28 | */ |
| 29 | |
| 30 | #ifndef _JAVASOFT_WIN32_THREADS_MD_H_ |
| 31 | #define _JAVASOFT_WIN32_THREADS_MD_H_ |
| 32 | |
| 33 | #include <windows.h> |
| 34 | |
| 35 | #define N_TRACED_REGS 7 |
| 36 | |
| 37 | #define SYS_THREAD_NULL ((sys_thread_t *) 0) |
| 38 | |
| 39 | /* |
| 40 | * Machine dependent info in a sys_thread_t: Keep these values in |
| 41 | * sync with the string array used by sysThreadDumpInfo() in threads_md.c! |
| 42 | */ |
| 43 | typedef enum { |
| 44 | FIRST_THREAD_STATE, |
| 45 | RUNNABLE = FIRST_THREAD_STATE, |
| 46 | SUSPENDED, |
| 47 | MONITOR_WAIT, |
| 48 | CONDVAR_WAIT, |
| 49 | MONITOR_SUSPENDED, |
| 50 | NUM_THREAD_STATES |
| 51 | } thread_state_t; |
| 52 | |
| 53 | struct sys_mon; |
| 54 | |
| 55 | /* |
| 56 | * Machine dependent thread data structure |
| 57 | */ |
| 58 | typedef struct sys_thread { |
| 59 | HANDLE handle; /* Win32 thread handle */ |
| 60 | unsigned long id; /* Win32 thread id */ |
| 61 | long regs[N_TRACED_REGS]; /* Registers */ |
| 62 | thread_state_t state; /* Current thread state */ |
| 63 | bool_t system_thread; /* TRUE if this is a system thread */ |
| 64 | bool_t interrupted; /* Shadow thread interruption */ |
| 65 | short suspend_flags; |
| 66 | HANDLE interrupt_event; /* Event signaled on thread interrupt */ |
| 67 | struct sys_mon *wait_monitor; /* Monitor the thread is waiting for */ |
| 68 | struct sys_thread *next_waiter; /* Next thread in the waiting queue */ |
| 69 | struct sys_mon *enter_monitor; /* Monitor thread is waiting to enter */ |
| 70 | void (*start_proc)(void *); /* Thread start routine address */ |
| 71 | void *start_parm; /* Thread start routine parameter */ |
| 72 | struct sys_thread *next; /* Next thread in active thread queue */ |
| 73 | void *stack_ptr; /* Pointer into the stack segment */ |
| 74 | unsigned int last_sum; |
| 75 | PNT_TIB nt_tib; /* Pointer to NT thread-local block */ |
| 76 | } sys_thread_t; |
| 77 | |
| 78 | #define MONITOR_WAIT_SUSPENDED 0x0001 |
| 79 | #define CONDVAR_WAIT_SUSPENDED 0x0002 |
| 80 | |
| 81 | extern bool_t ThreadsInitialized; |
| 82 | |
| 83 | extern sys_mon_t *_sys_queue_lock; |
| 84 | |
| 85 | #define SYS_QUEUE_LOCK(self) sysMonitorEnter(self, _sys_queue_lock) |
| 86 | #define SYS_QUEUE_LOCKED(self) sysMonitorEntered(self, _sys_queue_lock) |
| 87 | #define SYS_QUEUE_UNLOCK(self) sysMonitorExit(self, _sys_queue_lock) |
| 88 | #define SYS_QUEUE_NOTIFYALL(self) sysMonitorNotifyAll(self, _sys_queue_lock) |
| 89 | #define SYS_QUEUE_WAIT(self) sysMonitorWait(self, _sys_queue_lock, \ |
| 90 | SYS_TIMEOUT_INFINITY) |
| 91 | |
| 92 | #endif /* !_JAVASOFT_WIN32_THREADS_MD_H_ */ |