aoqi@0: /* aoqi@0: * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: * Copyright 2012, 2013 SAP AG. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@0: #ifndef OS_AIX_VM_OSTHREAD_AIX_HPP aoqi@0: #define OS_AIX_VM_OSTHREAD_AIX_HPP aoqi@0: aoqi@0: public: aoqi@0: typedef pid_t thread_id_t; aoqi@0: aoqi@0: private: aoqi@0: int _thread_type; aoqi@0: aoqi@0: public: aoqi@0: aoqi@0: int thread_type() const { aoqi@0: return _thread_type; aoqi@0: } aoqi@0: void set_thread_type(int type) { aoqi@0: _thread_type = type; aoqi@0: } aoqi@0: aoqi@0: private: aoqi@0: aoqi@0: // _pthread_id is the pthread id, which is used by library calls aoqi@0: // (e.g. pthread_kill). aoqi@0: pthread_t _pthread_id; aoqi@0: aoqi@0: sigset_t _caller_sigmask; // Caller's signal mask aoqi@0: aoqi@0: public: aoqi@0: aoqi@0: // Methods to save/restore caller's signal mask aoqi@0: sigset_t caller_sigmask() const { return _caller_sigmask; } aoqi@0: void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; } aoqi@0: aoqi@0: #ifndef PRODUCT aoqi@0: // Used for debugging, return a unique integer for each thread. aoqi@0: int thread_identifier() const { return _thread_id; } aoqi@0: #endif aoqi@0: #ifdef ASSERT aoqi@0: // We expect no reposition failures so kill vm if we get one. aoqi@0: // aoqi@0: bool valid_reposition_failure() { aoqi@0: return false; aoqi@0: } aoqi@0: #endif // ASSERT aoqi@0: pthread_t pthread_id() const { aoqi@0: return _pthread_id; aoqi@0: } aoqi@0: void set_pthread_id(pthread_t tid) { aoqi@0: _pthread_id = tid; aoqi@0: } aoqi@0: aoqi@0: // *************************************************************** aoqi@0: // suspension support. aoqi@0: // *************************************************************** aoqi@0: aoqi@0: public: aoqi@0: // flags that support signal based suspend/resume on Linux are in a aoqi@0: // separate class to avoid confusion with many flags in OSThread that aoqi@0: // are used by VM level suspend/resume. aoqi@0: os::SuspendResume sr; aoqi@0: aoqi@0: // _ucontext and _siginfo are used by SR_handler() to save thread context, aoqi@0: // and they will later be used to walk the stack or reposition thread PC. aoqi@0: // If the thread is not suspended in SR_handler() (e.g. self suspend), aoqi@0: // the value in _ucontext is meaningless, so we must use the last Java aoqi@0: // frame information as the frame. This will mean that for threads aoqi@0: // that are parked on a mutex the profiler (and safepoint mechanism) aoqi@0: // will see the thread as if it were still in the Java frame. This aoqi@0: // not a problem for the profiler since the Java frame is a close aoqi@0: // enough result. For the safepoint mechanism when the give it the aoqi@0: // Java frame we are not at a point where the safepoint needs the aoqi@0: // frame to that accurate (like for a compiled safepoint) since we aoqi@0: // should be in a place where we are native and will block ourselves aoqi@0: // if we transition. aoqi@0: private: aoqi@0: void* _siginfo; aoqi@0: ucontext_t* _ucontext; aoqi@0: int _expanding_stack; // non zero if manually expanding stack aoqi@0: address _alt_sig_stack; // address of base of alternate signal stack aoqi@0: aoqi@0: public: aoqi@0: void* siginfo() const { return _siginfo; } aoqi@0: void set_siginfo(void* ptr) { _siginfo = ptr; } aoqi@0: ucontext_t* ucontext() const { return _ucontext; } aoqi@0: void set_ucontext(ucontext_t* ptr) { _ucontext = ptr; } aoqi@0: void set_expanding_stack(void) { _expanding_stack = 1; } aoqi@0: void clear_expanding_stack(void) { _expanding_stack = 0; } aoqi@0: int expanding_stack(void) { return _expanding_stack; } aoqi@0: aoqi@0: void set_alt_sig_stack(address val) { _alt_sig_stack = val; } aoqi@0: address alt_sig_stack(void) { return _alt_sig_stack; } aoqi@0: aoqi@0: private: aoqi@0: Monitor* _startThread_lock; // sync parent and child in thread creation aoqi@0: aoqi@0: public: aoqi@0: aoqi@0: Monitor* startThread_lock() const { aoqi@0: return _startThread_lock; aoqi@0: } aoqi@0: aoqi@0: // *************************************************************** aoqi@0: // Platform dependent initialization and cleanup aoqi@0: // *************************************************************** aoqi@0: aoqi@0: private: aoqi@0: aoqi@0: void pd_initialize(); aoqi@0: void pd_destroy(); aoqi@0: aoqi@0: public: aoqi@0: aoqi@0: // The last measured values of cpu timing to prevent the "stale aoqi@0: // value return" bug in thread_cpu_time. aoqi@0: volatile struct { aoqi@0: jlong sys; aoqi@0: jlong user; aoqi@0: } _last_cpu_times; aoqi@0: aoqi@0: #endif // OS_AIX_VM_OSTHREAD_AIX_HPP