src/os/bsd/vm/osThread_bsd.hpp

Print this page
rev 3115 : [mq]: osx-threadid
   1 /*
   2  * Copyright (c) 1999, 2010, 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  */
  24 
  25 #ifndef OS_BSD_VM_OSTHREAD_BSD_HPP
  26 #define OS_BSD_VM_OSTHREAD_BSD_HPP
  27 
  28  private:
  29   int _thread_type;
  30 
  31  public:
  32 
  33   int thread_type() const {
  34     return _thread_type;
  35   }
  36   void set_thread_type(int type) {
  37     _thread_type = type;
  38   }
  39 
  40  private:
  41 
  42 #ifdef _ALLBSD_SOURCE
  43   // _thread_id and _pthread_id are the same on BSD
  44   // keep both to minimize code divergence in os_bsd.cpp


  45   pthread_t _thread_id;




  46   pthread_t _pthread_id;

  47 #else
  48   // _thread_id is kernel thread id (similar to LWP id on Solaris). Each
  49   // thread has a unique thread_id (BsdThreads or NPTL). It can be used
  50   // to access /proc.
  51   pid_t     _thread_id;
  52 
  53   // _pthread_id is the pthread id, which is used by library calls
  54   // (e.g. pthread_kill).
  55   pthread_t _pthread_id;
  56 #endif
  57 
  58   sigset_t _caller_sigmask; // Caller's signal mask
  59 
  60  public:
  61 
  62   // Methods to save/restore caller's signal mask
  63   sigset_t  caller_sigmask() const       { return _caller_sigmask; }
  64   void    set_caller_sigmask(sigset_t sigmask)  { _caller_sigmask = sigmask; }
  65 
  66 #ifdef _ALLBSD_SOURCE





  67   pthread_t thread_id() const {
  68     return _thread_id;
  69   }

  70 #else
  71   pid_t thread_id() const {
  72     return _thread_id;
  73   }
  74 #endif
  75 #ifndef PRODUCT
  76   // Used for debugging, return a unique integer for each thread.
  77   intptr_t thread_identifier() const   { return (intptr_t)_pthread_id; }
  78 #endif
  79 #ifdef ASSERT
  80   // We expect no reposition failures so kill vm if we get one.
  81   //
  82   bool valid_reposition_failure() {
  83     return false;
  84   }
  85 #endif // ASSERT
  86 #ifdef _ALLBSD_SOURCE





  87   void set_thread_id(pthread_t id) {
  88     _thread_id = id;
  89   }

  90 #else
  91   void set_thread_id(pid_t id) {
  92     _thread_id = id;
  93   }
  94 #endif
  95   pthread_t pthread_id() const {
  96     return _pthread_id;
  97   }
  98   void set_pthread_id(pthread_t tid) {
  99     _pthread_id = tid;
 100   }
 101 
 102   // ***************************************************************
 103   // suspension support.
 104   // ***************************************************************
 105 
 106 public:
 107   // flags that support signal based suspend/resume on Bsd are in a
 108   // separate class to avoid confusion with many flags in OSThread that
 109   // are used by VM level suspend/resume.


   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  */
  24 
  25 #ifndef OS_BSD_VM_OSTHREAD_BSD_HPP
  26 #define OS_BSD_VM_OSTHREAD_BSD_HPP
  27 
  28  private:
  29   int _thread_type;
  30 
  31  public:
  32 
  33   int thread_type() const {
  34     return _thread_type;
  35   }
  36   void set_thread_type(int type) {
  37     _thread_type = type;
  38   }
  39 
  40  private:
  41 
  42 #ifdef _ALLBSD_SOURCE
  43 
  44 #ifdef __APPLE__
  45   thread_t  _thread_id;
  46 #else
  47   pthread_t _thread_id;
  48 #endif
  49 
  50   // _pthread_id is the pthread id, which is used by library calls
  51   // (e.g. pthread_kill).
  52   pthread_t _pthread_id;
  53 
  54 #else
  55   // _thread_id is kernel thread id (similar to LWP id on Solaris). Each
  56   // thread has a unique thread_id (BsdThreads or NPTL). It can be used
  57   // to access /proc.
  58   pid_t     _thread_id;
  59 
  60   // _pthread_id is the pthread id, which is used by library calls
  61   // (e.g. pthread_kill).
  62   pthread_t _pthread_id;
  63 #endif
  64 
  65   sigset_t _caller_sigmask; // Caller's signal mask
  66 
  67  public:
  68 
  69   // Methods to save/restore caller's signal mask
  70   sigset_t  caller_sigmask() const       { return _caller_sigmask; }
  71   void    set_caller_sigmask(sigset_t sigmask)  { _caller_sigmask = sigmask; }
  72 
  73 #ifdef _ALLBSD_SOURCE
  74 #ifdef __APPLE__
  75   thread_t thread_id() const {
  76     return _thread_id;
  77   }
  78 #else
  79   pthread_t thread_id() const {
  80     return _thread_id;
  81   }
  82 #endif
  83 #else
  84   pid_t thread_id() const {
  85     return _thread_id;
  86   }
  87 #endif
  88 #ifndef PRODUCT
  89   // Used for debugging, return a unique integer for each thread.
  90   intptr_t thread_identifier() const   { return (intptr_t)_pthread_id; }
  91 #endif
  92 #ifdef ASSERT
  93   // We expect no reposition failures so kill vm if we get one.
  94   //
  95   bool valid_reposition_failure() {
  96     return false;
  97   }
  98 #endif // ASSERT
  99 #ifdef _ALLBSD_SOURCE
 100 #ifdef __APPLE__
 101   void set_thread_id(thread_t id) {
 102     _thread_id = id;
 103   }
 104 #else
 105   void set_thread_id(pthread_t id) {
 106     _thread_id = id;
 107   }
 108 #endif
 109 #else
 110   void set_thread_id(pid_t id) {
 111     _thread_id = id;
 112   }
 113 #endif
 114   pthread_t pthread_id() const {
 115     return _pthread_id;
 116   }
 117   void set_pthread_id(pthread_t tid) {
 118     _pthread_id = tid;
 119   }
 120 
 121   // ***************************************************************
 122   // suspension support.
 123   // ***************************************************************
 124 
 125 public:
 126   // flags that support signal based suspend/resume on Bsd are in a
 127   // separate class to avoid confusion with many flags in OSThread that
 128   // are used by VM level suspend/resume.