hotspot/src/os/bsd/vm/os_bsd.cpp
changeset 11881 9642744ae9a5
parent 11880 ed550eabf75c
child 12100 9990e6551406
equal deleted inserted replaced
11880:ed550eabf75c 11881:9642744ae9a5
   996     sync->notify_all();
   996     sync->notify_all();
   997     return NULL;
   997     return NULL;
   998   }
   998   }
   999 
   999 
  1000 #ifdef _ALLBSD_SOURCE
  1000 #ifdef _ALLBSD_SOURCE
       
  1001 #ifdef __APPLE__
       
  1002   // thread_id is mach thread on macos
       
  1003   osthread->set_thread_id(::mach_thread_self());
       
  1004 #else
  1001   // thread_id is pthread_id on BSD
  1005   // thread_id is pthread_id on BSD
  1002   osthread->set_thread_id(::pthread_self());
  1006   osthread->set_thread_id(::pthread_self());
       
  1007 #endif
  1003 #else
  1008 #else
  1004   // thread_id is kernel thread id (similar to Solaris LWP id)
  1009   // thread_id is kernel thread id (similar to Solaris LWP id)
  1005   osthread->set_thread_id(os::Bsd::gettid());
  1010   osthread->set_thread_id(os::Bsd::gettid());
  1006 
  1011 
  1007   if (UseNUMA) {
  1012   if (UseNUMA) {
  1188     return false;
  1193     return false;
  1189   }
  1194   }
  1190 
  1195 
  1191   // Store pthread info into the OSThread
  1196   // Store pthread info into the OSThread
  1192 #ifdef _ALLBSD_SOURCE
  1197 #ifdef _ALLBSD_SOURCE
       
  1198 #ifdef __APPLE__
       
  1199   osthread->set_thread_id(::mach_thread_self());
       
  1200 #else
  1193   osthread->set_thread_id(::pthread_self());
  1201   osthread->set_thread_id(::pthread_self());
       
  1202 #endif
  1194 #else
  1203 #else
  1195   osthread->set_thread_id(os::Bsd::gettid());
  1204   osthread->set_thread_id(os::Bsd::gettid());
  1196 #endif
  1205 #endif
  1197   osthread->set_pthread_id(::pthread_self());
  1206   osthread->set_pthread_id(::pthread_self());
  1198 
  1207 
  1805   ::strncpy(buf, s, n);
  1814   ::strncpy(buf, s, n);
  1806   buf[n] = '\0';
  1815   buf[n] = '\0';
  1807   return n;
  1816   return n;
  1808 }
  1817 }
  1809 
  1818 
  1810 intx os::current_thread_id() { return (intx)pthread_self(); }
  1819 intx os::current_thread_id() {
       
  1820 #ifdef __APPLE__
       
  1821   return (intx)::mach_thread_self();
       
  1822 #else
       
  1823   return (intx)::pthread_self();
       
  1824 #endif
       
  1825 }
  1811 int os::current_process_id() {
  1826 int os::current_process_id() {
  1812 
  1827 
  1813   // Under the old bsd thread library, bsd gives each thread
  1828   // Under the old bsd thread library, bsd gives each thread
  1814   // its own process id. Because of this each thread will return
  1829   // its own process id. Because of this each thread will return
  1815   // a different pid if this method were to return the result
  1830   // a different pid if this method were to return the result
  5150 jlong os::thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
  5165 jlong os::thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
  5151 #ifdef __APPLE__
  5166 #ifdef __APPLE__
  5152   struct thread_basic_info tinfo;
  5167   struct thread_basic_info tinfo;
  5153   mach_msg_type_number_t tcount = THREAD_INFO_MAX;
  5168   mach_msg_type_number_t tcount = THREAD_INFO_MAX;
  5154   kern_return_t kr;
  5169   kern_return_t kr;
  5155   mach_port_t mach_thread;
  5170   thread_t mach_thread;
  5156 
  5171 
  5157   mach_thread = pthread_mach_thread_np(thread->osthread()->thread_id());
  5172   mach_thread = thread->osthread()->thread_id();
  5158   kr = thread_info(mach_thread, THREAD_BASIC_INFO, (thread_info_t)&tinfo, &tcount);
  5173   kr = thread_info(mach_thread, THREAD_BASIC_INFO, (thread_info_t)&tinfo, &tcount);
  5159   if (kr != KERN_SUCCESS)
  5174   if (kr != KERN_SUCCESS)
  5160     return -1;
  5175     return -1;
  5161 
  5176 
  5162   if (user_sys_cpu_time) {
  5177   if (user_sys_cpu_time) {