2583 } 2584 2585 // Sleep forever; naked call to OS-specific sleep; use with CAUTION 2586 void os::infinite_sleep() { 2587 while (true) { // sleep forever ... 2588 ::sleep(100); // ... 100 seconds at a time 2589 } 2590 } 2591 2592 // Used to convert frequent JVM_Yield() to nops 2593 bool os::dont_yield() { 2594 return DontYieldALot; 2595 } 2596 2597 void os::yield() { 2598 sched_yield(); 2599 } 2600 2601 os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN ;} 2602 2603 void os::yield_all() { 2604 // Yields to all threads, including threads with lower priorities 2605 // Threads on Bsd are all with same priority. The Solaris style 2606 // os::yield_all() with nanosleep(1ms) is not necessary. 2607 sched_yield(); 2608 } 2609 2610 //////////////////////////////////////////////////////////////////////////////// 2611 // thread priority support 2612 2613 // Note: Normal Bsd applications are run with SCHED_OTHER policy. SCHED_OTHER 2614 // only supports dynamic priority, static priority must be zero. For real-time 2615 // applications, Bsd supports SCHED_RR which allows static priority (1-99). 2616 // However, for large multi-threaded applications, SCHED_RR is not only slower 2617 // than SCHED_OTHER, but also very unstable (my volano tests hang hard 4 out 2618 // of 5 runs - Sep 2005). 2619 // 2620 // The following code actually changes the niceness of kernel-thread/LWP. It 2621 // has an assumption that setpriority() only modifies one kernel-thread/LWP, 2622 // not the entire user process, and user level threads are 1:1 mapped to kernel 2623 // threads. It has always been the case, but could change in the future. For 2624 // this reason, the code should not be used as default (ThreadPriorityPolicy=0). 2625 // It is only used when ThreadPriorityPolicy=1 and requires root privilege. 2626 2627 #if !defined(__APPLE__) 2628 int os::java_to_os_priority[CriticalPriority + 1] = { 2629 19, // 0 Entry should never be used | 2583 } 2584 2585 // Sleep forever; naked call to OS-specific sleep; use with CAUTION 2586 void os::infinite_sleep() { 2587 while (true) { // sleep forever ... 2588 ::sleep(100); // ... 100 seconds at a time 2589 } 2590 } 2591 2592 // Used to convert frequent JVM_Yield() to nops 2593 bool os::dont_yield() { 2594 return DontYieldALot; 2595 } 2596 2597 void os::yield() { 2598 sched_yield(); 2599 } 2600 2601 os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN ;} 2602 2603 //////////////////////////////////////////////////////////////////////////////// 2604 // thread priority support 2605 2606 // Note: Normal Bsd applications are run with SCHED_OTHER policy. SCHED_OTHER 2607 // only supports dynamic priority, static priority must be zero. For real-time 2608 // applications, Bsd supports SCHED_RR which allows static priority (1-99). 2609 // However, for large multi-threaded applications, SCHED_RR is not only slower 2610 // than SCHED_OTHER, but also very unstable (my volano tests hang hard 4 out 2611 // of 5 runs - Sep 2005). 2612 // 2613 // The following code actually changes the niceness of kernel-thread/LWP. It 2614 // has an assumption that setpriority() only modifies one kernel-thread/LWP, 2615 // not the entire user process, and user level threads are 1:1 mapped to kernel 2616 // threads. It has always been the case, but could change in the future. For 2617 // this reason, the code should not be used as default (ThreadPriorityPolicy=0). 2618 // It is only used when ThreadPriorityPolicy=1 and requires root privilege. 2619 2620 #if !defined(__APPLE__) 2621 int os::java_to_os_priority[CriticalPriority + 1] = { 2622 19, // 0 Entry should never be used |