src/os/aix/vm/os_aix.cpp

Print this page




2795 }
2796 
2797 // Sleep forever; naked call to OS-specific sleep; use with CAUTION
2798 void os::infinite_sleep() {
2799   while (true) {    // sleep forever ...
2800     ::sleep(100);   // ... 100 seconds at a time
2801   }
2802 }
2803 
2804 // Used to convert frequent JVM_Yield() to nops
2805 bool os::dont_yield() {
2806   return DontYieldALot;
2807 }
2808 
2809 void os::yield() {
2810   sched_yield();
2811 }
2812 
2813 os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN; }
2814 
2815 void os::yield_all() {
2816   // Yields to all threads, including threads with lower priorities
2817   // Threads on Linux are all with same priority. The Solaris style
2818   // os::yield_all() with nanosleep(1ms) is not necessary.
2819   sched_yield();
2820 }
2821 
2822 ////////////////////////////////////////////////////////////////////////////////
2823 // thread priority support
2824 
2825 // From AIX manpage to pthread_setschedparam
2826 // (see: http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?
2827 //    topic=/com.ibm.aix.basetechref/doc/basetrf1/pthread_setschedparam.htm):
2828 //
2829 // "If schedpolicy is SCHED_OTHER, then sched_priority must be in the
2830 // range from 40 to 80, where 40 is the least favored priority and 80
2831 // is the most favored."
2832 //
2833 // (Actually, I doubt this even has an impact on AIX, as we do kernel
2834 // scheduling there; however, this still leaves iSeries.)
2835 //
2836 // We use the same values for AIX and PASE.
2837 int os::java_to_os_priority[CriticalPriority + 1] = {
2838   54,             // 0 Entry should never be used
2839 
2840   55,             // 1 MinPriority
2841   55,             // 2


3058   if (sr_notify(osthread) != 0) {
3059     // try to cancel, switch to running
3060 
3061     os::SuspendResume::State result = osthread->sr.cancel_suspend();
3062     if (result == os::SuspendResume::SR_RUNNING) {
3063       // cancelled
3064       return false;
3065     } else if (result == os::SuspendResume::SR_SUSPENDED) {
3066       // somehow managed to suspend
3067       return true;
3068     } else {
3069       ShouldNotReachHere();
3070       return false;
3071     }
3072   }
3073 
3074   // managed to send the signal and switch to SUSPEND_REQUEST, now wait for SUSPENDED
3075 
3076   for (int n = 0; !osthread->sr.is_suspended(); n++) {
3077     for (int i = 0; i < RANDOMLY_LARGE_INTEGER2 && !osthread->sr.is_suspended(); i++) {
3078       os::yield_all();
3079     }
3080 
3081     // timeout, try to cancel the request
3082     if (n >= RANDOMLY_LARGE_INTEGER) {
3083       os::SuspendResume::State cancelled = osthread->sr.cancel_suspend();
3084       if (cancelled == os::SuspendResume::SR_RUNNING) {
3085         return false;
3086       } else if (cancelled == os::SuspendResume::SR_SUSPENDED) {
3087         return true;
3088       } else {
3089         ShouldNotReachHere();
3090         return false;
3091       }
3092     }
3093   }
3094 
3095   guarantee(osthread->sr.is_suspended(), "Must be suspended");
3096   return true;
3097 }
3098 
3099 static void do_resume(OSThread* osthread) {
3100   //assert(osthread->sr.is_suspended(), "thread should be suspended");
3101 
3102   if (osthread->sr.request_wakeup() != os::SuspendResume::SR_WAKEUP_REQUEST) {
3103     // failed to switch to WAKEUP_REQUEST
3104     ShouldNotReachHere();
3105     return;
3106   }
3107 
3108   while (!osthread->sr.is_running()) {
3109     if (sr_notify(osthread) == 0) {
3110       for (int n = 0; n < RANDOMLY_LARGE_INTEGER && !osthread->sr.is_running(); n++) {
3111         for (int i = 0; i < 100 && !osthread->sr.is_running(); i++) {
3112           os::yield_all();
3113         }
3114       }
3115     } else {
3116       ShouldNotReachHere();
3117     }
3118   }
3119 
3120   guarantee(osthread->sr.is_running(), "Must be running!");
3121 }
3122 
3123 ///////////////////////////////////////////////////////////////////////////////////
3124 // signal handling (except suspend/resume)
3125 
3126 // This routine may be used by user applications as a "hook" to catch signals.
3127 // The user-defined signal handler must pass unrecognized signals to this
3128 // routine, and if it returns true (non-zero), then the signal handler must
3129 // return immediately. If the flag "abort_if_unrecognized" is true, then this
3130 // routine will never retun false (zero), but instead will execute a VM panic
3131 // routine kill the process.
3132 //




