aoqi@0: /* aoqi@0: * Copyright (c) 1997, 2013, Oracle and/or its affiliates. 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_SOLARIS_VM_OSTHREAD_SOLARIS_HPP aoqi@0: #define OS_SOLARIS_VM_OSTHREAD_SOLARIS_HPP aoqi@0: aoqi@0: // This is embedded via include into the class OSThread aoqi@0: public: aoqi@0: typedef thread_t thread_id_t; aoqi@0: aoqi@0: private: aoqi@0: uint _lwp_id; // lwp ID, only used with bound threads aoqi@0: int _native_priority; // Saved native priority when starting aoqi@0: // a bound thread aoqi@0: sigset_t _caller_sigmask; // Caller's signal mask aoqi@0: bool _vm_created_thread; // true if the VM created this thread, aoqi@0: // false if primary thread or attached thread aoqi@0: public: aoqi@0: uint lwp_id() const { return _lwp_id; } aoqi@0: int native_priority() const { return _native_priority; } aoqi@0: aoqi@0: // Set and get state of _vm_created_thread flag aoqi@0: void set_vm_created() { _vm_created_thread = true; } aoqi@0: bool is_vm_created() { return _vm_created_thread; } 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: // On solaris reposition can fail in two ways: aoqi@0: // 1: a mismatched pc, because signal is delivered too late, target thread aoqi@0: // is resumed. aoqi@0: // 2: on a timeout where signal is lost, target thread is resumed. aoqi@0: bool valid_reposition_failure() { aoqi@0: // only 1 and 2 can happen and we can handle both of them aoqi@0: return true; aoqi@0: } aoqi@0: #endif aoqi@0: void set_lwp_id(uint id) { _lwp_id = id; } aoqi@0: void set_native_priority(int prio) { _native_priority = prio; } aoqi@0: aoqi@0: // *************************************************************** aoqi@0: // interrupt support. interrupts (using signals) are used to get aoqi@0: // the thread context (get_thread_pc), to set the thread context aoqi@0: // (set_thread_pc), and to implement java.lang.Thread.interrupt. aoqi@0: // *************************************************************** aoqi@0: aoqi@0: public: aoqi@0: os::SuspendResume sr; aoqi@0: aoqi@0: private: aoqi@0: ucontext_t* _ucontext; aoqi@0: aoqi@0: public: aoqi@0: ucontext_t* ucontext() const { return _ucontext; } aoqi@0: void set_ucontext(ucontext_t* ptr) { _ucontext = ptr; } aoqi@0: static void SR_handler(Thread* thread, ucontext_t* uc); aoqi@0: aoqi@0: // *************************************************************** aoqi@0: // java.lang.Thread.interrupt state. aoqi@0: // *************************************************************** aoqi@0: aoqi@0: private: aoqi@0: aoqi@0: JavaThreadState _saved_interrupt_thread_state; // the thread state before a system call -- restored afterward aoqi@0: aoqi@0: public: aoqi@0: aoqi@0: aoqi@0: JavaThreadState saved_interrupt_thread_state() { return _saved_interrupt_thread_state; } aoqi@0: void set_saved_interrupt_thread_state(JavaThreadState state) { _saved_interrupt_thread_state = state; } aoqi@0: aoqi@0: static void handle_spinlock_contention(int tries); // Used for thread local eden locking 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: #endif // OS_SOLARIS_VM_OSTHREAD_SOLARIS_HPP