src/os/linux/vm/osThread_linux.hpp

Fri, 11 Jul 2008 01:14:44 -0700

author
trims
date
Fri, 11 Jul 2008 01:14:44 -0700
changeset 670
9c2ecc2ffb12
parent 435
a61af66fc99e
child 1907
c18cbe5936b8
permissions
-rw-r--r--

Merge

duke@435 1 /*
duke@435 2 * Copyright 1999-2004 Sun Microsystems, Inc. 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 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 private:
duke@435 26 int _thread_type;
duke@435 27
duke@435 28 public:
duke@435 29
duke@435 30 int thread_type() const {
duke@435 31 return _thread_type;
duke@435 32 }
duke@435 33 void set_thread_type(int type) {
duke@435 34 _thread_type = type;
duke@435 35 }
duke@435 36
duke@435 37 private:
duke@435 38
duke@435 39 // _thread_id is kernel thread id (similar to LWP id on Solaris). Each
duke@435 40 // thread has a unique thread_id (LinuxThreads or NPTL). It can be used
duke@435 41 // to access /proc.
duke@435 42 pid_t _thread_id;
duke@435 43
duke@435 44 // _pthread_id is the pthread id, which is used by library calls
duke@435 45 // (e.g. pthread_kill).
duke@435 46 pthread_t _pthread_id;
duke@435 47
duke@435 48 sigset_t _caller_sigmask; // Caller's signal mask
duke@435 49
duke@435 50 public:
duke@435 51
duke@435 52 // Methods to save/restore caller's signal mask
duke@435 53 sigset_t caller_sigmask() const { return _caller_sigmask; }
duke@435 54 void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; }
duke@435 55
duke@435 56 pid_t thread_id() const {
duke@435 57 return _thread_id;
duke@435 58 }
duke@435 59 #ifndef PRODUCT
duke@435 60 // Used for debugging, return a unique integer for each thread.
duke@435 61 int thread_identifier() const { return _thread_id; }
duke@435 62 #endif
duke@435 63 #ifdef ASSERT
duke@435 64 // We expect no reposition failures so kill vm if we get one.
duke@435 65 //
duke@435 66 bool valid_reposition_failure() {
duke@435 67 return false;
duke@435 68 }
duke@435 69 #endif // ASSERT
duke@435 70 void set_thread_id(pid_t id) {
duke@435 71 _thread_id = id;
duke@435 72 }
duke@435 73 pthread_t pthread_id() const {
duke@435 74 return _pthread_id;
duke@435 75 }
duke@435 76 void set_pthread_id(pthread_t tid) {
duke@435 77 _pthread_id = tid;
duke@435 78 }
duke@435 79
duke@435 80 // ***************************************************************
duke@435 81 // suspension support.
duke@435 82 // ***************************************************************
duke@435 83
duke@435 84 public:
duke@435 85 // flags that support signal based suspend/resume on Linux are in a
duke@435 86 // separate class to avoid confusion with many flags in OSThread that
duke@435 87 // are used by VM level suspend/resume.
duke@435 88 os::Linux::SuspendResume sr;
duke@435 89
duke@435 90 // _ucontext and _siginfo are used by SR_handler() to save thread context,
duke@435 91 // and they will later be used to walk the stack or reposition thread PC.
duke@435 92 // If the thread is not suspended in SR_handler() (e.g. self suspend),
duke@435 93 // the value in _ucontext is meaningless, so we must use the last Java
duke@435 94 // frame information as the frame. This will mean that for threads
duke@435 95 // that are parked on a mutex the profiler (and safepoint mechanism)
duke@435 96 // will see the thread as if it were still in the Java frame. This
duke@435 97 // not a problem for the profiler since the Java frame is a close
duke@435 98 // enough result. For the safepoint mechanism when the give it the
duke@435 99 // Java frame we are not at a point where the safepoint needs the
duke@435 100 // frame to that accurate (like for a compiled safepoint) since we
duke@435 101 // should be in a place where we are native and will block ourselves
duke@435 102 // if we transition.
duke@435 103 private:
duke@435 104 void* _siginfo;
duke@435 105 ucontext_t* _ucontext;
duke@435 106 int _expanding_stack; /* non zero if manually expanding stack */
duke@435 107 address _alt_sig_stack; /* address of base of alternate signal stack */
duke@435 108
duke@435 109 public:
duke@435 110 void* siginfo() const { return _siginfo; }
duke@435 111 void set_siginfo(void* ptr) { _siginfo = ptr; }
duke@435 112 ucontext_t* ucontext() const { return _ucontext; }
duke@435 113 void set_ucontext(ucontext_t* ptr) { _ucontext = ptr; }
duke@435 114 void set_expanding_stack(void) { _expanding_stack = 1; }
duke@435 115 void clear_expanding_stack(void) { _expanding_stack = 0; }
duke@435 116 int expanding_stack(void) { return _expanding_stack; }
duke@435 117
duke@435 118 void set_alt_sig_stack(address val) { _alt_sig_stack = val; }
duke@435 119 address alt_sig_stack(void) { return _alt_sig_stack; }
duke@435 120
duke@435 121 private:
duke@435 122 Monitor* _startThread_lock; // sync parent and child in thread creation
duke@435 123
duke@435 124 public:
duke@435 125
duke@435 126 Monitor* startThread_lock() const {
duke@435 127 return _startThread_lock;
duke@435 128 }
duke@435 129
duke@435 130 // ***************************************************************
duke@435 131 // Platform dependent initialization and cleanup
duke@435 132 // ***************************************************************
duke@435 133
duke@435 134 private:
duke@435 135
duke@435 136 void pd_initialize();
duke@435 137 void pd_destroy();
duke@435 138
duke@435 139 // Reconciliation History
duke@435 140 // osThread_solaris.hpp 1.24 99/08/27 13:11:54
duke@435 141 // End

mercurial