author | dcubed |
Tue, 17 Jun 2014 12:54:01 -0700 | |
changeset 25064 | 244218e6ec0a |
parent 20377 | 393ee12eccc8 |
permissions | -rw-r--r-- |
10565 | 1 |
/* |
18025 | 2 |
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. |
10565 | 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. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
#ifndef OS_BSD_VM_OSTHREAD_BSD_HPP |
|
26 |
#define OS_BSD_VM_OSTHREAD_BSD_HPP |
|
27 |
||
28 |
private: |
|
29 |
int _thread_type; |
|
30 |
||
31 |
public: |
|
32 |
||
33 |
int thread_type() const { |
|
34 |
return _thread_type; |
|
35 |
} |
|
36 |
void set_thread_type(int type) { |
|
37 |
_thread_type = type; |
|
38 |
} |
|
39 |
||
40 |
private: |
|
41 |
||
11881
9642744ae9a5
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
10565
diff
changeset
|
42 |
#ifdef __APPLE__ |
12765
3e1b42265329
7161732: Improve handling of thread_id in OSThread
rbackman
parents:
12377
diff
changeset
|
43 |
typedef thread_t thread_id_t; |
11881
9642744ae9a5
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
10565
diff
changeset
|
44 |
#else |
20377
393ee12eccc8
8022616: u4 should not be used as a type for thread_id
dsamersoff
parents:
18025
diff
changeset
|
45 |
typedef pid_t thread_id_t; |
12765
3e1b42265329
7161732: Improve handling of thread_id in OSThread
rbackman
parents:
12377
diff
changeset
|
46 |
#endif |
3e1b42265329
7161732: Improve handling of thread_id in OSThread
rbackman
parents:
12377
diff
changeset
|
47 |
|
11881
9642744ae9a5
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
10565
diff
changeset
|
48 |
// _pthread_id is the pthread id, which is used by library calls |
9642744ae9a5
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
10565
diff
changeset
|
49 |
// (e.g. pthread_kill). |
10565 | 50 |
pthread_t _pthread_id; |
11881
9642744ae9a5
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
10565
diff
changeset
|
51 |
|
15593
860cf6c70c06
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
14286
diff
changeset
|
52 |
// This is the "thread_id" from struct thread_identifier_info. According to a |
860cf6c70c06
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
14286
diff
changeset
|
53 |
// comment in thread_info.h, this is a "system-wide unique 64-bit thread id". |
860cf6c70c06
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
14286
diff
changeset
|
54 |
// The value is used by SA to correlate threads. |
860cf6c70c06
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
14286
diff
changeset
|
55 |
uint64_t _unique_thread_id; |
860cf6c70c06
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
14286
diff
changeset
|
56 |
|
10565 | 57 |
sigset_t _caller_sigmask; // Caller's signal mask |
58 |
||
59 |
public: |
|
60 |
||
61 |
// Methods to save/restore caller's signal mask |
|
62 |
sigset_t caller_sigmask() const { return _caller_sigmask; } |
|
63 |
void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; } |
|
64 |
||
65 |
#ifndef PRODUCT |
|
66 |
// Used for debugging, return a unique integer for each thread. |
|
67 |
intptr_t thread_identifier() const { return (intptr_t)_pthread_id; } |
|
68 |
#endif |
|
12765
3e1b42265329
7161732: Improve handling of thread_id in OSThread
rbackman
parents:
12377
diff
changeset
|
69 |
|
10565 | 70 |
#ifdef ASSERT |
71 |
// We expect no reposition failures so kill vm if we get one. |
|
72 |
// |
|
73 |
bool valid_reposition_failure() { |
|
74 |
return false; |
|
75 |
} |
|
76 |
#endif // ASSERT |
|
12765
3e1b42265329
7161732: Improve handling of thread_id in OSThread
rbackman
parents:
12377
diff
changeset
|
77 |
|
10565 | 78 |
pthread_t pthread_id() const { |
79 |
return _pthread_id; |
|
80 |
} |
|
81 |
void set_pthread_id(pthread_t tid) { |
|
82 |
_pthread_id = tid; |
|
83 |
} |
|
84 |
||
15593
860cf6c70c06
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
14286
diff
changeset
|
85 |
void set_unique_thread_id(uint64_t id) { |
860cf6c70c06
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
14286
diff
changeset
|
86 |
_unique_thread_id = id; |
860cf6c70c06
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
14286
diff
changeset
|
87 |
} |
860cf6c70c06
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
14286
diff
changeset
|
88 |
|
10565 | 89 |
// *************************************************************** |
90 |
// suspension support. |
|
91 |
// *************************************************************** |
|
92 |
||
93 |
public: |
|
94 |
// flags that support signal based suspend/resume on Bsd are in a |
|
95 |
// separate class to avoid confusion with many flags in OSThread that |
|
96 |
// are used by VM level suspend/resume. |
|
18025 | 97 |
os::SuspendResume sr; |
10565 | 98 |
|
99 |
// _ucontext and _siginfo are used by SR_handler() to save thread context, |
|
100 |
// and they will later be used to walk the stack or reposition thread PC. |
|
101 |
// If the thread is not suspended in SR_handler() (e.g. self suspend), |
|
102 |
// the value in _ucontext is meaningless, so we must use the last Java |
|
103 |
// frame information as the frame. This will mean that for threads |
|
104 |
// that are parked on a mutex the profiler (and safepoint mechanism) |
|
105 |
// will see the thread as if it were still in the Java frame. This |
|
106 |
// not a problem for the profiler since the Java frame is a close |
|
107 |
// enough result. For the safepoint mechanism when the give it the |
|
108 |
// Java frame we are not at a point where the safepoint needs the |
|
109 |
// frame to that accurate (like for a compiled safepoint) since we |
|
110 |
// should be in a place where we are native and will block ourselves |
|
111 |
// if we transition. |
|
112 |
private: |
|
113 |
void* _siginfo; |
|
114 |
ucontext_t* _ucontext; |
|
115 |
int _expanding_stack; /* non zero if manually expanding stack */ |
|
116 |
address _alt_sig_stack; /* address of base of alternate signal stack */ |
|
117 |
||
118 |
public: |
|
119 |
void* siginfo() const { return _siginfo; } |
|
120 |
void set_siginfo(void* ptr) { _siginfo = ptr; } |
|
121 |
ucontext_t* ucontext() const { return _ucontext; } |
|
122 |
void set_ucontext(ucontext_t* ptr) { _ucontext = ptr; } |
|
123 |
void set_expanding_stack(void) { _expanding_stack = 1; } |
|
124 |
void clear_expanding_stack(void) { _expanding_stack = 0; } |
|
125 |
int expanding_stack(void) { return _expanding_stack; } |
|
126 |
||
127 |
void set_alt_sig_stack(address val) { _alt_sig_stack = val; } |
|
128 |
address alt_sig_stack(void) { return _alt_sig_stack; } |
|
129 |
||
130 |
private: |
|
131 |
Monitor* _startThread_lock; // sync parent and child in thread creation |
|
132 |
||
133 |
public: |
|
134 |
||
135 |
Monitor* startThread_lock() const { |
|
136 |
return _startThread_lock; |
|
137 |
} |
|
138 |
||
139 |
// *************************************************************** |
|
140 |
// Platform dependent initialization and cleanup |
|
141 |
// *************************************************************** |
|
142 |
||
143 |
private: |
|
144 |
||
145 |
void pd_initialize(); |
|
146 |
void pd_destroy(); |
|
147 |
||
148 |
// Reconciliation History |
|
149 |
// osThread_solaris.hpp 1.24 99/08/27 13:11:54 |
|
150 |
// End |
|
151 |
||
152 |
#endif // OS_BSD_VM_OSTHREAD_BSD_HPP |