106 #ifndef RUSAGE_THREAD |
106 #ifndef RUSAGE_THREAD |
107 #define RUSAGE_THREAD (1) /* only the calling thread */ |
107 #define RUSAGE_THREAD (1) /* only the calling thread */ |
108 #endif |
108 #endif |
109 |
109 |
110 #define MAX_PATH (2 * K) |
110 #define MAX_PATH (2 * K) |
|
111 |
|
112 #define MAX_SECS 100000000 |
111 |
113 |
112 // for timer info max values which include all bits |
114 // for timer info max values which include all bits |
113 #define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF) |
115 #define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF) |
114 |
116 |
115 #define LARGEPAGES_BIT (1 << 6) |
117 #define LARGEPAGES_BIT (1 << 6) |
2491 bool Semaphore::trywait() { |
2492 bool Semaphore::trywait() { |
2492 return sem_trywait(&_semaphore) == 0; |
2493 return sem_trywait(&_semaphore) == 0; |
2493 } |
2494 } |
2494 |
2495 |
2495 bool Semaphore::timedwait(unsigned int sec, int nsec) { |
2496 bool Semaphore::timedwait(unsigned int sec, int nsec) { |
|
2497 |
2496 struct timespec ts; |
2498 struct timespec ts; |
2497 unpackTime(&ts, false, (sec * NANOSECS_PER_SEC) + nsec); |
2499 // Semaphore's are always associated with CLOCK_REALTIME |
|
2500 os::Linux::clock_gettime(CLOCK_REALTIME, &ts); |
|
2501 // see unpackTime for discussion on overflow checking |
|
2502 if (sec >= MAX_SECS) { |
|
2503 ts.tv_sec += MAX_SECS; |
|
2504 ts.tv_nsec = 0; |
|
2505 } else { |
|
2506 ts.tv_sec += sec; |
|
2507 ts.tv_nsec += nsec; |
|
2508 if (ts.tv_nsec >= NANOSECS_PER_SEC) { |
|
2509 ts.tv_nsec -= NANOSECS_PER_SEC; |
|
2510 ++ts.tv_sec; // note: this must be <= max_secs |
|
2511 } |
|
2512 } |
2498 |
2513 |
2499 while (1) { |
2514 while (1) { |
2500 int result = sem_timedwait(&_semaphore, &ts); |
2515 int result = sem_timedwait(&_semaphore, &ts); |
2501 if (result == 0) { |
2516 if (result == 0) { |
2502 return true; |
2517 return true; |
5806 * on the condvar. Contention seen when trying to park implies that someone |
5821 * on the condvar. Contention seen when trying to park implies that someone |
5807 * is unparking you, so don't wait. And spurious returns are fine, so there |
5822 * is unparking you, so don't wait. And spurious returns are fine, so there |
5808 * is no need to track notifications. |
5823 * is no need to track notifications. |
5809 */ |
5824 */ |
5810 |
5825 |
5811 #define MAX_SECS 100000000 |
|
5812 /* |
5826 /* |
5813 * This code is common to linux and solaris and will be moved to a |
5827 * This code is common to linux and solaris and will be moved to a |
5814 * common place in dolphin. |
5828 * common place in dolphin. |
5815 * |
5829 * |
5816 * The passed in time value is either a relative time in nanoseconds |
5830 * The passed in time value is either a relative time in nanoseconds |