--- old/src/os/linux/vm/os_linux.cpp 2015-06-22 16:01:34.912902008 +0200 +++ new/src/os/linux/vm/os_linux.cpp 2015-06-22 16:01:34.756896691 +0200 @@ -2393,40 +2393,7 @@ return CAST_FROM_FN_PTR(void*, UserHandler); } -class Semaphore : public StackObj { - public: - Semaphore(); - ~Semaphore(); - void signal(); - void wait(); - bool trywait(); - bool timedwait(unsigned int sec, int nsec); - private: - sem_t _semaphore; -}; - -Semaphore::Semaphore() { - sem_init(&_semaphore, 0, 0); -} - -Semaphore::~Semaphore() { - sem_destroy(&_semaphore); -} - -void Semaphore::signal() { - sem_post(&_semaphore); -} - -void Semaphore::wait() { - sem_wait(&_semaphore); -} - -bool Semaphore::trywait() { - return sem_trywait(&_semaphore) == 0; -} - -bool Semaphore::timedwait(unsigned int sec, int nsec) { - +struct timespec os::PosixSemaphore::create_timespec(unsigned int sec, int nsec) { struct timespec ts; // Semaphore's are always associated with CLOCK_REALTIME os::Linux::clock_gettime(CLOCK_REALTIME, &ts); @@ -2443,18 +2410,7 @@ } } - while (1) { - int result = sem_timedwait(&_semaphore, &ts); - if (result == 0) { - return true; - } else if (errno == EINTR) { - continue; - } else if (errno == ETIMEDOUT) { - return false; - } else { - return false; - } - } + return ts; } extern "C" { @@ -2494,7 +2450,7 @@ // Linux(POSIX) specific hand shaking semaphore. static sem_t sig_sem; -static Semaphore sr_semaphore; +static os::PosixSemaphore sr_semaphore; void os::signal_init_pd() { // Initialize signal structures