src/os/linux/vm/osThread_linux.hpp

Wed, 16 Feb 2011 13:30:31 -0800

author
ohair
date
Wed, 16 Feb 2011 13:30:31 -0800
changeset 2527
cdef89d821bd
parent 2314
f95d63e2154a
child 3709
0105f367a14c
permissions
-rw-r--r--

7013964: openjdk LICENSE file needs rebranding
Reviewed-by: darcy, katleman, jjg

duke@435 1 /*
stefank@2314 2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef OS_LINUX_VM_OSTHREAD_LINUX_HPP
stefank@2314 26 #define OS_LINUX_VM_OSTHREAD_LINUX_HPP
stefank@2314 27
duke@435 28 private:
duke@435 29 int _thread_type;
duke@435 30
duke@435 31 public:
duke@435 32
duke@435 33 int thread_type() const {
duke@435 34 return _thread_type;
duke@435 35 }
duke@435 36 void set_thread_type(int type) {
duke@435 37 _thread_type = type;
duke@435 38 }
duke@435 39
duke@435 40 private:
duke@435 41
duke@435 42 // _thread_id is kernel thread id (similar to LWP id on Solaris). Each
duke@435 43 // thread has a unique thread_id (LinuxThreads or NPTL). It can be used
duke@435 44 // to access /proc.
duke@435 45 pid_t _thread_id;
duke@435 46
duke@435 47 // _pthread_id is the pthread id, which is used by library calls
duke@435 48 // (e.g. pthread_kill).
duke@435 49 pthread_t _pthread_id;
duke@435 50
duke@435 51 sigset_t _caller_sigmask; // Caller's signal mask
duke@435 52
duke@435 53 public:
duke@435 54
duke@435 55 // Methods to save/restore caller's signal mask
duke@435 56 sigset_t caller_sigmask() const { return _caller_sigmask; }
duke@435 57 void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; }
duke@435 58
duke@435 59 pid_t thread_id() const {
duke@435 60 return _thread_id;
duke@435 61 }
duke@435 62 #ifndef PRODUCT
duke@435 63 // Used for debugging, return a unique integer for each thread.
duke@435 64 int thread_identifier() const { return _thread_id; }
duke@435 65 #endif
duke@435 66 #ifdef ASSERT
duke@435 67 // We expect no reposition failures so kill vm if we get one.
duke@435 68 //
duke@435 69 bool valid_reposition_failure() {
duke@435 70 return false;
duke@435 71 }
duke@435 72 #endif // ASSERT
duke@435 73 void set_thread_id(pid_t id) {
duke@435 74 _thread_id = id;
duke@435 75 }
duke@435 76 pthread_t pthread_id() const {
duke@435 77 return _pthread_id;
duke@435 78 }
duke@435 79 void set_pthread_id(pthread_t tid) {
duke@435 80 _pthread_id = tid;
duke@435 81 }
duke@435 82
duke@435 83 // ***************************************************************
duke@435 84 // suspension support.
duke@435 85 // ***************************************************************
duke@435 86
duke@435 87 public:
duke@435 88 // flags that support signal based suspend/resume on Linux are in a
duke@435 89 // separate class to avoid confusion with many flags in OSThread that
duke@435 90 // are used by VM level suspend/resume.
duke@435 91 os::Linux::SuspendResume sr;
duke@435 92
duke@435 93 // _ucontext and _siginfo are used by SR_handler() to save thread context,
duke@435 94 // and they will later be used to walk the stack or reposition thread PC.
duke@435 95 // If the thread is not suspended in SR_handler() (e.g. self suspend),
duke@435 96 // the value in _ucontext is meaningless, so we must use the last Java
duke@435 97 // frame information as the frame. This will mean that for threads
duke@435 98 // that are parked on a mutex the profiler (and safepoint mechanism)
duke@435 99 // will see the thread as if it were still in the Java frame. This
duke@435 100 // not a problem for the profiler since the Java frame is a close
duke@435 101 // enough result. For the safepoint mechanism when the give it the
duke@435 102 // Java frame we are not at a point where the safepoint needs the
duke@435 103 // frame to that accurate (like for a compiled safepoint) since we
duke@435 104 // should be in a place where we are native and will block ourselves
duke@435 105 // if we transition.
duke@435 106 private:
duke@435 107 void* _siginfo;
duke@435 108 ucontext_t* _ucontext;
duke@435 109 int _expanding_stack; /* non zero if manually expanding stack */
duke@435 110 address _alt_sig_stack; /* address of base of alternate signal stack */
duke@435 111
duke@435 112 public:
duke@435 113 void* siginfo() const { return _siginfo; }
duke@435 114 void set_siginfo(void* ptr) { _siginfo = ptr; }
duke@435 115 ucontext_t* ucontext() const { return _ucontext; }
duke@435 116 void set_ucontext(ucontext_t* ptr) { _ucontext = ptr; }
duke@435 117 void set_expanding_stack(void) { _expanding_stack = 1; }
duke@435 118 void clear_expanding_stack(void) { _expanding_stack = 0; }
duke@435 119 int expanding_stack(void) { return _expanding_stack; }
duke@435 120
duke@435 121 void set_alt_sig_stack(address val) { _alt_sig_stack = val; }
duke@435 122 address alt_sig_stack(void) { return _alt_sig_stack; }
duke@435 123
duke@435 124 private:
duke@435 125 Monitor* _startThread_lock; // sync parent and child in thread creation
duke@435 126
duke@435 127 public:
duke@435 128
duke@435 129 Monitor* startThread_lock() const {
duke@435 130 return _startThread_lock;
duke@435 131 }
duke@435 132
duke@435 133 // ***************************************************************
duke@435 134 // Platform dependent initialization and cleanup
duke@435 135 // ***************************************************************
duke@435 136
duke@435 137 private:
duke@435 138
duke@435 139 void pd_initialize();
duke@435 140 void pd_destroy();
duke@435 141
duke@435 142 // Reconciliation History
duke@435 143 // osThread_solaris.hpp 1.24 99/08/27 13:11:54
duke@435 144 // End
stefank@2314 145
stefank@2314 146 #endif // OS_LINUX_VM_OSTHREAD_LINUX_HPP

mercurial