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