Path: blob/master/src/hotspot/os/bsd/osThread_bsd.hpp
40949 views
/*1* Copyright (c) 1999, 2020, 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_BSD_OSTHREAD_BSD_HPP25#define OS_BSD_OSTHREAD_BSD_HPP2627private:28int _thread_type;2930public:3132int thread_type() const {33return _thread_type;34}35void set_thread_type(int type) {36_thread_type = type;37}3839private:4041#ifdef __APPLE__42typedef thread_t thread_id_t;43#else44typedef pid_t thread_id_t;45#endif4647// _pthread_id is the pthread id, which is used by library calls48// (e.g. pthread_kill).49pthread_t _pthread_id;5051// This is the "thread_id" from struct thread_identifier_info. According to a52// comment in thread_info.h, this is a "system-wide unique 64-bit thread id".53// The value is used by SA to correlate threads.54uint64_t _unique_thread_id;5556sigset_t _caller_sigmask; // Caller's signal mask5758public:5960// Methods to save/restore caller's signal mask61sigset_t caller_sigmask() const { return _caller_sigmask; }62void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; }6364#ifndef PRODUCT65// Used for debugging, return a unique integer for each thread.66intptr_t thread_identifier() const { return (intptr_t)_pthread_id; }67#endif6869#ifdef ASSERT70// We expect no reposition failures so kill vm if we get one.71//72bool valid_reposition_failure() {73return false;74}75#endif // ASSERT7677pthread_t pthread_id() const {78return _pthread_id;79}80void set_pthread_id(pthread_t tid) {81_pthread_id = tid;82}8384void set_unique_thread_id();8586// ***************************************************************87// suspension support.88// ***************************************************************8990public:91// flags that support signal based suspend/resume on Bsd are in a92// separate class to avoid confusion with many flags in OSThread that93// are used by VM level suspend/resume.94os::SuspendResume sr;9596// _ucontext and _siginfo are used by SR_handler() to save thread context,97// and they will later be used to walk the stack or reposition thread PC.98// If the thread is not suspended in SR_handler() (e.g. self suspend),99// the value in _ucontext is meaningless, so we must use the last Java100// frame information as the frame. This will mean that for threads101// that are parked on a mutex the profiler (and safepoint mechanism)102// will see the thread as if it were still in the Java frame. This103// not a problem for the profiler since the Java frame is a close104// enough result. For the safepoint mechanism when the give it the105// Java frame we are not at a point where the safepoint needs the106// frame to that accurate (like for a compiled safepoint) since we107// should be in a place where we are native and will block ourselves108// if we transition.109private:110void* _siginfo;111ucontext_t* _ucontext;112int _expanding_stack; /* non zero if manually expanding stack */113address _alt_sig_stack; /* address of base of alternate signal stack */114115public:116void* siginfo() const { return _siginfo; }117void set_siginfo(void* ptr) { _siginfo = ptr; }118ucontext_t* ucontext() const { return _ucontext; }119void set_ucontext(ucontext_t* ptr) { _ucontext = ptr; }120void set_expanding_stack(void) { _expanding_stack = 1; }121void clear_expanding_stack(void) { _expanding_stack = 0; }122int expanding_stack(void) { return _expanding_stack; }123124void set_alt_sig_stack(address val) { _alt_sig_stack = val; }125address alt_sig_stack(void) { return _alt_sig_stack; }126127private:128Monitor* _startThread_lock; // sync parent and child in thread creation129130public:131132Monitor* startThread_lock() const {133return _startThread_lock;134}135136// ***************************************************************137// Platform dependent initialization and cleanup138// ***************************************************************139140private:141142void pd_initialize();143void pd_destroy();144145// Reconciliation History146// osThread_solaris.hpp 1.24 99/08/27 13:11:54147// End148149#endif // OS_BSD_OSTHREAD_BSD_HPP150151152