Path: blob/master/src/hotspot/os/linux/osThread_linux.hpp
40951 views
/*1* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef OS_LINUX_OSTHREAD_LINUX_HPP25#define OS_LINUX_OSTHREAD_LINUX_HPP26public:27typedef pid_t thread_id_t;2829private:30int _thread_type;3132public:3334int thread_type() const {35return _thread_type;36}37void set_thread_type(int type) {38_thread_type = type;39}4041// _pthread_id is the pthread id, which is used by library calls42// (e.g. pthread_kill).43pthread_t _pthread_id;4445sigset_t _caller_sigmask; // Caller's signal mask4647public:4849// Methods to save/restore caller's signal mask50sigset_t caller_sigmask() const { return _caller_sigmask; }51void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; }5253#ifndef PRODUCT54// Used for debugging, return a unique integer for each thread.55int thread_identifier() const { return _thread_id; }56#endif57#ifdef ASSERT58// We expect no reposition failures so kill vm if we get one.59//60bool valid_reposition_failure() {61return false;62}63#endif // ASSERT64pthread_t pthread_id() const {65return _pthread_id;66}67void set_pthread_id(pthread_t tid) {68_pthread_id = tid;69}7071// ***************************************************************72// suspension support.73// ***************************************************************7475public:76// flags that support signal based suspend/resume on Linux are in a77// separate class to avoid confusion with many flags in OSThread that78// are used by VM level suspend/resume.79os::SuspendResume sr;8081// _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 Java85// frame information as the frame. This will mean that for threads86// 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. This88// not a problem for the profiler since the Java frame is a close89// enough result. For the safepoint mechanism when the give it the90// Java frame we are not at a point where the safepoint needs the91// frame to that accurate (like for a compiled safepoint) since we92// should be in a place where we are native and will block ourselves93// if we transition.94private:95void* _siginfo;96ucontext_t* _ucontext;97int _expanding_stack; /* non zero if manually expanding stack */98address _alt_sig_stack; /* address of base of alternate signal stack */99100public:101void* siginfo() const { return _siginfo; }102void set_siginfo(void* ptr) { _siginfo = ptr; }103ucontext_t* ucontext() const { return _ucontext; }104void set_ucontext(ucontext_t* ptr) { _ucontext = ptr; }105void set_expanding_stack(void) { _expanding_stack = 1; }106void clear_expanding_stack(void) { _expanding_stack = 0; }107int expanding_stack(void) { return _expanding_stack; }108109void set_alt_sig_stack(address val) { _alt_sig_stack = val; }110address alt_sig_stack(void) { return _alt_sig_stack; }111112private:113Monitor* _startThread_lock; // sync parent and child in thread creation114115public:116117Monitor* startThread_lock() const {118return _startThread_lock;119}120121// ***************************************************************122// Platform dependent initialization and cleanup123// ***************************************************************124125private:126127void pd_initialize();128void pd_destroy();129130// Reconciliation History131// osThread_solaris.hpp 1.24 99/08/27 13:11:54132// End133134#endif // OS_LINUX_OSTHREAD_LINUX_HPP135136137