aboutsummaryrefslogtreecommitdiff
path: root/src/os
diff options
context:
space:
mode:
authorrbackman <none@none>2012-05-22 10:11:53 +0200
committerrbackman <none@none>2012-05-22 10:11:53 +0200
commit9c4321ddce7080afd4d031c04dbeba761dbed295 (patch)
tree21dd71faf934de0fa5adabfd1caed1a7fe9bf80f /src/os
parentcf8088aac7e68db13a2ffe3b24353fb9bb260d7c (diff)
7161732: Improve handling of thread_id in OSThread
Reviewed-by: dholmes, kamg
Diffstat (limited to 'src/os')
-rw-r--r--src/os/bsd/vm/osThread_bsd.hpp50
-rw-r--r--src/os/linux/vm/osThread_linux.hpp17
-rw-r--r--src/os/solaris/vm/osThread_solaris.hpp6
-rw-r--r--src/os/windows/vm/osThread_windows.hpp10
4 files changed, 13 insertions, 70 deletions
diff --git a/src/os/bsd/vm/osThread_bsd.hpp b/src/os/bsd/vm/osThread_bsd.hpp
index 914a0439c..c72b36025 100644
--- a/src/os/bsd/vm/osThread_bsd.hpp
+++ b/src/os/bsd/vm/osThread_bsd.hpp
@@ -42,25 +42,18 @@
#ifdef _ALLBSD_SOURCE
#ifdef __APPLE__
- thread_t _thread_id;
+ typedef thread_t thread_id_t;
#else
- pthread_t _thread_id;
+ typedef pthread_t thread_id_t;
#endif
- // _pthread_id is the pthread id, which is used by library calls
- // (e.g. pthread_kill).
- pthread_t _pthread_id;
-
#else
- // _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.
- pid_t _thread_id;
+ typedef pid_t thread_id_t;
+#endif
// _pthread_id is the pthread id, which is used by library calls
// (e.g. pthread_kill).
pthread_t _pthread_id;
-#endif
sigset_t _caller_sigmask; // Caller's signal mask
@@ -70,28 +63,11 @@
sigset_t caller_sigmask() const { return _caller_sigmask; }
void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; }
-#ifdef _ALLBSD_SOURCE
-#ifdef __APPLE__
- static size_t thread_id_size() { return sizeof(thread_t); }
- thread_t thread_id() const {
- return _thread_id;
- }
-#else
- static size_t thread_id_size() { return sizeof(pthread_t); }
- pthread_t thread_id() const {
- return _thread_id;
- }
-#endif
-#else
- static size_t thread_id_size() { return sizeof(pid_t); }
- pid_t thread_id() const {
- return _thread_id;
- }
-#endif
#ifndef PRODUCT
// Used for debugging, return a unique integer for each thread.
intptr_t thread_identifier() const { return (intptr_t)_pthread_id; }
#endif
+
#ifdef ASSERT
// We expect no reposition failures so kill vm if we get one.
//
@@ -99,21 +75,7 @@
return false;
}
#endif // ASSERT
-#ifdef _ALLBSD_SOURCE
-#ifdef __APPLE__
- void set_thread_id(thread_t id) {
- _thread_id = id;
- }
-#else
- void set_thread_id(pthread_t id) {
- _thread_id = id;
- }
-#endif
-#else
- void set_thread_id(pid_t id) {
- _thread_id = id;
- }
-#endif
+
pthread_t pthread_id() const {
return _pthread_id;
}
diff --git a/src/os/linux/vm/osThread_linux.hpp b/src/os/linux/vm/osThread_linux.hpp
index fe9fe6188..904ab52e6 100644
--- a/src/os/linux/vm/osThread_linux.hpp
+++ b/src/os/linux/vm/osThread_linux.hpp
@@ -24,6 +24,8 @@
#ifndef OS_LINUX_VM_OSTHREAD_LINUX_HPP
#define OS_LINUX_VM_OSTHREAD_LINUX_HPP
+ public:
+ typedef pid_t thread_id_t;
private:
int _thread_type;
@@ -37,13 +39,6 @@
_thread_type = type;
}
- private:
-
- // _thread_id is kernel thread id (similar to LWP id on Solaris). Each
- // thread has a unique thread_id (LinuxThreads or NPTL). It can be used
- // to access /proc.
- pid_t _thread_id;
-
// _pthread_id is the pthread id, which is used by library calls
// (e.g. pthread_kill).
pthread_t _pthread_id;
@@ -56,11 +51,6 @@
sigset_t caller_sigmask() const { return _caller_sigmask; }
void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; }
- static size_t thread_id_size() { return sizeof(pid_t); }
-
- pid_t thread_id() const {
- return _thread_id;
- }
#ifndef PRODUCT
// Used for debugging, return a unique integer for each thread.
int thread_identifier() const { return _thread_id; }
@@ -72,9 +62,6 @@
return false;
}
#endif // ASSERT
- void set_thread_id(pid_t id) {
- _thread_id = id;
- }
pthread_t pthread_id() const {
return _pthread_id;
}
diff --git a/src/os/solaris/vm/osThread_solaris.hpp b/src/os/solaris/vm/osThread_solaris.hpp
index 6e79e1855..2a7a2470a 100644
--- a/src/os/solaris/vm/osThread_solaris.hpp
+++ b/src/os/solaris/vm/osThread_solaris.hpp
@@ -26,9 +26,10 @@
#define OS_SOLARIS_VM_OSTHREAD_SOLARIS_HPP
// This is embedded via include into the class OSThread
+ public:
+ typedef thread_t thread_id_t;
private:
- thread_t _thread_id; // Solaris thread id
uint _lwp_id; // lwp ID, only used with bound threads
int _native_priority; // Saved native priority when starting
// a bound thread
@@ -36,8 +37,6 @@
bool _vm_created_thread; // true if the VM created this thread,
// false if primary thread or attached thread
public:
- static size_t thread_id_size() { return sizeof(thread_t); }
- thread_t thread_id() const { return _thread_id; }
uint lwp_id() const { return _lwp_id; }
int native_priority() const { return _native_priority; }
@@ -63,7 +62,6 @@
return true;
}
#endif
- void set_thread_id(thread_t id) { _thread_id = id; }
void set_lwp_id(uint id) { _lwp_id = id; }
void set_native_priority(int prio) { _native_priority = prio; }
diff --git a/src/os/windows/vm/osThread_windows.hpp b/src/os/windows/vm/osThread_windows.hpp
index 28cd45c5c..af07695aa 100644
--- a/src/os/windows/vm/osThread_windows.hpp
+++ b/src/os/windows/vm/osThread_windows.hpp
@@ -25,12 +25,13 @@
#ifndef OS_WINDOWS_VM_OSTHREAD_WINDOWS_HPP
#define OS_WINDOWS_VM_OSTHREAD_WINDOWS_HPP
-typedef void* HANDLE;
+ typedef void* HANDLE;
+ public:
+ typedef unsigned long thread_id_t;
private:
// Win32-specific thread information
HANDLE _thread_handle; // Win32 thread handle
- unsigned long _thread_id; // Win32 thread id
HANDLE _interrupt_event; // Event signalled on thread interrupt
ThreadState _last_state;
@@ -42,9 +43,6 @@ typedef void* HANDLE;
HANDLE interrupt_event() const { return _interrupt_event; }
void set_interrupt_event(HANDLE interrupt_event) { _interrupt_event = interrupt_event; }
-
- static size_t thread_id_size() { return sizeof(unsigned long); }
- unsigned long thread_id() const { return _thread_id; }
#ifndef PRODUCT
// Used for debugging, return a unique integer for each thread.
int thread_identifier() const { return _thread_id; }
@@ -56,8 +54,6 @@ typedef void* HANDLE;
return false;
}
#endif // ASSERT
- void set_thread_id(unsigned long thread_id) { _thread_id = thread_id; }
-
bool is_try_mutex_enter() { return false; }
// This is a temporary fix for the thread states during