src/os/bsd/vm/os_bsd.cpp
Print this page
rev 3115 : [mq]: osx-threadid
*** 977,988 ****
--- 977,993 ----
sync->notify_all();
return NULL;
}
#ifdef _ALLBSD_SOURCE
+ #ifdef __APPLE__
+ // thread_id is mach thread on macos
+ osthread->set_thread_id(::mach_thread_self());
+ #else
// thread_id is pthread_id on BSD
osthread->set_thread_id(::pthread_self());
+ #endif
#else
// thread_id is kernel thread id (similar to Solaris LWP id)
osthread->set_thread_id(os::Bsd::gettid());
if (UseNUMA) {
*** 1169,1179 ****
--- 1174,1188 ----
return false;
}
// Store pthread info into the OSThread
#ifdef _ALLBSD_SOURCE
+ #ifdef __APPLE__
+ osthread->set_thread_id(::mach_thread_self());
+ #else
osthread->set_thread_id(::pthread_self());
+ #endif
#else
osthread->set_thread_id(os::Bsd::gettid());
#endif
osthread->set_pthread_id(::pthread_self());
*** 1786,1796 ****
::strncpy(buf, s, n);
buf[n] = '\0';
return n;
}
! intx os::current_thread_id() { return (intx)pthread_self(); }
int os::current_process_id() {
// Under the old bsd thread library, bsd gives each thread
// its own process id. Because of this each thread will return
// a different pid if this method were to return the result
--- 1795,1811 ----
::strncpy(buf, s, n);
buf[n] = '\0';
return n;
}
! intx os::current_thread_id() {
! #ifdef __APPLE__
! return (intx)::mach_thread_self();
! #else
! return (intx)::pthread_self();
! #endif
! }
int os::current_process_id() {
// Under the old bsd thread library, bsd gives each thread
// its own process id. Because of this each thread will return
// a different pid if this method were to return the result
*** 5131,5143 ****
jlong os::thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
#ifdef __APPLE__
struct thread_basic_info tinfo;
mach_msg_type_number_t tcount = THREAD_INFO_MAX;
kern_return_t kr;
! mach_port_t mach_thread;
! mach_thread = pthread_mach_thread_np(thread->osthread()->thread_id());
kr = thread_info(mach_thread, THREAD_BASIC_INFO, (thread_info_t)&tinfo, &tcount);
if (kr != KERN_SUCCESS)
return -1;
if (user_sys_cpu_time) {
--- 5146,5158 ----
jlong os::thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
#ifdef __APPLE__
struct thread_basic_info tinfo;
mach_msg_type_number_t tcount = THREAD_INFO_MAX;
kern_return_t kr;
! thread_t mach_thread;
! mach_thread = thread->osthread()->thread_id();
kr = thread_info(mach_thread, THREAD_BASIC_INFO, (thread_info_t)&tinfo, &tcount);
if (kr != KERN_SUCCESS)
return -1;
if (user_sys_cpu_time) {