src/os/bsd/vm/osThread_bsd.hpp

changeset 3156
f08d439fab8c
child 3587
0368109684cb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/os/bsd/vm/osThread_bsd.hpp	Sun Sep 25 16:03:29 2011 -0700
     1.3 @@ -0,0 +1,165 @@
     1.4 +/*
     1.5 + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef OS_BSD_VM_OSTHREAD_BSD_HPP
    1.29 +#define OS_BSD_VM_OSTHREAD_BSD_HPP
    1.30 +
    1.31 + private:
    1.32 +  int _thread_type;
    1.33 +
    1.34 + public:
    1.35 +
    1.36 +  int thread_type() const {
    1.37 +    return _thread_type;
    1.38 +  }
    1.39 +  void set_thread_type(int type) {
    1.40 +    _thread_type = type;
    1.41 +  }
    1.42 +
    1.43 + private:
    1.44 +
    1.45 +#ifdef _ALLBSD_SOURCE
    1.46 +  // _thread_id and _pthread_id are the same on BSD
    1.47 +  // keep both to minimize code divergence in os_bsd.cpp
    1.48 +  pthread_t _thread_id;
    1.49 +  pthread_t _pthread_id;
    1.50 +#else
    1.51 +  // _thread_id is kernel thread id (similar to LWP id on Solaris). Each
    1.52 +  // thread has a unique thread_id (BsdThreads or NPTL). It can be used
    1.53 +  // to access /proc.
    1.54 +  pid_t     _thread_id;
    1.55 +
    1.56 +  // _pthread_id is the pthread id, which is used by library calls
    1.57 +  // (e.g. pthread_kill).
    1.58 +  pthread_t _pthread_id;
    1.59 +#endif
    1.60 +
    1.61 +  sigset_t _caller_sigmask; // Caller's signal mask
    1.62 +
    1.63 + public:
    1.64 +
    1.65 +  // Methods to save/restore caller's signal mask
    1.66 +  sigset_t  caller_sigmask() const       { return _caller_sigmask; }
    1.67 +  void    set_caller_sigmask(sigset_t sigmask)  { _caller_sigmask = sigmask; }
    1.68 +
    1.69 +#ifdef _ALLBSD_SOURCE
    1.70 +  pthread_t thread_id() const {
    1.71 +    return _thread_id;
    1.72 +  }
    1.73 +#else
    1.74 +  pid_t thread_id() const {
    1.75 +    return _thread_id;
    1.76 +  }
    1.77 +#endif
    1.78 +#ifndef PRODUCT
    1.79 +  // Used for debugging, return a unique integer for each thread.
    1.80 +  intptr_t thread_identifier() const   { return (intptr_t)_pthread_id; }
    1.81 +#endif
    1.82 +#ifdef ASSERT
    1.83 +  // We expect no reposition failures so kill vm if we get one.
    1.84 +  //
    1.85 +  bool valid_reposition_failure() {
    1.86 +    return false;
    1.87 +  }
    1.88 +#endif // ASSERT
    1.89 +#ifdef _ALLBSD_SOURCE
    1.90 +  void set_thread_id(pthread_t id) {
    1.91 +    _thread_id = id;
    1.92 +  }
    1.93 +#else
    1.94 +  void set_thread_id(pid_t id) {
    1.95 +    _thread_id = id;
    1.96 +  }
    1.97 +#endif
    1.98 +  pthread_t pthread_id() const {
    1.99 +    return _pthread_id;
   1.100 +  }
   1.101 +  void set_pthread_id(pthread_t tid) {
   1.102 +    _pthread_id = tid;
   1.103 +  }
   1.104 +
   1.105 +  // ***************************************************************
   1.106 +  // suspension support.
   1.107 +  // ***************************************************************
   1.108 +
   1.109 +public:
   1.110 +  // flags that support signal based suspend/resume on Bsd are in a
   1.111 +  // separate class to avoid confusion with many flags in OSThread that
   1.112 +  // are used by VM level suspend/resume.
   1.113 +  os::Bsd::SuspendResume sr;
   1.114 +
   1.115 +  // _ucontext and _siginfo are used by SR_handler() to save thread context,
   1.116 +  // and they will later be used to walk the stack or reposition thread PC.
   1.117 +  // If the thread is not suspended in SR_handler() (e.g. self suspend),
   1.118 +  // the value in _ucontext is meaningless, so we must use the last Java
   1.119 +  // frame information as the frame. This will mean that for threads
   1.120 +  // that are parked on a mutex the profiler (and safepoint mechanism)
   1.121 +  // will see the thread as if it were still in the Java frame. This
   1.122 +  // not a problem for the profiler since the Java frame is a close
   1.123 +  // enough result. For the safepoint mechanism when the give it the
   1.124 +  // Java frame we are not at a point where the safepoint needs the
   1.125 +  // frame to that accurate (like for a compiled safepoint) since we
   1.126 +  // should be in a place where we are native and will block ourselves
   1.127 +  // if we transition.
   1.128 +private:
   1.129 +  void* _siginfo;
   1.130 +  ucontext_t* _ucontext;
   1.131 +  int _expanding_stack;                 /* non zero if manually expanding stack */
   1.132 +  address _alt_sig_stack;               /* address of base of alternate signal stack */
   1.133 +
   1.134 +public:
   1.135 +  void* siginfo() const                   { return _siginfo;  }
   1.136 +  void set_siginfo(void* ptr)             { _siginfo = ptr;   }
   1.137 +  ucontext_t* ucontext() const            { return _ucontext; }
   1.138 +  void set_ucontext(ucontext_t* ptr)      { _ucontext = ptr;  }
   1.139 +  void set_expanding_stack(void)          { _expanding_stack = 1;  }
   1.140 +  void clear_expanding_stack(void)        { _expanding_stack = 0;  }
   1.141 +  int  expanding_stack(void)              { return _expanding_stack;  }
   1.142 +
   1.143 +  void set_alt_sig_stack(address val)     { _alt_sig_stack = val; }
   1.144 +  address alt_sig_stack(void)             { return _alt_sig_stack; }
   1.145 +
   1.146 +private:
   1.147 +  Monitor* _startThread_lock;     // sync parent and child in thread creation
   1.148 +
   1.149 +public:
   1.150 +
   1.151 +  Monitor* startThread_lock() const {
   1.152 +    return _startThread_lock;
   1.153 +  }
   1.154 +
   1.155 +  // ***************************************************************
   1.156 +  // Platform dependent initialization and cleanup
   1.157 +  // ***************************************************************
   1.158 +
   1.159 +private:
   1.160 +
   1.161 +  void pd_initialize();
   1.162 +  void pd_destroy();
   1.163 +
   1.164 +// Reconciliation History
   1.165 +// osThread_solaris.hpp 1.24 99/08/27 13:11:54
   1.166 +// End
   1.167 +
   1.168 +#endif // OS_BSD_VM_OSTHREAD_BSD_HPP

mercurial