src/os/bsd/vm/os_bsd.cpp

Print this page




2531 }
2532 
2533 // Sleep forever; naked call to OS-specific sleep; use with CAUTION
2534 void os::infinite_sleep() {
2535   while (true) {    // sleep forever ...
2536     ::sleep(100);   // ... 100 seconds at a time
2537   }
2538 }
2539 
2540 // Used to convert frequent JVM_Yield() to nops
2541 bool os::dont_yield() {
2542   return DontYieldALot;
2543 }
2544 
2545 void os::yield() {
2546   sched_yield();
2547 }
2548 
2549 os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN ;}
2550 
2551 void os::yield_all(int attempts) {
2552   // Yields to all threads, including threads with lower priorities
2553   // Threads on Bsd are all with same priority. The Solaris style
2554   // os::yield_all() with nanosleep(1ms) is not necessary.
2555   sched_yield();
2556 }
2557 
2558 // Called from the tight loops to possibly influence time-sharing heuristics
2559 void os::loop_breaker(int attempts) {
2560   os::yield_all(attempts);
2561 }
2562 
2563 ////////////////////////////////////////////////////////////////////////////////
2564 // thread priority support
2565 
2566 // Note: Normal Bsd applications are run with SCHED_OTHER policy. SCHED_OTHER
2567 // only supports dynamic priority, static priority must be zero. For real-time
2568 // applications, Bsd supports SCHED_RR which allows static priority (1-99).
2569 // However, for large multi-threaded applications, SCHED_RR is not only slower
2570 // than SCHED_OTHER, but also very unstable (my volano tests hang hard 4 out
2571 // of 5 runs - Sep 2005).
2572 //
2573 // The following code actually changes the niceness of kernel-thread/LWP. It
2574 // has an assumption that setpriority() only modifies one kernel-thread/LWP,
2575 // not the entire user process, and user level threads are 1:1 mapped to kernel
2576 // threads. It has always been the case, but could change in the future. For
2577 // this reason, the code should not be used as default (ThreadPriorityPolicy=0).
2578 // It is only used when ThreadPriorityPolicy=1 and requires root privilege.
2579 
2580 #if !defined(__APPLE__)
2581 int os::java_to_os_priority[CriticalPriority + 1] = {
2582   19,              // 0 Entry should never be used




2531 }
2532 
2533 // Sleep forever; naked call to OS-specific sleep; use with CAUTION
2534 void os::infinite_sleep() {
2535   while (true) {    // sleep forever ...
2536     ::sleep(100);   // ... 100 seconds at a time
2537   }
2538 }
2539 
2540 // Used to convert frequent JVM_Yield() to nops
2541 bool os::dont_yield() {
2542   return DontYieldALot;
2543 }
2544 
2545 void os::yield() {
2546   sched_yield();
2547 }
2548 
2549 os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN ;}
2550 
2551 void os::yield_all() {
2552   // Yields to all threads, including threads with lower priorities
2553   // Threads on Bsd are all with same priority. The Solaris style
2554   // os::yield_all() with nanosleep(1ms) is not necessary.
2555   sched_yield();
2556 }
2557 





2558 ////////////////////////////////////////////////////////////////////////////////
2559 // thread priority support
2560 
2561 // Note: Normal Bsd applications are run with SCHED_OTHER policy. SCHED_OTHER
2562 // only supports dynamic priority, static priority must be zero. For real-time
2563 // applications, Bsd supports SCHED_RR which allows static priority (1-99).
2564 // However, for large multi-threaded applications, SCHED_RR is not only slower
2565 // than SCHED_OTHER, but also very unstable (my volano tests hang hard 4 out
2566 // of 5 runs - Sep 2005).
2567 //
2568 // The following code actually changes the niceness of kernel-thread/LWP. It
2569 // has an assumption that setpriority() only modifies one kernel-thread/LWP,
2570 // not the entire user process, and user level threads are 1:1 mapped to kernel
2571 // threads. It has always been the case, but could change in the future. For
2572 // this reason, the code should not be used as default (ThreadPriorityPolicy=0).
2573 // It is only used when ThreadPriorityPolicy=1 and requires root privilege.
2574 
2575 #if !defined(__APPLE__)
2576 int os::java_to_os_priority[CriticalPriority + 1] = {
2577   19,              // 0 Entry should never be used