src/os/linux/vm/osThread_linux.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) 1999, 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_LINUX_VM_OSTHREAD_LINUX_HPP
aoqi@0 26 #define OS_LINUX_VM_OSTHREAD_LINUX_HPP
aoqi@0 27 public:
aoqi@0 28 typedef pid_t thread_id_t;
aoqi@0 29
aoqi@0 30 private:
aoqi@0 31 int _thread_type;
aoqi@0 32
aoqi@0 33 public:
aoqi@0 34
aoqi@0 35 int thread_type() const {
aoqi@0 36 return _thread_type;
aoqi@0 37 }
aoqi@0 38 void set_thread_type(int type) {
aoqi@0 39 _thread_type = type;
aoqi@0 40 }
aoqi@0 41
aoqi@0 42 // _pthread_id is the pthread id, which is used by library calls
aoqi@0 43 // (e.g. pthread_kill).
aoqi@0 44 pthread_t _pthread_id;
aoqi@0 45
aoqi@0 46 sigset_t _caller_sigmask; // Caller's signal mask
aoqi@0 47
aoqi@0 48 public:
aoqi@0 49
aoqi@0 50 // Methods to save/restore caller's signal mask
aoqi@0 51 sigset_t caller_sigmask() const { return _caller_sigmask; }
aoqi@0 52 void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; }
aoqi@0 53
aoqi@0 54 #ifndef PRODUCT
aoqi@0 55 // Used for debugging, return a unique integer for each thread.
aoqi@0 56 int thread_identifier() const { return _thread_id; }
aoqi@0 57 #endif
aoqi@0 58 #ifdef ASSERT
aoqi@0 59 // We expect no reposition failures so kill vm if we get one.
aoqi@0 60 //
aoqi@0 61 bool valid_reposition_failure() {
aoqi@0 62 return false;
aoqi@0 63 }
aoqi@0 64 #endif // ASSERT
aoqi@0 65 pthread_t pthread_id() const {
aoqi@0 66 return _pthread_id;
aoqi@0 67 }
aoqi@0 68 void set_pthread_id(pthread_t tid) {
aoqi@0 69 _pthread_id = tid;
aoqi@0 70 }
aoqi@0 71
aoqi@0 72 // ***************************************************************
aoqi@0 73 // suspension support.
aoqi@0 74 // ***************************************************************
aoqi@0 75
aoqi@0 76 public:
aoqi@0 77 // flags that support signal based suspend/resume on Linux are in a
aoqi@0 78 // separate class to avoid confusion with many flags in OSThread that
aoqi@0 79 // are used by VM level suspend/resume.
aoqi@0 80 os::SuspendResume sr;
aoqi@0 81
aoqi@0 82 // _ucontext and _siginfo are used by SR_handler() to save thread context,
aoqi@0 83 // and they will later be used to walk the stack or reposition thread PC.
aoqi@0 84 // If the thread is not suspended in SR_handler() (e.g. self suspend),
aoqi@0 85 // the value in _ucontext is meaningless, so we must use the last Java
aoqi@0 86 // frame information as the frame. This will mean that for threads
aoqi@0 87 // that are parked on a mutex the profiler (and safepoint mechanism)
aoqi@0 88 // will see the thread as if it were still in the Java frame. This
aoqi@0 89 // not a problem for the profiler since the Java frame is a close
aoqi@0 90 // enough result. For the safepoint mechanism when the give it the
aoqi@0 91 // Java frame we are not at a point where the safepoint needs the
aoqi@0 92 // frame to that accurate (like for a compiled safepoint) since we
aoqi@0 93 // should be in a place where we are native and will block ourselves
aoqi@0 94 // if we transition.
aoqi@0 95 private:
aoqi@0 96 void* _siginfo;
aoqi@0 97 ucontext_t* _ucontext;
aoqi@0 98 int _expanding_stack; /* non zero if manually expanding stack */
aoqi@0 99 address _alt_sig_stack; /* address of base of alternate signal stack */
aoqi@0 100
aoqi@0 101 public:
aoqi@0 102 void* siginfo() const { return _siginfo; }
aoqi@0 103 void set_siginfo(void* ptr) { _siginfo = ptr; }
aoqi@0 104 ucontext_t* ucontext() const { return _ucontext; }
aoqi@0 105 void set_ucontext(ucontext_t* ptr) { _ucontext = ptr; }
aoqi@0 106 void set_expanding_stack(void) { _expanding_stack = 1; }
aoqi@0 107 void clear_expanding_stack(void) { _expanding_stack = 0; }
aoqi@0 108 int expanding_stack(void) { return _expanding_stack; }
aoqi@0 109
aoqi@0 110 void set_alt_sig_stack(address val) { _alt_sig_stack = val; }
aoqi@0 111 address alt_sig_stack(void) { return _alt_sig_stack; }
aoqi@0 112
aoqi@0 113 private:
aoqi@0 114 Monitor* _startThread_lock; // sync parent and child in thread creation
aoqi@0 115
aoqi@0 116 public:
aoqi@0 117
aoqi@0 118 Monitor* startThread_lock() const {
aoqi@0 119 return _startThread_lock;
aoqi@0 120 }
aoqi@0 121
aoqi@0 122 // ***************************************************************
aoqi@0 123 // Platform dependent initialization and cleanup
aoqi@0 124 // ***************************************************************
aoqi@0 125
aoqi@0 126 private:
aoqi@0 127
aoqi@0 128 void pd_initialize();
aoqi@0 129 void pd_destroy();
aoqi@0 130
aoqi@0 131 // Reconciliation History
aoqi@0 132 // osThread_solaris.hpp 1.24 99/08/27 13:11:54
aoqi@0 133 // End
aoqi@0 134
aoqi@0 135 #endif // OS_LINUX_VM_OSTHREAD_LINUX_HPP

mercurial