annotate src/os/solaris/vm/osThread_solaris.hpp @ 10405:f2110083203d

8005849: JEP 167: Event-Based JVM Tracing Reviewed-by: acorn, coleenp, sla Contributed-by: Karen Kinnear <karen.kinnear@oracle.com>, Bengt Rutisson <bengt.rutisson@oracle.com>, Calvin Cheung <calvin.cheung@oracle.com>, Erik Gahlin <erik.gahlin@oracle.com>, Erik Helin <erik.helin@oracle.com>, Jesper Wilhelmsson <jesper.wilhelmsson@oracle.com>, Keith McGuigan <keith.mcguigan@oracle.com>, Mattias Tobiasson <mattias.tobiasson@oracle.com>, Markus Gronlund <markus.gronlund@oracle.com>, Mikael Auno <mikael.auno@oracle.com>, Nils Eliasson <nils.eliasson@oracle.com>, Nils Loodin <nils.loodin@oracle.com>, Rickard Backman <rickard.backman@oracle.com>, Staffan Larsen <staffan.larsen@oracle.com>, Stefan Karlsson <stefan.karlsson@oracle.com>, Yekaterina Kantserova <yekaterina.kantserova@oracle.com>
author sla
date Mon, 10 Jun 2013 11:30:51 +0200
parents 960a442eae91
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
10405
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 6093
diff changeset
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1624
diff changeset
25 #ifndef OS_SOLARIS_VM_OSTHREAD_SOLARIS_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1624
diff changeset
26 #define OS_SOLARIS_VM_OSTHREAD_SOLARIS_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1624
diff changeset
27
0
a61af66fc99e Initial load
duke
parents:
diff changeset
28 // This is embedded via include into the class OSThread
6093
960a442eae91 7161732: Improve handling of thread_id in OSThread
rbackman
parents: 6006
diff changeset
29 public:
960a442eae91 7161732: Improve handling of thread_id in OSThread
rbackman
parents: 6006
diff changeset
30 typedef thread_t thread_id_t;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
31
a61af66fc99e Initial load
duke
parents:
diff changeset
32 private:
4854
de268c8a8075 7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents: 1972
diff changeset
33 uint _lwp_id; // lwp ID, only used with bound threads
de268c8a8075 7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents: 1972
diff changeset
34 int _native_priority; // Saved native priority when starting
de268c8a8075 7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents: 1972
diff changeset
35 // a bound thread
de268c8a8075 7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents: 1972
diff changeset
36 sigset_t _caller_sigmask; // Caller's signal mask
de268c8a8075 7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents: 1972
diff changeset
37 bool _vm_created_thread; // true if the VM created this thread,
de268c8a8075 7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents: 1972
diff changeset
38 // false if primary thread or attached thread
0
a61af66fc99e Initial load
duke
parents:
diff changeset
39 public:
4854
de268c8a8075 7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents: 1972
diff changeset
40 uint lwp_id() const { return _lwp_id; }
de268c8a8075 7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents: 1972
diff changeset
41 int native_priority() const { return _native_priority; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // Set and get state of _vm_created_thread flag
a61af66fc99e Initial load
duke
parents:
diff changeset
44 void set_vm_created() { _vm_created_thread = true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
45 bool is_vm_created() { return _vm_created_thread; }
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // Methods to save/restore caller's signal mask
a61af66fc99e Initial load
duke
parents:
diff changeset
48 sigset_t caller_sigmask() const { return _caller_sigmask; }
a61af66fc99e Initial load
duke
parents:
diff changeset
49 void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; }
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // Used for debugging, return a unique integer for each thread.
a61af66fc99e Initial load
duke
parents:
diff changeset
53 int thread_identifier() const { return _thread_id; }
a61af66fc99e Initial load
duke
parents:
diff changeset
54 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
55 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // On solaris reposition can fail in two ways:
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // 1: a mismatched pc, because signal is delivered too late, target thread
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // is resumed.
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // 2: on a timeout where signal is lost, target thread is resumed.
a61af66fc99e Initial load
duke
parents:
diff changeset
60 bool valid_reposition_failure() {
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // only 1 and 2 can happen and we can handle both of them
a61af66fc99e Initial load
duke
parents:
diff changeset
62 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 }
a61af66fc99e Initial load
duke
parents:
diff changeset
64 #endif
4854
de268c8a8075 7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents: 1972
diff changeset
65 void set_lwp_id(uint id) { _lwp_id = id; }
de268c8a8075 7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
phh
parents: 1972
diff changeset
66 void set_native_priority(int prio) { _native_priority = prio; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // ***************************************************************
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // interrupt support. interrupts (using signals) are used to get
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // the thread context (get_thread_pc), to set the thread context
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // (set_thread_pc), and to implement java.lang.Thread.interrupt.
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // ***************************************************************
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 public:
10405
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 6093
diff changeset
75 os::SuspendResume sr;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 private:
10405
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 6093
diff changeset
78 ucontext_t* _ucontext;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 public:
10405
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 6093
diff changeset
81 ucontext_t* ucontext() const { return _ucontext; }
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 6093
diff changeset
82 void set_ucontext(ucontext_t* ptr) { _ucontext = ptr; }
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 6093
diff changeset
83 static void SR_handler(Thread* thread, ucontext_t* uc);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // ***************************************************************
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // java.lang.Thread.interrupt state.
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // ***************************************************************
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 JavaThreadState _saved_interrupt_thread_state; // the thread state before a system call -- restored afterward
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 JavaThreadState saved_interrupt_thread_state() { return _saved_interrupt_thread_state; }
a61af66fc99e Initial load
duke
parents:
diff changeset
97 void set_saved_interrupt_thread_state(JavaThreadState state) { _saved_interrupt_thread_state = state; }
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 static void handle_spinlock_contention(int tries); // Used for thread local eden locking
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // ***************************************************************
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // Platform dependent initialization and cleanup
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // ***************************************************************
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107 void pd_initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
108 void pd_destroy();
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1624
diff changeset
109
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1624
diff changeset
110 #endif // OS_SOLARIS_VM_OSTHREAD_SOLARIS_HPP