src/os/solaris/vm/osThread_solaris.hpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef OS_SOLARIS_VM_OSTHREAD_SOLARIS_HPP
aoqi@0 26 #define OS_SOLARIS_VM_OSTHREAD_SOLARIS_HPP
aoqi@0 27
aoqi@0 28 // This is embedded via include into the class OSThread
aoqi@0 29 public:
aoqi@0 30 typedef thread_t thread_id_t;
aoqi@0 31
aoqi@0 32 private:
aoqi@0 33 uint _lwp_id; // lwp ID, only used with bound threads
aoqi@0 34 int _native_priority; // Saved native priority when starting
aoqi@0 35 // a bound thread
aoqi@0 36 sigset_t _caller_sigmask; // Caller's signal mask
aoqi@0 37 bool _vm_created_thread; // true if the VM created this thread,
aoqi@0 38 // false if primary thread or attached thread
aoqi@0 39 public:
aoqi@0 40 uint lwp_id() const { return _lwp_id; }
aoqi@0 41 int native_priority() const { return _native_priority; }
aoqi@0 42
aoqi@0 43 // Set and get state of _vm_created_thread flag
aoqi@0 44 void set_vm_created() { _vm_created_thread = true; }
aoqi@0 45 bool is_vm_created() { return _vm_created_thread; }
aoqi@0 46
aoqi@0 47 // Methods to save/restore caller's signal mask
aoqi@0 48 sigset_t caller_sigmask() const { return _caller_sigmask; }
aoqi@0 49 void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; }
aoqi@0 50
aoqi@0 51 #ifndef PRODUCT
aoqi@0 52 // Used for debugging, return a unique integer for each thread.
aoqi@0 53 int thread_identifier() const { return _thread_id; }
aoqi@0 54 #endif
aoqi@0 55 #ifdef ASSERT
aoqi@0 56 // On solaris reposition can fail in two ways:
aoqi@0 57 // 1: a mismatched pc, because signal is delivered too late, target thread
aoqi@0 58 // is resumed.
aoqi@0 59 // 2: on a timeout where signal is lost, target thread is resumed.
aoqi@0 60 bool valid_reposition_failure() {
aoqi@0 61 // only 1 and 2 can happen and we can handle both of them
aoqi@0 62 return true;
aoqi@0 63 }
aoqi@0 64 #endif
aoqi@0 65 void set_lwp_id(uint id) { _lwp_id = id; }
aoqi@0 66 void set_native_priority(int prio) { _native_priority = prio; }
aoqi@0 67
aoqi@0 68 // ***************************************************************
aoqi@0 69 // interrupt support. interrupts (using signals) are used to get
aoqi@0 70 // the thread context (get_thread_pc), to set the thread context
aoqi@0 71 // (set_thread_pc), and to implement java.lang.Thread.interrupt.
aoqi@0 72 // ***************************************************************
aoqi@0 73
aoqi@0 74 public:
aoqi@0 75 os::SuspendResume sr;
aoqi@0 76
aoqi@0 77 private:
aoqi@0 78 ucontext_t* _ucontext;
aoqi@0 79
aoqi@0 80 public:
aoqi@0 81 ucontext_t* ucontext() const { return _ucontext; }
aoqi@0 82 void set_ucontext(ucontext_t* ptr) { _ucontext = ptr; }
aoqi@0 83 static void SR_handler(Thread* thread, ucontext_t* uc);
aoqi@0 84
aoqi@0 85 // ***************************************************************
aoqi@0 86 // java.lang.Thread.interrupt state.
aoqi@0 87 // ***************************************************************
aoqi@0 88
aoqi@0 89 private:
aoqi@0 90
aoqi@0 91 JavaThreadState _saved_interrupt_thread_state; // the thread state before a system call -- restored afterward
aoqi@0 92
aoqi@0 93 public:
aoqi@0 94
aoqi@0 95
aoqi@0 96 JavaThreadState saved_interrupt_thread_state() { return _saved_interrupt_thread_state; }
aoqi@0 97 void set_saved_interrupt_thread_state(JavaThreadState state) { _saved_interrupt_thread_state = state; }
aoqi@0 98
aoqi@0 99 static void handle_spinlock_contention(int tries); // Used for thread local eden locking
aoqi@0 100
aoqi@0 101 // ***************************************************************
aoqi@0 102 // Platform dependent initialization and cleanup
aoqi@0 103 // ***************************************************************
aoqi@0 104
aoqi@0 105 private:
aoqi@0 106
aoqi@0 107 void pd_initialize();
aoqi@0 108 void pd_destroy();
aoqi@0 109
aoqi@0 110 #endif // OS_SOLARIS_VM_OSTHREAD_SOLARIS_HPP

mercurial