hotspot/src/os/bsd/vm/os_bsd.cpp
changeset 11251 e29da6b5622b
parent 11161 ec855b5a23c2
child 11402 739e52129c84
equal deleted inserted replaced
11250:ef1ab0772513 11251:e29da6b5622b
   148 
   148 
   149 #define MAX_PATH    (2 * K)
   149 #define MAX_PATH    (2 * K)
   150 
   150 
   151 // for timer info max values which include all bits
   151 // for timer info max values which include all bits
   152 #define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF)
   152 #define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF)
   153 #define SEC_IN_NANOSECS  1000000000LL
       
   154 
   153 
   155 #define LARGEPAGES_BIT (1 << 6)
   154 #define LARGEPAGES_BIT (1 << 6)
   156 ////////////////////////////////////////////////////////////////////////////////
   155 ////////////////////////////////////////////////////////////////////////////////
   157 // global variables
   156 // global variables
   158 julong os::Bsd::_physical_memory = 0;
   157 julong os::Bsd::_physical_memory = 0;
  3443 // Solaris uses poll(), bsd uses park().
  3442 // Solaris uses poll(), bsd uses park().
  3444 // Poll() is likely a better choice, assuming that Thread.interrupt()
  3443 // Poll() is likely a better choice, assuming that Thread.interrupt()
  3445 // generates a SIGUSRx signal. Note that SIGUSR1 can interfere with
  3444 // generates a SIGUSRx signal. Note that SIGUSR1 can interfere with
  3446 // SIGSEGV, see 4355769.
  3445 // SIGSEGV, see 4355769.
  3447 
  3446 
  3448 const int NANOSECS_PER_MILLISECS = 1000000;
       
  3449 
       
  3450 int os::sleep(Thread* thread, jlong millis, bool interruptible) {
  3447 int os::sleep(Thread* thread, jlong millis, bool interruptible) {
  3451   assert(thread == Thread::current(),  "thread consistency check");
  3448   assert(thread == Thread::current(),  "thread consistency check");
  3452 
  3449 
  3453   ParkEvent * const slp = thread->_SleepEvent ;
  3450   ParkEvent * const slp = thread->_SleepEvent ;
  3454   slp->reset() ;
  3451   slp->reset() ;
  3467       if (newtime - prevtime < 0) {
  3464       if (newtime - prevtime < 0) {
  3468         // time moving backwards, should only happen if no monotonic clock
  3465         // time moving backwards, should only happen if no monotonic clock
  3469         // not a guarantee() because JVM should not abort on kernel/glibc bugs
  3466         // not a guarantee() because JVM should not abort on kernel/glibc bugs
  3470         assert(!Bsd::supports_monotonic_clock(), "time moving backwards");
  3467         assert(!Bsd::supports_monotonic_clock(), "time moving backwards");
  3471       } else {
  3468       } else {
  3472         millis -= (newtime - prevtime) / NANOSECS_PER_MILLISECS;
  3469         millis -= (newtime - prevtime) / NANOSECS_PER_MILLISEC;
  3473       }
  3470       }
  3474 
  3471 
  3475       if(millis <= 0) {
  3472       if(millis <= 0) {
  3476         return OS_OK;
  3473         return OS_OK;
  3477       }
  3474       }
  3506       if (newtime - prevtime < 0) {
  3503       if (newtime - prevtime < 0) {
  3507         // time moving backwards, should only happen if no monotonic clock
  3504         // time moving backwards, should only happen if no monotonic clock
  3508         // not a guarantee() because JVM should not abort on kernel/glibc bugs
  3505         // not a guarantee() because JVM should not abort on kernel/glibc bugs
  3509         assert(!Bsd::supports_monotonic_clock(), "time moving backwards");
  3506         assert(!Bsd::supports_monotonic_clock(), "time moving backwards");
  3510       } else {
  3507       } else {
  3511         millis -= (newtime - prevtime) / NANOSECS_PER_MILLISECS;
  3508         millis -= (newtime - prevtime) / NANOSECS_PER_MILLISEC;
  3512       }
  3509       }
  3513 
  3510 
  3514       if(millis <= 0) break ;
  3511       if(millis <= 0) break ;
  3515 
  3512 
  3516       prevtime = newtime;
  3513       prevtime = newtime;
  4195 jlong os::Bsd::fast_thread_cpu_time(clockid_t clockid) {
  4192 jlong os::Bsd::fast_thread_cpu_time(clockid_t clockid) {
  4196   struct timespec tp;
  4193   struct timespec tp;
  4197   int rc = os::Bsd::clock_gettime(clockid, &tp);
  4194   int rc = os::Bsd::clock_gettime(clockid, &tp);
  4198   assert(rc == 0, "clock_gettime is expected to return 0 code");
  4195   assert(rc == 0, "clock_gettime is expected to return 0 code");
  4199 
  4196 
  4200   return (tp.tv_sec * SEC_IN_NANOSECS) + tp.tv_nsec;
  4197   return (tp.tv_sec * NANOSECS_PER_SEC) + tp.tv_nsec;
  4201 }
  4198 }
  4202 #endif
  4199 #endif
  4203 
  4200 
  4204 /////
  4201 /////
  4205 // glibc on Bsd platform uses non-documented flag
  4202 // glibc on Bsd platform uses non-documented flag
  5520  * on the condvar. Contention seen when trying to park implies that someone
  5517  * on the condvar. Contention seen when trying to park implies that someone
  5521  * is unparking you, so don't wait. And spurious returns are fine, so there
  5518  * is unparking you, so don't wait. And spurious returns are fine, so there
  5522  * is no need to track notifications.
  5519  * is no need to track notifications.
  5523  */
  5520  */
  5524 
  5521 
  5525 
       
  5526 #define NANOSECS_PER_SEC 1000000000
       
  5527 #define NANOSECS_PER_MILLISEC 1000000
       
  5528 #define MAX_SECS 100000000
  5522 #define MAX_SECS 100000000
  5529 /*
  5523 /*
  5530  * This code is common to bsd and solaris and will be moved to a
  5524  * This code is common to bsd and solaris and will be moved to a
  5531  * common place in dolphin.
  5525  * common place in dolphin.
  5532  *
  5526  *