< prev index next >

src/os/solaris/vm/os_solaris.cpp

Print this page

        

*** 2264,2322 **** void* os::user_handler() { 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: ! sema_t _semaphore; ! }; ! ! ! Semaphore::Semaphore() { ! sema_init(&_semaphore, 0, NULL, NULL); ! } ! ! Semaphore::~Semaphore() { ! sema_destroy(&_semaphore); ! } ! ! void Semaphore::signal() { ! sema_post(&_semaphore); ! } ! ! void Semaphore::wait() { ! sema_wait(&_semaphore); ! } ! ! bool Semaphore::trywait() { ! return sema_trywait(&_semaphore) == 0; ! } ! ! bool Semaphore::timedwait(unsigned int sec, int nsec) { struct timespec ts; unpackTime(&ts, false, (sec * NANOSECS_PER_SEC) + nsec); ! while (1) { ! int result = sema_timedwait(&_semaphore, &ts); ! if (result == 0) { ! return true; ! } else if (errno == EINTR) { ! continue; ! } else if (errno == ETIME) { ! return false; ! } else { ! return false; ! } ! } } extern "C" { typedef void (*sa_handler_t)(int); typedef void (*sa_sigaction_t)(int, siginfo_t *, void *); --- 2264,2278 ---- void* os::user_handler() { return CAST_FROM_FN_PTR(void*, UserHandler); } ! struct timespec os::PosixSemaphore::create_timespec(unsigned int sec, int nsec) { struct timespec ts; unpackTime(&ts, false, (sec * NANOSECS_PER_SEC) + nsec); ! return ts; } extern "C" { typedef void (*sa_handler_t)(int); typedef void (*sa_sigaction_t)(int, siginfo_t *, void *);
*** 3712,3722 **** static void suspend_save_context(OSThread *osthread, ucontext_t* context) { osthread->set_ucontext(context); } ! static Semaphore sr_semaphore; void os::Solaris::SR_handler(Thread* thread, ucontext_t* uc) { // Save and restore errno to avoid confusing native code with EINTR // after sigsuspend. int old_errno = errno; --- 3668,3678 ---- static void suspend_save_context(OSThread *osthread, ucontext_t* context) { osthread->set_ucontext(context); } ! static os::PosixSemaphore sr_semaphore; void os::Solaris::SR_handler(Thread* thread, ucontext_t* uc) { // Save and restore errno to avoid confusing native code with EINTR // after sigsuspend. int old_errno = errno;
< prev index next >