< prev index next >

src/hotspot/os/windows/os_windows.cpp

Print this page




 778     return ActiveProcessorCount;
 779   }
 780 
 781   DWORD_PTR lpProcessAffinityMask = 0;
 782   DWORD_PTR lpSystemAffinityMask = 0;
 783   int proc_count = processor_count();
 784   if (proc_count <= sizeof(UINT_PTR) * BitsPerByte &&
 785       GetProcessAffinityMask(GetCurrentProcess(), &lpProcessAffinityMask, &lpSystemAffinityMask)) {
 786     // Nof active processors is number of bits in process affinity mask
 787     int bitcount = 0;
 788     while (lpProcessAffinityMask != 0) {
 789       lpProcessAffinityMask = lpProcessAffinityMask & (lpProcessAffinityMask-1);
 790       bitcount++;
 791     }
 792     return bitcount;
 793   } else {
 794     return proc_count;
 795   }
 796 }
 797 




 798 void os::set_native_thread_name(const char *name) {
 799 
 800   // See: http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx
 801   //
 802   // Note that unfortunately this only works if the process
 803   // is already attached to a debugger; debugger must observe
 804   // the exception below to show the correct name.
 805 
 806   // If there is no debugger attached skip raising the exception
 807   if (!IsDebuggerPresent()) {
 808     return;
 809   }
 810 
 811   const DWORD MS_VC_EXCEPTION = 0x406D1388;
 812   struct {
 813     DWORD dwType;     // must be 0x1000
 814     LPCSTR szName;    // pointer to name (in user addr space)
 815     DWORD dwThreadID; // thread ID (-1=caller thread)
 816     DWORD dwFlags;    // reserved for future use, must be zero
 817   } info;




 778     return ActiveProcessorCount;
 779   }
 780 
 781   DWORD_PTR lpProcessAffinityMask = 0;
 782   DWORD_PTR lpSystemAffinityMask = 0;
 783   int proc_count = processor_count();
 784   if (proc_count <= sizeof(UINT_PTR) * BitsPerByte &&
 785       GetProcessAffinityMask(GetCurrentProcess(), &lpProcessAffinityMask, &lpSystemAffinityMask)) {
 786     // Nof active processors is number of bits in process affinity mask
 787     int bitcount = 0;
 788     while (lpProcessAffinityMask != 0) {
 789       lpProcessAffinityMask = lpProcessAffinityMask & (lpProcessAffinityMask-1);
 790       bitcount++;
 791     }
 792     return bitcount;
 793   } else {
 794     return proc_count;
 795   }
 796 }
 797 
 798 uint os::processor_id() {
 799   return (uint)GetCurrentProcessorNumber();
 800 }
 801 
 802 void os::set_native_thread_name(const char *name) {
 803 
 804   // See: http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx
 805   //
 806   // Note that unfortunately this only works if the process
 807   // is already attached to a debugger; debugger must observe
 808   // the exception below to show the correct name.
 809 
 810   // If there is no debugger attached skip raising the exception
 811   if (!IsDebuggerPresent()) {
 812     return;
 813   }
 814 
 815   const DWORD MS_VC_EXCEPTION = 0x406D1388;
 816   struct {
 817     DWORD dwType;     // must be 0x1000
 818     LPCSTR szName;    // pointer to name (in user addr space)
 819     DWORD dwThreadID; // thread ID (-1=caller thread)
 820     DWORD dwFlags;    // reserved for future use, must be zero
 821   } info;


< prev index next >