src/os/windows/vm/os_windows.cpp

Print this page




3503   while (true) {    // sleep forever ...
3504     Sleep(100000);  // ... 100 seconds at a time
3505   }
3506 }
3507 
3508 typedef BOOL (WINAPI * STTSignature)(void) ;
3509 
3510 os::YieldResult os::NakedYield() {
3511   // Use either SwitchToThread() or Sleep(0)
3512   // Consider passing back the return value from SwitchToThread().
3513   if (os::Kernel32Dll::SwitchToThreadAvailable()) {
3514     return SwitchToThread() ? os::YIELD_SWITCHED : os::YIELD_NONEREADY ;
3515   } else {
3516     Sleep(0);
3517   }
3518   return os::YIELD_UNKNOWN ;
3519 }
3520 
3521 void os::yield() {  os::NakedYield(); }
3522 
3523 void os::yield_all(int attempts) {
3524   // Yields to all threads, including threads with lower priorities
3525   Sleep(1);
3526 }
3527 
3528 // Win32 only gives you access to seven real priorities at a time,
3529 // so we compress Java's ten down to seven.  It would be better
3530 // if we dynamically adjusted relative priorities.
3531 
3532 int os::java_to_os_priority[CriticalPriority + 1] = {
3533   THREAD_PRIORITY_IDLE,                         // 0  Entry should never be used
3534   THREAD_PRIORITY_LOWEST,                       // 1  MinPriority
3535   THREAD_PRIORITY_LOWEST,                       // 2
3536   THREAD_PRIORITY_BELOW_NORMAL,                 // 3
3537   THREAD_PRIORITY_BELOW_NORMAL,                 // 4
3538   THREAD_PRIORITY_NORMAL,                       // 5  NormPriority
3539   THREAD_PRIORITY_NORMAL,                       // 6
3540   THREAD_PRIORITY_ABOVE_NORMAL,                 // 7
3541   THREAD_PRIORITY_ABOVE_NORMAL,                 // 8
3542   THREAD_PRIORITY_HIGHEST,                      // 9  NearMaxPriority
3543   THREAD_PRIORITY_HIGHEST,                      // 10 MaxPriority


3849   void *code_ptr = (void *)code;
3850   __try {
3851     __asm call code_ptr
3852   } __except(nx_exception_filter((_EXCEPTION_POINTERS*)_exception_info())) {
3853     tty->print_raw_cr("NX protection detected.");
3854   }
3855 }
3856 #endif // _WIN64
3857 #endif // PRODUCT
3858 
3859 // this is called _before_ the global arguments have been parsed
3860 void os::init(void) {
3861   _initial_pid = _getpid();
3862 
3863   init_random(1234567);
3864 
3865   win32::initialize_system_info();
3866   win32::setmode_streams();
3867   init_page_sizes((size_t) win32::vm_page_size());
3868 
3869   // For better scalability on MP systems (must be called after initialize_system_info)
3870 #ifndef PRODUCT
3871   if (is_MP()) {
3872     NoYieldsInMicrolock = true;
3873   }
3874 #endif
3875   // This may be overridden later when argument processing is done.
3876   FLAG_SET_ERGO(bool, UseLargePagesIndividualAllocation,
3877     os::win32::is_windows_2003());
3878 
3879   // Initialize main_process and main_thread
3880   main_process = GetCurrentProcess();  // Remember main_process is a pseudo handle
3881  if (!DuplicateHandle(main_process, GetCurrentThread(), main_process,
3882                        &main_thread, THREAD_ALL_ACCESS, false, 0)) {
3883     fatal("DuplicateHandle failed\n");
3884   }
3885   main_thread_id = (int) GetCurrentThreadId();
3886 }
3887 
3888 // To install functions for atexit processing
3889 extern "C" {
3890   static void perfMemory_exit_helper() {
3891     perfMemory_exit();
3892   }
3893 }
3894 




3503   while (true) {    // sleep forever ...
3504     Sleep(100000);  // ... 100 seconds at a time
3505   }
3506 }
3507 
3508 typedef BOOL (WINAPI * STTSignature)(void) ;
3509 
3510 os::YieldResult os::NakedYield() {
3511   // Use either SwitchToThread() or Sleep(0)
3512   // Consider passing back the return value from SwitchToThread().
3513   if (os::Kernel32Dll::SwitchToThreadAvailable()) {
3514     return SwitchToThread() ? os::YIELD_SWITCHED : os::YIELD_NONEREADY ;
3515   } else {
3516     Sleep(0);
3517   }
3518   return os::YIELD_UNKNOWN ;
3519 }
3520 
3521 void os::yield() {  os::NakedYield(); }
3522 
3523 void os::yield_all() {
3524   // Yields to all threads, including threads with lower priorities
3525   Sleep(1);
3526 }
3527 
3528 // Win32 only gives you access to seven real priorities at a time,
3529 // so we compress Java's ten down to seven.  It would be better
3530 // if we dynamically adjusted relative priorities.
3531 
3532 int os::java_to_os_priority[CriticalPriority + 1] = {
3533   THREAD_PRIORITY_IDLE,                         // 0  Entry should never be used
3534   THREAD_PRIORITY_LOWEST,                       // 1  MinPriority
3535   THREAD_PRIORITY_LOWEST,                       // 2
3536   THREAD_PRIORITY_BELOW_NORMAL,                 // 3
3537   THREAD_PRIORITY_BELOW_NORMAL,                 // 4
3538   THREAD_PRIORITY_NORMAL,                       // 5  NormPriority
3539   THREAD_PRIORITY_NORMAL,                       // 6
3540   THREAD_PRIORITY_ABOVE_NORMAL,                 // 7
3541   THREAD_PRIORITY_ABOVE_NORMAL,                 // 8
3542   THREAD_PRIORITY_HIGHEST,                      // 9  NearMaxPriority
3543   THREAD_PRIORITY_HIGHEST,                      // 10 MaxPriority


3849   void *code_ptr = (void *)code;
3850   __try {
3851     __asm call code_ptr
3852   } __except(nx_exception_filter((_EXCEPTION_POINTERS*)_exception_info())) {
3853     tty->print_raw_cr("NX protection detected.");
3854   }
3855 }
3856 #endif // _WIN64
3857 #endif // PRODUCT
3858 
3859 // this is called _before_ the global arguments have been parsed
3860 void os::init(void) {
3861   _initial_pid = _getpid();
3862 
3863   init_random(1234567);
3864 
3865   win32::initialize_system_info();
3866   win32::setmode_streams();
3867   init_page_sizes((size_t) win32::vm_page_size());
3868 






3869   // This may be overridden later when argument processing is done.
3870   FLAG_SET_ERGO(bool, UseLargePagesIndividualAllocation,
3871     os::win32::is_windows_2003());
3872 
3873   // Initialize main_process and main_thread
3874   main_process = GetCurrentProcess();  // Remember main_process is a pseudo handle
3875  if (!DuplicateHandle(main_process, GetCurrentThread(), main_process,
3876                        &main_thread, THREAD_ALL_ACCESS, false, 0)) {
3877     fatal("DuplicateHandle failed\n");
3878   }
3879   main_thread_id = (int) GetCurrentThreadId();
3880 }
3881 
3882 // To install functions for atexit processing
3883 extern "C" {
3884   static void perfMemory_exit_helper() {
3885     perfMemory_exit();
3886   }
3887 }
3888