duke@435: /* sla@5237: * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #ifndef OS_SOLARIS_VM_OSTHREAD_SOLARIS_HPP stefank@2314: #define OS_SOLARIS_VM_OSTHREAD_SOLARIS_HPP stefank@2314: duke@435: // This is embedded via include into the class OSThread rbackman@3796: public: rbackman@3796: typedef thread_t thread_id_t; duke@435: duke@435: private: phh@3481: uint _lwp_id; // lwp ID, only used with bound threads phh@3481: int _native_priority; // Saved native priority when starting phh@3481: // a bound thread phh@3481: sigset_t _caller_sigmask; // Caller's signal mask phh@3481: bool _vm_created_thread; // true if the VM created this thread, phh@3481: // false if primary thread or attached thread duke@435: public: phh@3481: uint lwp_id() const { return _lwp_id; } phh@3481: int native_priority() const { return _native_priority; } duke@435: duke@435: // Set and get state of _vm_created_thread flag duke@435: void set_vm_created() { _vm_created_thread = true; } duke@435: bool is_vm_created() { return _vm_created_thread; } duke@435: duke@435: // Methods to save/restore caller's signal mask duke@435: sigset_t caller_sigmask() const { return _caller_sigmask; } duke@435: void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; } duke@435: duke@435: #ifndef PRODUCT duke@435: // Used for debugging, return a unique integer for each thread. duke@435: int thread_identifier() const { return _thread_id; } duke@435: #endif duke@435: #ifdef ASSERT duke@435: // On solaris reposition can fail in two ways: duke@435: // 1: a mismatched pc, because signal is delivered too late, target thread duke@435: // is resumed. duke@435: // 2: on a timeout where signal is lost, target thread is resumed. duke@435: bool valid_reposition_failure() { duke@435: // only 1 and 2 can happen and we can handle both of them duke@435: return true; duke@435: } duke@435: #endif phh@3481: void set_lwp_id(uint id) { _lwp_id = id; } phh@3481: void set_native_priority(int prio) { _native_priority = prio; } duke@435: duke@435: // *************************************************************** duke@435: // interrupt support. interrupts (using signals) are used to get duke@435: // the thread context (get_thread_pc), to set the thread context duke@435: // (set_thread_pc), and to implement java.lang.Thread.interrupt. duke@435: // *************************************************************** duke@435: duke@435: public: sla@5237: os::SuspendResume sr; duke@435: duke@435: private: sla@5237: ucontext_t* _ucontext; duke@435: duke@435: public: sla@5237: ucontext_t* ucontext() const { return _ucontext; } sla@5237: void set_ucontext(ucontext_t* ptr) { _ucontext = ptr; } sla@5237: static void SR_handler(Thread* thread, ucontext_t* uc); duke@435: duke@435: // *************************************************************** duke@435: // java.lang.Thread.interrupt state. duke@435: // *************************************************************** duke@435: duke@435: private: duke@435: duke@435: JavaThreadState _saved_interrupt_thread_state; // the thread state before a system call -- restored afterward duke@435: duke@435: public: duke@435: duke@435: duke@435: JavaThreadState saved_interrupt_thread_state() { return _saved_interrupt_thread_state; } duke@435: void set_saved_interrupt_thread_state(JavaThreadState state) { _saved_interrupt_thread_state = state; } duke@435: duke@435: static void handle_spinlock_contention(int tries); // Used for thread local eden locking duke@435: duke@435: // *************************************************************** duke@435: // Platform dependent initialization and cleanup duke@435: // *************************************************************** duke@435: duke@435: private: duke@435: duke@435: void pd_initialize(); duke@435: void pd_destroy(); stefank@2314: stefank@2314: #endif // OS_SOLARIS_VM_OSTHREAD_SOLARIS_HPP