osThread_solaris.hpp revision 6134:9ba2269eafd4
11897Swollman/*
21897Swollman * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
31897Swollman * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
41897Swollman *
51897Swollman * This code is free software; you can redistribute it and/or modify it
61897Swollman * under the terms of the GNU General Public License version 2 only, as
71897Swollman * published by the Free Software Foundation.
8100441Scharnier *
91897Swollman * This code is distributed in the hope that it will be useful, but WITHOUT
101897Swollman * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
111897Swollman * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12100441Scharnier * version 2 for more details (a copy is included in the LICENSE file that
131897Swollman * accompanied this code).
141897Swollman *
151897Swollman * You should have received a copy of the GNU General Public License version
16100441Scharnier * 2 along with this work; if not, write to the Free Software Foundation,
171897Swollman * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
181897Swollman *
191897Swollman * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20100441Scharnier * or visit www.oracle.com if you need additional information or have any
211897Swollman * questions.
221897Swollman *
231897Swollman */
24100441Scharnier
251897Swollman#ifndef OS_SOLARIS_VM_OSTHREAD_SOLARIS_HPP
261897Swollman#define OS_SOLARIS_VM_OSTHREAD_SOLARIS_HPP
271897Swollman
281897Swollman// This is embedded via include into the class OSThread
2912798Swpaul public:
30100441Scharnier  typedef thread_t thread_id_t;
311897Swollman
32146833Sstefanf private:
3312798Swpaul  uint     _lwp_id;            // lwp ID, only used with bound threads
341897Swollman  int      _native_priority;   // Saved native priority when starting
3527935Scharnier                               // a bound thread
361897Swollman  sigset_t _caller_sigmask;    // Caller's signal mask
37100441Scharnier  bool     _vm_created_thread; // true if the VM created this thread,
38100441Scharnier                               // false if primary thread or attached thread
39100441Scharnier public:
401897Swollman  uint     lwp_id() const          { return _lwp_id; }
418874Srgrimes  int      native_priority() const { return _native_priority; }
428874Srgrimes
431897Swollman  // Set and get state of _vm_created_thread flag
4427935Scharnier  void set_vm_created()           { _vm_created_thread = true; }
451897Swollman  bool is_vm_created()            { return _vm_created_thread; }
4612798Swpaul
4712798Swpaul  // Methods to save/restore caller's signal mask
48149682Sstefanf  sigset_t  caller_sigmask() const       { return _caller_sigmask; }
491897Swollman  void    set_caller_sigmask(sigset_t sigmask)  { _caller_sigmask = sigmask; }
501897Swollman
5192921Simp#ifndef PRODUCT
5292921Simp  // Used for debugging, return a unique integer for each thread.
5392921Simp  int thread_identifier() const   { return _thread_id; }
5492921Simp#endif
5592921Simp#ifdef ASSERT
5692921Simp  // On solaris reposition can fail in two ways:
5792921Simp  // 1: a mismatched pc, because signal is delivered too late, target thread
5892921Simp  //    is resumed.
5992921Simp  // 2: on a timeout where signal is lost, target thread is resumed.
6092921Simp  bool valid_reposition_failure() {
611897Swollman    // only 1 and 2 can happen and we can handle both of them
621897Swollman    return true;
638874Srgrimes  }
641897Swollman#endif
651897Swollman  void set_lwp_id(uint id)           { _lwp_id = id; }
66152398Sdwmalone  void set_native_priority(int prio) { _native_priority = prio; }
671897Swollman
6812798Swpaul // ***************************************************************
691897Swollman // interrupt support.  interrupts (using signals) are used to get
701897Swollman // the thread context (get_thread_pc), to set the thread context
7112798Swpaul // (set_thread_pc), and to implement java.lang.Thread.interrupt.
7212798Swpaul // ***************************************************************
7312798Swpaul
7412798Swpaul public:
7512798Swpaul  os::SuspendResume sr;
7612798Swpaul
7712798Swpaul private:
7812798Swpaul  ucontext_t* _ucontext;
7912798Swpaul
8012798Swpaul public:
8112798Swpaul  ucontext_t* ucontext() const { return _ucontext; }
8212798Swpaul  void set_ucontext(ucontext_t* ptr) { _ucontext = ptr; }
8312798Swpaul  static void SR_handler(Thread* thread, ucontext_t* uc);
84298089Spfg
851897Swollman  static void       handle_spinlock_contention(int tries);                      // Used for thread local eden locking
861897Swollman
871897Swollman  // ***************************************************************
881897Swollman  // Platform dependent initialization and cleanup
891897Swollman  // ***************************************************************
901897Swollman
911897Swollmanprivate:
921897Swollman
931897Swollman  void pd_initialize();
941897Swollman  void pd_destroy();
951897Swollman
961897Swollman#endif // OS_SOLARIS_VM_OSTHREAD_SOLARIS_HPP
971897Swollman