aboutsummaryrefslogtreecommitdiff
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
parentcf8088aac7e68db13a2ffe3b24353fb9bb260d7c (diff)
7161732: Improve handling of thread_id in OSThread
Reviewed-by: dholmes, kamg
-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
-rw-r--r--src/os_cpu/bsd_x86/vm/vmStructs_bsd_x86.hpp10
-rw-r--r--src/os_cpu/linux_sparc/vm/vmStructs_linux_sparc.hpp6
-rw-r--r--src/os_cpu/linux_x86/vm/vmStructs_linux_x86.hpp6
-rw-r--r--src/os_cpu/solaris_sparc/vm/vmStructs_solaris_sparc.hpp6
-rw-r--r--src/os_cpu/solaris_x86/vm/vmStructs_solaris_x86.hpp6
-rw-r--r--src/os_cpu/windows_x86/vm/vmStructs_windows_x86.hpp4
-rw-r--r--src/share/vm/runtime/osThread.hpp18
11 files changed, 42 insertions, 97 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
diff --git a/src/os_cpu/bsd_x86/vm/vmStructs_bsd_x86.hpp b/src/os_cpu/bsd_x86/vm/vmStructs_bsd_x86.hpp
index 4ccf80744..b98d97540 100644
--- a/src/os_cpu/bsd_x86/vm/vmStructs_bsd_x86.hpp
+++ b/src/os_cpu/bsd_x86/vm/vmStructs_bsd_x86.hpp
@@ -29,18 +29,12 @@
// constants required by the Serviceability Agent. This file is
// referenced by vmStructs.cpp.
-#ifdef __APPLE__
-#define OS_THREAD_ID_TYPE thread_t
-#else
-#define OS_THREAD_ID_TYPE pthread_t
-#endif
-
#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field, last_entry) \
\
/******************************/ \
/* Threads (NOTE: incomplete) */ \
/******************************/ \
- nonstatic_field(OSThread, _thread_id, OS_THREAD_ID_TYPE) \
+ nonstatic_field(OSThread, _thread_id, OSThread::thread_id_t) \
nonstatic_field(OSThread, _pthread_id, pthread_t) \
/* This must be the last entry, and must be present */ \
last_entry()
@@ -52,7 +46,7 @@
/* Posix Thread IDs */ \
/**********************/ \
\
- declare_unsigned_integer_type(thread_t) \
+ declare_unsigned_integer_type(OSThread::thread_id_t) \
declare_unsigned_integer_type(pthread_t) \
\
/* This must be the last entry, and must be present */ \
diff --git a/src/os_cpu/linux_sparc/vm/vmStructs_linux_sparc.hpp b/src/os_cpu/linux_sparc/vm/vmStructs_linux_sparc.hpp
index 4b0a3e63a..58fc94bbc 100644
--- a/src/os_cpu/linux_sparc/vm/vmStructs_linux_sparc.hpp
+++ b/src/os_cpu/linux_sparc/vm/vmStructs_linux_sparc.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,7 @@
/******************************/ \
\
nonstatic_field(JavaThread, _base_of_stack_pointer, intptr_t*) \
- nonstatic_field(OSThread, _thread_id, pid_t) \
+ nonstatic_field(OSThread, _thread_id, OSThread::thread_id_t) \
nonstatic_field(OSThread, _pthread_id, pthread_t) \
/* This must be the last entry, and must be present */ \
last_entry()
@@ -48,7 +48,7 @@
/* POSIX Thread IDs */ \
/**********************/ \
\
- declare_integer_type(pid_t) \
+ declare_integer_type(OSThread::thread_id_t) \
declare_unsigned_integer_type(pthread_t) \
\
/* This must be the last entry, and must be present */ \
diff --git a/src/os_cpu/linux_x86/vm/vmStructs_linux_x86.hpp b/src/os_cpu/linux_x86/vm/vmStructs_linux_x86.hpp
index c54cb1d72..c01e6c91c 100644
--- a/src/os_cpu/linux_x86/vm/vmStructs_linux_x86.hpp
+++ b/src/os_cpu/linux_x86/vm/vmStructs_linux_x86.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,7 @@
/******************************/ \
/* Threads (NOTE: incomplete) */ \
/******************************/ \
- nonstatic_field(OSThread, _thread_id, pid_t) \
+ nonstatic_field(OSThread, _thread_id, OSThread::thread_id_t) \
nonstatic_field(OSThread, _pthread_id, pthread_t) \
/* This must be the last entry, and must be present */ \
last_entry()
@@ -46,7 +46,7 @@
/* Posix Thread IDs */ \
/**********************/ \
\
- declare_integer_type(pid_t) \
+ declare_integer_type(OSThread::thread_id_t) \
declare_unsigned_integer_type(pthread_t) \
\
/* This must be the last entry, and must be present */ \
diff --git a/src/os_cpu/solaris_sparc/vm/vmStructs_solaris_sparc.hpp b/src/os_cpu/solaris_sparc/vm/vmStructs_solaris_sparc.hpp
index 710e33690..58113a9ea 100644
--- a/src/os_cpu/solaris_sparc/vm/vmStructs_solaris_sparc.hpp
+++ b/src/os_cpu/solaris_sparc/vm/vmStructs_solaris_sparc.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,7 @@
/******************************/ \
\
nonstatic_field(JavaThread, _base_of_stack_pointer, intptr_t*) \
- nonstatic_field(OSThread, _thread_id, thread_t) \
+ nonstatic_field(OSThread, _thread_id, OSThread::thread_id_t) \
/* This must be the last entry, and must be present */ \
last_entry()
@@ -47,7 +47,7 @@
/* Solaris Thread IDs */ \
/**********************/ \
\
- declare_unsigned_integer_type(thread_t) \
+ declare_unsigned_integer_type(OSThread::thread_id_t) \
\
/* This must be the last entry, and must be present */ \
last_entry()
diff --git a/src/os_cpu/solaris_x86/vm/vmStructs_solaris_x86.hpp b/src/os_cpu/solaris_x86/vm/vmStructs_solaris_x86.hpp
index 763389560..a2a4f7c60 100644
--- a/src/os_cpu/solaris_x86/vm/vmStructs_solaris_x86.hpp
+++ b/src/os_cpu/solaris_x86/vm/vmStructs_solaris_x86.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@
/* Threads (NOTE: incomplete) */ \
/******************************/ \
\
- nonstatic_field(OSThread, _thread_id, thread_t) \
+ nonstatic_field(OSThread, _thread_id, OSThread::thread_id_t) \
\
/* This must be the last entry, and must be present */ \
last_entry()
@@ -46,7 +46,7 @@
/* Solaris Thread IDs */ \
/**********************/ \
\
- declare_unsigned_integer_type(thread_t) \
+ declare_unsigned_integer_type(OSThread::thread_id_t) \
\
/* This must be the last entry, and must be present */ \
last_entry()
diff --git a/src/os_cpu/windows_x86/vm/vmStructs_windows_x86.hpp b/src/os_cpu/windows_x86/vm/vmStructs_windows_x86.hpp
index 6df1f7226..46e5f4c42 100644
--- a/src/os_cpu/windows_x86/vm/vmStructs_windows_x86.hpp
+++ b/src/os_cpu/windows_x86/vm/vmStructs_windows_x86.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@
/* Threads (NOTE: incomplete) */ \
/******************************/ \
\
- nonstatic_field(OSThread, _thread_id, unsigned long) \
+ nonstatic_field(OSThread, _thread_id, OSThread::thread_id_t) \
unchecked_nonstatic_field(OSThread, _thread_handle, sizeof(HANDLE)) /* NOTE: no type */ \
\
/* This must be the last entry, and must be present */ \
diff --git a/src/share/vm/runtime/osThread.hpp b/src/share/vm/runtime/osThread.hpp
index bb3fd7963..c0f2b1932 100644
--- a/src/share/vm/runtime/osThread.hpp
+++ b/src/share/vm/runtime/osThread.hpp
@@ -61,7 +61,6 @@ enum ThreadState {
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 @@ class OSThread: public CHeapObj {
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 @@ class OSThread: public CHeapObj {
// 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 @@ class OSThread: public CHeapObj {
# 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;
};