hotspot/src/os/linux/vm/osThread_linux.hpp
author iveresov
Thu, 25 Aug 2011 02:57:46 -0700
changeset 10494 3f347ed8bd3c
parent 7397 5b173b4ca846
child 12377 ae6def2813e0
permissions -rw-r--r--
7082969: NUMA interleaving Summary: Support interleaving on NUMA systems for collectors that don't have NUMA-awareness. Reviewed-by: iveresov, ysr Contributed-by: Tom Deneau <tom.deneau@amd.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
     2
 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef OS_LINUX_VM_OSTHREAD_LINUX_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define OS_LINUX_VM_OSTHREAD_LINUX_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
  int _thread_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
  int thread_type() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
    return _thread_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  void set_thread_type(int type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
    _thread_type = type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  // _thread_id is kernel thread id (similar to LWP id on Solaris). Each
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  // thread has a unique thread_id (LinuxThreads or NPTL). It can be used
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  // to access /proc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  pid_t     _thread_id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  // _pthread_id is the pthread id, which is used by library calls
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  // (e.g. pthread_kill).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  pthread_t _pthread_id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  sigset_t _caller_sigmask; // Caller's signal mask
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  // Methods to save/restore caller's signal mask
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  sigset_t  caller_sigmask() const       { return _caller_sigmask; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  void    set_caller_sigmask(sigset_t sigmask)  { _caller_sigmask = sigmask; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  pid_t thread_id() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    return _thread_id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  // Used for debugging, return a unique integer for each thread.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  int thread_identifier() const   { return _thread_id; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  // We expect no reposition failures so kill vm if we get one.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  bool valid_reposition_failure() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
#endif // ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  void set_thread_id(pid_t id) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
    _thread_id = id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  pthread_t pthread_id() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
    return _pthread_id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  void set_pthread_id(pthread_t tid) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    _pthread_id = tid;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  // ***************************************************************
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  // suspension support.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  // ***************************************************************
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  // flags that support signal based suspend/resume on Linux are in a
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  // separate class to avoid confusion with many flags in OSThread that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  // are used by VM level suspend/resume.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  os::Linux::SuspendResume sr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  // _ucontext and _siginfo are used by SR_handler() to save thread context,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  // and they will later be used to walk the stack or reposition thread PC.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  // If the thread is not suspended in SR_handler() (e.g. self suspend),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  // the value in _ucontext is meaningless, so we must use the last Java
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  // frame information as the frame. This will mean that for threads
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  // that are parked on a mutex the profiler (and safepoint mechanism)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  // will see the thread as if it were still in the Java frame. This
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  // not a problem for the profiler since the Java frame is a close
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  // enough result. For the safepoint mechanism when the give it the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  // Java frame we are not at a point where the safepoint needs the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  // frame to that accurate (like for a compiled safepoint) since we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  // should be in a place where we are native and will block ourselves
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  // if we transition.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  void* _siginfo;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  ucontext_t* _ucontext;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  int _expanding_stack;                 /* non zero if manually expanding stack */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  address _alt_sig_stack;               /* address of base of alternate signal stack */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  void* siginfo() const                   { return _siginfo;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  void set_siginfo(void* ptr)             { _siginfo = ptr;   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  ucontext_t* ucontext() const            { return _ucontext; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  void set_ucontext(ucontext_t* ptr)      { _ucontext = ptr;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  void set_expanding_stack(void)          { _expanding_stack = 1;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  void clear_expanding_stack(void)        { _expanding_stack = 0;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  int  expanding_stack(void)              { return _expanding_stack;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  void set_alt_sig_stack(address val)     { _alt_sig_stack = val; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  address alt_sig_stack(void)             { return _alt_sig_stack; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  Monitor* _startThread_lock;     // sync parent and child in thread creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  Monitor* startThread_lock() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    return _startThread_lock;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  // ***************************************************************
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  // Platform dependent initialization and cleanup
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  // ***************************************************************
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  void pd_initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  void pd_destroy();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
// Reconciliation History
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
// osThread_solaris.hpp 1.24 99/08/27 13:11:54
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
// End
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   145
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   146
#endif // OS_LINUX_VM_OSTHREAD_LINUX_HPP