src/os/linux/vm/osThread_linux.hpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/os/linux/vm/osThread_linux.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,135 @@
     1.4 +/*
     1.5 + * Copyright (c) 1999, 2013, 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_LINUX_VM_OSTHREAD_LINUX_HPP
    1.29 +#define OS_LINUX_VM_OSTHREAD_LINUX_HPP
    1.30 + public:
    1.31 +  typedef pid_t thread_id_t;
    1.32 +
    1.33 + private:
    1.34 +  int _thread_type;
    1.35 +
    1.36 + public:
    1.37 +
    1.38 +  int thread_type() const {
    1.39 +    return _thread_type;
    1.40 +  }
    1.41 +  void set_thread_type(int type) {
    1.42 +    _thread_type = type;
    1.43 +  }
    1.44 +
    1.45 +  // _pthread_id is the pthread id, which is used by library calls
    1.46 +  // (e.g. pthread_kill).
    1.47 +  pthread_t _pthread_id;
    1.48 +
    1.49 +  sigset_t _caller_sigmask; // Caller's signal mask
    1.50 +
    1.51 + public:
    1.52 +
    1.53 +  // Methods to save/restore caller's signal mask
    1.54 +  sigset_t  caller_sigmask() const       { return _caller_sigmask; }
    1.55 +  void    set_caller_sigmask(sigset_t sigmask)  { _caller_sigmask = sigmask; }
    1.56 +
    1.57 +#ifndef PRODUCT
    1.58 +  // Used for debugging, return a unique integer for each thread.
    1.59 +  int thread_identifier() const   { return _thread_id; }
    1.60 +#endif
    1.61 +#ifdef ASSERT
    1.62 +  // We expect no reposition failures so kill vm if we get one.
    1.63 +  //
    1.64 +  bool valid_reposition_failure() {
    1.65 +    return false;
    1.66 +  }
    1.67 +#endif // ASSERT
    1.68 +  pthread_t pthread_id() const {
    1.69 +    return _pthread_id;
    1.70 +  }
    1.71 +  void set_pthread_id(pthread_t tid) {
    1.72 +    _pthread_id = tid;
    1.73 +  }
    1.74 +
    1.75 +  // ***************************************************************
    1.76 +  // suspension support.
    1.77 +  // ***************************************************************
    1.78 +
    1.79 +public:
    1.80 +  // flags that support signal based suspend/resume on Linux are in a
    1.81 +  // separate class to avoid confusion with many flags in OSThread that
    1.82 +  // are used by VM level suspend/resume.
    1.83 +  os::SuspendResume sr;
    1.84 +
    1.85 +  // _ucontext and _siginfo are used by SR_handler() to save thread context,
    1.86 +  // and they will later be used to walk the stack or reposition thread PC.
    1.87 +  // If the thread is not suspended in SR_handler() (e.g. self suspend),
    1.88 +  // the value in _ucontext is meaningless, so we must use the last Java
    1.89 +  // frame information as the frame. This will mean that for threads
    1.90 +  // that are parked on a mutex the profiler (and safepoint mechanism)
    1.91 +  // will see the thread as if it were still in the Java frame. This
    1.92 +  // not a problem for the profiler since the Java frame is a close
    1.93 +  // enough result. For the safepoint mechanism when the give it the
    1.94 +  // Java frame we are not at a point where the safepoint needs the
    1.95 +  // frame to that accurate (like for a compiled safepoint) since we
    1.96 +  // should be in a place where we are native and will block ourselves
    1.97 +  // if we transition.
    1.98 +private:
    1.99 +  void* _siginfo;
   1.100 +  ucontext_t* _ucontext;
   1.101 +  int _expanding_stack;                 /* non zero if manually expanding stack */
   1.102 +  address _alt_sig_stack;               /* address of base of alternate signal stack */
   1.103 +
   1.104 +public:
   1.105 +  void* siginfo() const                   { return _siginfo;  }
   1.106 +  void set_siginfo(void* ptr)             { _siginfo = ptr;   }
   1.107 +  ucontext_t* ucontext() const            { return _ucontext; }
   1.108 +  void set_ucontext(ucontext_t* ptr)      { _ucontext = ptr;  }
   1.109 +  void set_expanding_stack(void)          { _expanding_stack = 1;  }
   1.110 +  void clear_expanding_stack(void)        { _expanding_stack = 0;  }
   1.111 +  int  expanding_stack(void)              { return _expanding_stack;  }
   1.112 +
   1.113 +  void set_alt_sig_stack(address val)     { _alt_sig_stack = val; }
   1.114 +  address alt_sig_stack(void)             { return _alt_sig_stack; }
   1.115 +
   1.116 +private:
   1.117 +  Monitor* _startThread_lock;     // sync parent and child in thread creation
   1.118 +
   1.119 +public:
   1.120 +
   1.121 +  Monitor* startThread_lock() const {
   1.122 +    return _startThread_lock;
   1.123 +  }
   1.124 +
   1.125 +  // ***************************************************************
   1.126 +  // Platform dependent initialization and cleanup
   1.127 +  // ***************************************************************
   1.128 +
   1.129 +private:
   1.130 +
   1.131 +  void pd_initialize();
   1.132 +  void pd_destroy();
   1.133 +
   1.134 +// Reconciliation History
   1.135 +// osThread_solaris.hpp 1.24 99/08/27 13:11:54
   1.136 +// End
   1.137 +
   1.138 +#endif // OS_LINUX_VM_OSTHREAD_LINUX_HPP

mercurial