src/os/linux/vm/osThread_linux.hpp

Tue, 06 Mar 2012 12:36:59 +0100

author
rbackman
date
Tue, 06 Mar 2012 12:36:59 +0100
changeset 3709
0105f367a14c
parent 2314
f95d63e2154a
child 3796
960a442eae91
permissions
-rw-r--r--

7160570: Intrinsification support for tracing framework
Reviewed-by: sla, never

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

mercurial