src/os/linux/vm/os_linux.cpp

Print this page




3778 }
3779 
3780 // Sleep forever; naked call to OS-specific sleep; use with CAUTION
3781 void os::infinite_sleep() {
3782   while (true) {    // sleep forever ...
3783     ::sleep(100);   // ... 100 seconds at a time
3784   }
3785 }
3786 
3787 // Used to convert frequent JVM_Yield() to nops
3788 bool os::dont_yield() {
3789   return DontYieldALot;
3790 }
3791 
3792 void os::yield() {
3793   sched_yield();
3794 }
3795 
3796 os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN ;}
3797 
3798 void os::yield_all() {
3799   // Yields to all threads, including threads with lower priorities
3800   // Threads on Linux are all with same priority. The Solaris style
3801   // os::yield_all() with nanosleep(1ms) is not necessary.
3802   sched_yield();
3803 }
3804 
3805 ////////////////////////////////////////////////////////////////////////////////
3806 // thread priority support
3807 
3808 // Note: Normal Linux applications are run with SCHED_OTHER policy. SCHED_OTHER
3809 // only supports dynamic priority, static priority must be zero. For real-time
3810 // applications, Linux supports SCHED_RR which allows static priority (1-99).
3811 // However, for large multi-threaded applications, SCHED_RR is not only slower
3812 // than SCHED_OTHER, but also very unstable (my volano tests hang hard 4 out
3813 // of 5 runs - Sep 2005).
3814 //
3815 // The following code actually changes the niceness of kernel-thread/LWP. It
3816 // has an assumption that setpriority() only modifies one kernel-thread/LWP,
3817 // not the entire user process, and user level threads are 1:1 mapped to kernel
3818 // threads. It has always been the case, but could change in the future. For
3819 // this reason, the code should not be used as default (ThreadPriorityPolicy=0).
3820 // It is only used when ThreadPriorityPolicy=1 and requires root privilege.
3821 
3822 int os::java_to_os_priority[CriticalPriority + 1] = {
3823   19,              // 0 Entry should never be used
3824 




3778 }
3779 
3780 // Sleep forever; naked call to OS-specific sleep; use with CAUTION
3781 void os::infinite_sleep() {
3782   while (true) {    // sleep forever ...
3783     ::sleep(100);   // ... 100 seconds at a time
3784   }
3785 }
3786 
3787 // Used to convert frequent JVM_Yield() to nops
3788 bool os::dont_yield() {
3789   return DontYieldALot;
3790 }
3791 
3792 void os::yield() {
3793   sched_yield();
3794 }
3795 
3796 os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN ;}
3797 







3798 ////////////////////////////////////////////////////////////////////////////////
3799 // thread priority support
3800 
3801 // Note: Normal Linux applications are run with SCHED_OTHER policy. SCHED_OTHER
3802 // only supports dynamic priority, static priority must be zero. For real-time
3803 // applications, Linux supports SCHED_RR which allows static priority (1-99).
3804 // However, for large multi-threaded applications, SCHED_RR is not only slower
3805 // than SCHED_OTHER, but also very unstable (my volano tests hang hard 4 out
3806 // of 5 runs - Sep 2005).
3807 //
3808 // The following code actually changes the niceness of kernel-thread/LWP. It
3809 // has an assumption that setpriority() only modifies one kernel-thread/LWP,
3810 // not the entire user process, and user level threads are 1:1 mapped to kernel
3811 // threads. It has always been the case, but could change in the future. For
3812 // this reason, the code should not be used as default (ThreadPriorityPolicy=0).
3813 // It is only used when ThreadPriorityPolicy=1 and requires root privilege.
3814 
3815 int os::java_to_os_priority[CriticalPriority + 1] = {
3816   19,              // 0 Entry should never be used
3817