comparison 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
comparison
equal deleted inserted replaced
6082:4b37c0dafe3a 6093:960a442eae91
59 59
60 60
61 class OSThread: public CHeapObj { 61 class OSThread: public CHeapObj {
62 friend class VMStructs; 62 friend class VMStructs;
63 private: 63 private:
64 //void* _start_proc; // Thread start routine
65 OSThreadStartFunc _start_proc; // Thread start routine 64 OSThreadStartFunc _start_proc; // Thread start routine
66 void* _start_parm; // Thread start routine parameter 65 void* _start_parm; // Thread start routine parameter
67 volatile ThreadState _state; // Thread state *hint* 66 volatile ThreadState _state; // Thread state *hint*
68 volatile jint _interrupted; // Thread.isInterrupted state 67 volatile jint _interrupted; // Thread.isInterrupted state
69 68
75 // Methods 74 // Methods
76 public: 75 public:
77 void set_state(ThreadState state) { _state = state; } 76 void set_state(ThreadState state) { _state = state; }
78 ThreadState get_state() { return _state; } 77 ThreadState get_state() { return _state; }
79 78
80 // Constructor
81 OSThread(OSThreadStartFunc start_proc, void* start_parm); 79 OSThread(OSThreadStartFunc start_proc, void* start_parm);
82
83 // Destructor
84 ~OSThread(); 80 ~OSThread();
85 81
86 // Accessors 82 // Accessors
87 OSThreadStartFunc start_proc() const { return _start_proc; } 83 OSThreadStartFunc start_proc() const { return _start_proc; }
88 void set_start_proc(OSThreadStartFunc start_proc) { _start_proc = start_proc; } 84 void set_start_proc(OSThreadStartFunc start_proc) { _start_proc = start_proc; }
96 void print_on(outputStream* st) const; 92 void print_on(outputStream* st) const;
97 void print() const { print_on(tty); } 93 void print() const { print_on(tty); }
98 94
99 // For java intrinsics: 95 // For java intrinsics:
100 static ByteSize interrupted_offset() { return byte_offset_of(OSThread, _interrupted); } 96 static ByteSize interrupted_offset() { return byte_offset_of(OSThread, _interrupted); }
101 static ByteSize thread_id_offset() { return byte_offset_of(OSThread, _thread_id); }
102 97
103 // Platform dependent stuff 98 // Platform dependent stuff
104 #ifdef TARGET_OS_FAMILY_linux 99 #ifdef TARGET_OS_FAMILY_linux
105 # include "osThread_linux.hpp" 100 # include "osThread_linux.hpp"
106 #endif 101 #endif
112 #endif 107 #endif
113 #ifdef TARGET_OS_FAMILY_bsd 108 #ifdef TARGET_OS_FAMILY_bsd
114 # include "osThread_bsd.hpp" 109 # include "osThread_bsd.hpp"
115 #endif 110 #endif
116 111
112 public:
113 static ByteSize thread_id_offset() { return byte_offset_of(OSThread, _thread_id); }
114 static size_t thread_id_size() { return sizeof(thread_id_t); }
115
116 thread_id_t thread_id() const { return _thread_id; }
117
118 void set_thread_id(thread_id_t id) { _thread_id = id; }
119
120 private:
121 // _thread_id is kernel thread id (similar to LWP id on Solaris). Each
122 // thread has a unique thread_id (BsdThreads or NPTL). It can be used
123 // to access /proc.
124 thread_id_t _thread_id;
117 }; 125 };
118 126
119 127
120 // Utility class for use with condition variables: 128 // Utility class for use with condition variables:
121 class OSThreadWaitState : public StackObj { 129 class OSThreadWaitState : public StackObj {