src/os/linux/vm/osThread_linux.hpp

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

mercurial