2795 }
2796 
2797 // Sleep forever; naked call to OS-specific sleep; use with CAUTION
2798 void os::infinite_sleep() {
2799   while (true) {    // sleep forever ...
2800     ::sleep(100);   // ... 100 seconds at a time
2801   }
2802 }
2803 
2804 // Used to convert frequent JVM_Yield() to nops
2805 bool os::dont_yield() {
2806   return DontYieldALot;
2807 }
2808 
2809 void os::yield() {
2810   sched_yield();
2811 }
2812 
2813 os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN; }
2814 







2815 ////////////////////////////////////////////////////////////////////////////////
2816 // thread priority support
2817 
2818 // From AIX manpage to pthread_setschedparam
2819 // (see: http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?
2820 //    topic=/com.ibm.aix.basetechref/doc/basetrf1/pthread_setschedparam.htm):
2821 //
2822 // "If schedpolicy is SCHED_OTHER, then sched_priority must be in the
2823 // range from 40 to 80, where 40 is the least favored priority and 80
2824 // is the most favored."
2825 //
2826 // (Actually, I doubt this even has an impact on AIX, as we do kernel
2827 // scheduling there; however, this still leaves iSeries.)
2828 //
2829 // We use the same values for AIX and PASE.
2830 int os::java_to_os_priority[CriticalPriority + 1] = {
2831   54,             // 0 Entry should never be used
2832 
2833   55,             // 1 MinPriority
2834   55,             // 2


3051   if (sr_notify(osthread) != 0) {
3052     // try to cancel, switch to running
3053 
3054     os::SuspendResume::State result = osthread->sr.cancel_suspend();
3055     if (result == os::SuspendResume::SR_RUNNING) {
3056       // cancelled
3057       return false;
3058     } else if (result == os::SuspendResume::SR_SUSPENDED) {
3059       // somehow managed to suspend
3060       return true;
3061     } else {
3062       ShouldNotReachHere();
3063       return false;
3064     }
3065   }
3066 
3067   // managed to send the signal and switch to SUSPEND_REQUEST, now wait for SUSPENDED
3068 
3069   for (int n = 0; !osthread->sr.is_suspended(); n++) {
3070     for (int i = 0; i < RANDOMLY_LARGE_INTEGER2 && !osthread->sr.is_suspended(); i++) {
3071       os::yield();
3072     }
3073 
3074     // timeout, try to cancel the request
3075     if (n >= RANDOMLY_LARGE_INTEGER) {
3076       os::SuspendResume::State cancelled = osthread->sr.cancel_suspend();
3077       if (cancelled == os::SuspendResume::SR_RUNNING) {
3078         return false;
3079       } else if (cancelled == os::SuspendResume::SR_SUSPENDED) {
3080         return true;
3081       } else {
3082         ShouldNotReachHere();
3083         return false;
3084       }
3085     }
3086   }
3087 
3088   guarantee(osthread->sr.is_suspended(), "Must be suspended");
3089   return true;
3090 }
3091 
3092 static void do_resume(OSThread* osthread) {
3093   //assert(osthread->sr.is_suspended(), "thread should be suspended");
3094 
3095   if (osthread->sr.request_wakeup() != os::SuspendResume::SR_WAKEUP_REQUEST) {
3096     // failed to switch to WAKEUP_REQUEST
3097     ShouldNotReachHere();
3098     return;
3099   }
3100 
3101   while (!osthread->sr.is_running()) {
3102     if (sr_notify(osthread) == 0) {
3103       for (int n = 0; n < RANDOMLY_LARGE_INTEGER && !osthread->sr.is_running(); n++) {
3104         for (int i = 0; i < 100 && !osthread->sr.is_running(); i++) {
3105           os::yield();
3106         }
3107       }
3108     } else {
3109       ShouldNotReachHere();
3110     }
3111   }
3112 
3113   guarantee(osthread->sr.is_running(), "Must be running!");
3114 }
3115 
3116 ///////////////////////////////////////////////////////////////////////////////////
3117 // signal handling (except suspend/resume)
3118 
3119 // This routine may be used by user applications as a "hook" to catch signals.
3120 // The user-defined signal handler must pass unrecognized signals to this
3121 // routine, and if it returns true (non-zero), then the signal handler must
3122 // return immediately. If the flag "abort_if_unrecognized" is true, then this
3123 // routine will never retun false (zero), but instead will execute a VM panic
3124 // routine kill the process.
3125 //