diff src/share/vm/runtime/osThread.hpp @ 6093:960a442eae91

7161732: Improve handling of thread_id in OSThread Reviewed-by: dholmes, kamg
author rbackman
date Tue, 22 May 2012 10:11:53 +0200
parents 0105f367a14c
children d2a62e0f25eb
line wrap: on
line diff
--- a/src/share/vm/runtime/osThread.hpp	Fri May 18 09:15:15 2012 -0700
+++ b/src/share/vm/runtime/osThread.hpp	Tue May 22 10:11:53 2012 +0200
@@ -61,7 +61,6 @@
 class OSThread: public CHeapObj {
   friend class VMStructs;
  private:
-  //void* _start_proc;            // Thread start routine
   OSThreadStartFunc _start_proc;  // Thread start routine
   void* _start_parm;              // Thread start routine parameter
   volatile ThreadState _state;    // Thread state *hint*
@@ -77,10 +76,7 @@
   void set_state(ThreadState state)                { _state = state; }
   ThreadState get_state()                          { return _state; }
 
-  // Constructor
   OSThread(OSThreadStartFunc start_proc, void* start_parm);
-
-  // Destructor
   ~OSThread();
 
   // Accessors
@@ -98,7 +94,6 @@
 
   // For java intrinsics:
   static ByteSize interrupted_offset()            { return byte_offset_of(OSThread, _interrupted); }
-  static ByteSize thread_id_offset()              { return byte_offset_of(OSThread, _thread_id); }
 
   // Platform dependent stuff
 #ifdef TARGET_OS_FAMILY_linux
@@ -114,6 +109,19 @@
 # include "osThread_bsd.hpp"
 #endif
 
+ public:
+  static ByteSize thread_id_offset()              { return byte_offset_of(OSThread, _thread_id); }
+  static size_t thread_id_size()                  { return sizeof(thread_id_t); }
+
+  thread_id_t thread_id() const                   { return _thread_id; }
+
+  void set_thread_id(thread_id_t id)              { _thread_id = id; }
+
+ private:
+  // _thread_id is kernel thread id (similar to LWP id on Solaris). Each
+  // thread has a unique thread_id (BsdThreads or NPTL). It can be used
+  // to access /proc.
+  thread_id_t _thread_id;
 };