Path: blob/master/src/hotspot/os/aix/osThread_aix.hpp
40930 views
/*1* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2012, 2013 SAP SE. 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 it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 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 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425#ifndef OS_AIX_OSTHREAD_AIX_HPP26#define OS_AIX_OSTHREAD_AIX_HPP2728public:29typedef pthread_t thread_id_t;3031private:32int _thread_type;3334public:3536int thread_type() const {37return _thread_type;38}39void set_thread_type(int type) {40_thread_type = type;41}4243private:4445// On AIX, we use the pthread id as OSThread::thread_id and keep the kernel thread id46// separately for diagnostic purposes.47//48// Note: this kernel thread id is saved at thread start. Depending on the49// AIX scheduling mode, this may not be the current thread id (usually not50// a problem though as we run with AIXTHREAD_SCOPE=S).51tid_t _kernel_thread_id;5253sigset_t _caller_sigmask; // Caller's signal mask5455public:5657// Methods to save/restore caller's signal mask58sigset_t caller_sigmask() const { return _caller_sigmask; }59void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; }6061#ifndef PRODUCT62// Used for debugging, return a unique integer for each thread.63int thread_identifier() const { return _thread_id; }64#endif65#ifdef ASSERT66// We expect no reposition failures so kill vm if we get one.67//68bool valid_reposition_failure() {69return false;70}71#endif // ASSERT72tid_t kernel_thread_id() const {73return _kernel_thread_id;74}75void set_kernel_thread_id(tid_t tid) {76_kernel_thread_id = tid;77}7879pthread_t pthread_id() const {80// Here: same as OSThread::thread_id()81return _thread_id;82}8384// ***************************************************************85// suspension support.86// ***************************************************************8788public:89// flags that support signal based suspend/resume on Aix are in a90// separate class to avoid confusion with many flags in OSThread that91// are used by VM level suspend/resume.92os::SuspendResume sr;9394// _ucontext and _siginfo are used by SR_handler() to save thread context,95// and they will later be used to walk the stack or reposition thread PC.96// If the thread is not suspended in SR_handler() (e.g. self suspend),97// the value in _ucontext is meaningless, so we must use the last Java98// frame information as the frame. This will mean that for threads99// that are parked on a mutex the profiler (and safepoint mechanism)100// will see the thread as if it were still in the Java frame. This101// not a problem for the profiler since the Java frame is a close102// enough result. For the safepoint mechanism when the give it the103// Java frame we are not at a point where the safepoint needs the104// frame to that accurate (like for a compiled safepoint) since we105// should be in a place where we are native and will block ourselves106// if we transition.107private:108void* _siginfo;109ucontext_t* _ucontext;110int _expanding_stack; // non zero if manually expanding stack111address _alt_sig_stack; // address of base of alternate signal stack112113public:114void* siginfo() const { return _siginfo; }115void set_siginfo(void* ptr) { _siginfo = ptr; }116ucontext_t* ucontext() const { return _ucontext; }117void set_ucontext(ucontext_t* ptr) { _ucontext = ptr; }118void set_expanding_stack(void) { _expanding_stack = 1; }119void clear_expanding_stack(void) { _expanding_stack = 0; }120int expanding_stack(void) { return _expanding_stack; }121122void set_alt_sig_stack(address val) { _alt_sig_stack = val; }123address alt_sig_stack(void) { return _alt_sig_stack; }124125private:126Monitor* _startThread_lock; // sync parent and child in thread creation127128public:129130Monitor* startThread_lock() const {131return _startThread_lock;132}133134// ***************************************************************135// Platform dependent initialization and cleanup136// ***************************************************************137138private:139140void pd_initialize();141void pd_destroy();142143public:144145// The last measured values of cpu timing to prevent the "stale146// value return" bug in thread_cpu_time.147volatile struct {148jlong sys;149jlong user;150} _last_cpu_times;151152#endif // OS_AIX_OSTHREAD_AIX_HPP153154155