semevent-r0drv-solaris.c revision 8c99dcd207cf5b7bee01f95fbe19728a94076f94
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync/* $Id$ */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync/** @file
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * IPRT - Semaphores, Ring-0 Driver, Solaris.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync/*
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync *
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * available from http://www.virtualbox.org. This file is free software;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * you can redistribute it and/or modify it under the terms of the GNU
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * General Public License (GPL) as published by the Free Software
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync *
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * The contents of this file may alternatively be used under the terms
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * of the Common Development and Distribution License Version 1.0
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * VirtualBox OSE distribution, in which case the provisions of the
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * CDDL are applicable instead of those of the GPL.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync *
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * You may elect to license modified versions of this file under the
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * terms and conditions of either the GPL or the CDDL or both.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync *
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * additional information or have any questions.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsync/*******************************************************************************
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync* Header Files *
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync*******************************************************************************/
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync#include "the-solaris-kernel.h"
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync#include "internal/iprt.h"
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync#include <iprt/semaphore.h>
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync#include <iprt/alloc.h>
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync#include <iprt/assert.h>
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync#include <iprt/asm.h>
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync#include <iprt/err.h>
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync#include <iprt/mp.h>
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync#include <iprt/thread.h>
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync#include "internal/magics.h"
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync/*******************************************************************************
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync* Structures and Typedefs *
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync*******************************************************************************/
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync/**
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync * Solaris event semaphore.
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync */
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsynctypedef struct RTSEMEVENTINTERNAL
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync{
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync /** Magic value (RTSEMEVENT_MAGIC). */
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync uint32_t volatile u32Magic;
619824b60d668e6e43f385ef78cf06e13d43aab6vboxsync /** The number of waiting threads. */
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync uint32_t volatile cWaiters;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** Set if the event object is signaled. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync uint8_t volatile fSignaled;
2c95722bb302f4ce9454d04324b09314c0ccc038vboxsync /** The number of threads in the process of waking up. */
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync uint32_t volatile cWaking;
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync /** The Solaris mutex protecting this structure and pairing up the with the cv. */
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync kmutex_t Mtx;
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync /** The Solaris condition variable. */
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync kcondvar_t Cnd;
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync} RTSEMEVENTINTERNAL, *PRTSEMEVENTINTERNAL;
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsyncRTDECL(int) RTSemEventCreate(PRTSEMEVENT pEventSem)
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync{
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync Assert(sizeof(RTSEMEVENTINTERNAL) > sizeof(void *));
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync AssertPtrReturn(pEventSem, VERR_INVALID_POINTER);
76cb9831bbeaff3bb30068363e35660a776736c4vboxsync
d68336e34409fd767807d5ef641a305de4d9ee59vboxsync PRTSEMEVENTINTERNAL pEventInt = (PRTSEMEVENTINTERNAL)RTMemAlloc(sizeof(*pEventInt));
d68336e34409fd767807d5ef641a305de4d9ee59vboxsync if (pEventInt)
76cb9831bbeaff3bb30068363e35660a776736c4vboxsync {
76cb9831bbeaff3bb30068363e35660a776736c4vboxsync pEventInt->u32Magic = RTSEMEVENT_MAGIC;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync pEventInt->cWaiters = 0;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync pEventInt->cWaking = 0;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync pEventInt->fSignaled = 0;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync mutex_init(&pEventInt->Mtx, "IPRT Event Semaphore", MUTEX_DRIVER, (void *)ipltospl(DISP_LEVEL));
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync cv_init(&pEventInt->Cnd, "IPRT CV", CV_DRIVER, NULL);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync *pEventSem = pEventInt;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync return VINF_SUCCESS;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync }
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync return VERR_NO_MEMORY;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync}
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsyncRTDECL(int) RTSemEventDestroy(RTSEMEVENT EventSem)
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync{
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync if (EventSem == NIL_RTSEMEVENT)
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync return VERR_INVALID_HANDLE;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync PRTSEMEVENTINTERNAL pEventInt = (PRTSEMEVENTINTERNAL)EventSem;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync AssertPtrReturn(pEventInt, VERR_INVALID_HANDLE);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync AssertMsgReturn(pEventInt->u32Magic == RTSEMEVENT_MAGIC,
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync ("pEventInt=%p u32Magic=%#x\n", pEventInt, pEventInt->u32Magic),
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync VERR_INVALID_HANDLE);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync RT_ASSERT_INTS_ON();
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync mutex_enter(&pEventInt->Mtx);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync ASMAtomicIncU32(&pEventInt->u32Magic); /* make the handle invalid */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync if (pEventInt->cWaiters > 0)
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync {
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /* abort waiting thread, last man cleans up. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync ASMAtomicXchgU32(&pEventInt->cWaking, pEventInt->cWaking + pEventInt->cWaiters);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync cv_broadcast(&pEventInt->Cnd);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync mutex_exit(&pEventInt->Mtx);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync }
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync else if (pEventInt->cWaking)
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync {
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync /* the last waking thread is gonna do the cleanup */
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync mutex_exit(&pEventInt->Mtx);
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync }
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync else
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync {
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync mutex_exit(&pEventInt->Mtx);
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync cv_destroy(&pEventInt->Cnd);
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync mutex_destroy(&pEventInt->Mtx);
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync RTMemFree(pEventInt);
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync }
619824b60d668e6e43f385ef78cf06e13d43aab6vboxsync
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync return VINF_SUCCESS;
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync}
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsyncRTDECL(int) RTSemEventSignal(RTSEMEVENT EventSem)
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync{
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync PRTSEMEVENTINTERNAL pEventInt = (PRTSEMEVENTINTERNAL)EventSem;
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync RT_ASSERT_PREEMPT_CPUID_VAR();
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync AssertPtrReturn(pEventInt, VERR_INVALID_HANDLE);
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync AssertMsgReturn(pEventInt->u32Magic == RTSEMEVENT_MAGIC,
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync ("pEventInt=%p u32Magic=%#x\n", pEventInt, pEventInt->u32Magic),
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync VERR_INVALID_HANDLE);
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync RT_ASSERT_INTS_ON();
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync mutex_enter(&pEventInt->Mtx);
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync if (pEventInt->cWaiters > 0)
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync {
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync ASMAtomicDecU32(&pEventInt->cWaiters);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync ASMAtomicIncU32(&pEventInt->cWaking);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync cv_signal(&pEventInt->Cnd);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync }
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync else
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync ASMAtomicXchgU8(&pEventInt->fSignaled, true);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync mutex_exit(&pEventInt->Mtx);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync RT_ASSERT_PREEMPT_CPUID();
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync return VINF_SUCCESS;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync}
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsyncstatic int rtSemEventWait(RTSEMEVENT EventSem, unsigned cMillies, bool fInterruptible)
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync{
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync int rc;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync PRTSEMEVENTINTERNAL pEventInt = (PRTSEMEVENTINTERNAL)EventSem;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync AssertPtrReturn(pEventInt, VERR_INVALID_HANDLE);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync AssertMsgReturn(pEventInt->u32Magic == RTSEMEVENT_MAGIC,
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync ("pEventInt=%p u32Magic=%#x\n", pEventInt, pEventInt->u32Magic),
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync VERR_INVALID_HANDLE);
b3109af8dcc2a3da7f424aa05a4e84a64bf1c43fvboxsync RT_ASSERT_PREEMPTIBLE();
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync mutex_enter(&pEventInt->Mtx);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync if (pEventInt->fSignaled)
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync {
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync Assert(!pEventInt->cWaiters);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync ASMAtomicXchgU8(&pEventInt->fSignaled, false);
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync rc = VINF_SUCCESS;
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync }
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync else
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync {
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync ASMAtomicIncU32(&pEventInt->cWaiters);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /*
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * Translate milliseconds into ticks and go to sleep.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync if (cMillies != RT_INDEFINITE_WAIT)
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync {
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync clock_t cTicks = drv_usectohz((clock_t)(cMillies * 1000L));
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync clock_t timeout = ddi_get_lbolt();
4aafb1203580a5c145a7bdae57ebf69a36fa4f01vboxsync timeout += cTicks;
4aafb1203580a5c145a7bdae57ebf69a36fa4f01vboxsync if (fInterruptible)
4aafb1203580a5c145a7bdae57ebf69a36fa4f01vboxsync rc = cv_timedwait_sig(&pEventInt->Cnd, &pEventInt->Mtx, timeout);
4aafb1203580a5c145a7bdae57ebf69a36fa4f01vboxsync else
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync rc = cv_timedwait(&pEventInt->Cnd, &pEventInt->Mtx, timeout);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync }
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync else
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync {
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync if (fInterruptible)
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync rc = cv_wait_sig(&pEventInt->Cnd, &pEventInt->Mtx);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync else
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync {
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync cv_wait(&pEventInt->Cnd, &pEventInt->Mtx);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync rc = 1;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync }
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync }
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync if (rc > 0)
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync {
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /* Retured due to call to cv_signal() or cv_broadcast() */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync if (pEventInt->u32Magic != RTSEMEVENT_MAGIC)
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync {
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync rc = VERR_SEM_DESTROYED;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync if (!ASMAtomicDecU32(&pEventInt->cWaking))
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync {
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync mutex_exit(&pEventInt->Mtx);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync cv_destroy(&pEventInt->Cnd);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync mutex_destroy(&pEventInt->Mtx);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync RTMemFree(pEventInt);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync return rc;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync }
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync }
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync ASMAtomicDecU32(&pEventInt->cWaking);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync rc = VINF_SUCCESS;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync }
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync else if (rc == -1)
0780b79e94db3b60fb4a3057df7c64ba8b1cb75dvboxsync {
0780b79e94db3b60fb4a3057df7c64ba8b1cb75dvboxsync /* Returned due to timeout being reached */
0780b79e94db3b60fb4a3057df7c64ba8b1cb75dvboxsync if (pEventInt->cWaiters > 0)
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync ASMAtomicDecU32(&pEventInt->cWaiters);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync rc = VERR_TIMEOUT;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync }
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync else
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync {
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /* Returned due to pending signal */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync if (pEventInt->cWaiters > 0)
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync ASMAtomicDecU32(&pEventInt->cWaiters);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync rc = VERR_INTERRUPTED;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync }
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync }
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync mutex_exit(&pEventInt->Mtx);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync return rc;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync}
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync
4aafb1203580a5c145a7bdae57ebf69a36fa4f01vboxsyncRTDECL(int) RTSemEventWait(RTSEMEVENT EventSem, unsigned cMillies)
4aafb1203580a5c145a7bdae57ebf69a36fa4f01vboxsync{
4aafb1203580a5c145a7bdae57ebf69a36fa4f01vboxsync return rtSemEventWait(EventSem, cMillies, false /* not interruptible */);
4aafb1203580a5c145a7bdae57ebf69a36fa4f01vboxsync}
4aafb1203580a5c145a7bdae57ebf69a36fa4f01vboxsync
4aafb1203580a5c145a7bdae57ebf69a36fa4f01vboxsync
4aafb1203580a5c145a7bdae57ebf69a36fa4f01vboxsyncRTDECL(int) RTSemEventWaitNoResume(RTSEMEVENT EventSem, unsigned cMillies)
4aafb1203580a5c145a7bdae57ebf69a36fa4f01vboxsync{
4aafb1203580a5c145a7bdae57ebf69a36fa4f01vboxsync return rtSemEventWait(EventSem, cMillies, true /* interruptible */);
4aafb1203580a5c145a7bdae57ebf69a36fa4f01vboxsync}
4aafb1203580a5c145a7bdae57ebf69a36fa4f01vboxsync