semeventmulti-r0drv-os2.cpp revision c97989161fbe75bc14cea477a5443bbf474dd3ad
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync/* $Id$ */
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync/** @file
c97989161fbe75bc14cea477a5443bbf474dd3advboxsync * innotek Portable Runtime - Multiple Release Event Semaphores, Ring-0 Driver, OS/2.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync */
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync/*
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * Copyright (c) 2007 knut st. osmundsen <bird-src-spam@anduin.net>
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync *
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * Permission is hereby granted, free of charge, to any person
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * obtaining a copy of this software and associated documentation
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * files (the "Software"), to deal in the Software without
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * restriction, including without limitation the rights to use,
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * copy, modify, merge, publish, distribute, sublicense, and/or sell
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * copies of the Software, and to permit persons to whom the
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * Software is furnished to do so, subject to the following
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * conditions:
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync *
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * The above copyright notice and this permission notice shall be
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * included in all copies or substantial portions of the Software.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync *
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * OTHER DEALINGS IN THE SOFTWARE.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync */
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync/*******************************************************************************
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync* Header Files *
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync*******************************************************************************/
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync#include "the-os2-kernel.h"
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync#include <iprt/semaphore.h>
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync#include <iprt/alloc.h>
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync#include <iprt/asm.h>
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync#include <iprt/assert.h>
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync#include <iprt/err.h>
881b5ff6bc55e1fb0f4ef42f9782ccec79c0a138vboxsync#include "internal/magics.h"
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync/*******************************************************************************
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync* Structures and Typedefs *
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync*******************************************************************************/
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync/**
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync * OS/2 multiple release event semaphore.
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync */
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsynctypedef struct RTSEMEVENTMULTIINTERNAL
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync{
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync /** Magic value (RTSEMEVENTMULTI_MAGIC). */
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync uint32_t volatile u32Magic;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync /** The number of waiting threads. */
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync uint32_t volatile cWaiters;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync /** Set if the event object is signaled. */
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync uint8_t volatile fSignaled;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync /** The number of threads in the process of waking up. */
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync uint32_t volatile cWaking;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync /** The OS/2 spinlock protecting this structure. */
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync SpinLock_t Spinlock;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync} RTSEMEVENTMULTIINTERNAL, *PRTSEMEVENTMULTIINTERNAL;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsyncRTDECL(int) RTSemEventMultiCreate(PRTSEMEVENTMULTI pEventMultiSem)
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync{
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync Assert(sizeof(RTSEMEVENTMULTIINTERNAL) > sizeof(void *));
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync AssertPtrReturn(pEventMultiSem, VERR_INVALID_POINTER);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync PRTSEMEVENTMULTIINTERNAL pEventMultiInt = (PRTSEMEVENTMULTIINTERNAL)RTMemAlloc(sizeof(*pEventMultiInt));
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync if (pEventMultiInt)
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync {
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync pEventMultiInt->u32Magic = RTSEMEVENTMULTI_MAGIC;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync pEventMultiInt->cWaiters = 0;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync pEventMultiInt->cWaking = 0;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync pEventMultiInt->fSignaled = 0;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync KernAllocSpinLock(&pEventMultiInt->Spinlock);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync *pEventMultiSem = pEventMultiInt;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync return VINF_SUCCESS;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync }
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync return VERR_NO_MEMORY;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync}
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsyncRTDECL(int) RTSemEventMultiDestroy(RTSEMEVENTMULTI EventMultiSem)
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync{
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync if (EventMultiSem == NIL_RTSEMEVENTMULTI) /* don't bitch */
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync return VERR_INVALID_HANDLE;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync PRTSEMEVENTMULTIINTERNAL pEventMultiInt = (PRTSEMEVENTMULTIINTERNAL)EventMultiSem;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync AssertPtrReturn(pEventMultiInt, VERR_INVALID_HANDLE);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync AssertMsgReturn(pEventMultiInt->u32Magic == RTSEMEVENTMULTI_MAGIC,
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync ("pEventMultiInt=%p u32Magic=%#x\n", pEventMultiInt, pEventMultiInt->u32Magic),
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync VERR_INVALID_HANDLE);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync KernAcquireSpinLock(&pEventMultiInt->Spinlock);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync ASMAtomicIncU32(&pEventMultiInt->u32Magic); /* make the handle invalid */
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync if (pEventMultiInt->cWaiters > 0)
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync {
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync /* abort waiting thread, last man cleans up. */
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync ASMAtomicXchgU32(&pEventMultiInt->cWaking, pEventMultiInt->cWaking + pEventMultiInt->cWaiters);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync ULONG cThreads;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync KernWakeup((ULONG)pEventMultiInt, WAKEUP_DATA | WAKEUP_BOOST, &cThreads, (ULONG)VERR_SEM_DESTROYED);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync KernReleaseSpinLock(&pEventMultiInt->Spinlock);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync }
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync else if (pEventMultiInt->cWaking)
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync /* the last waking thread is gonna do the cleanup */
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync KernReleaseSpinLock(&pEventMultiInt->Spinlock);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync else
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync {
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync KernReleaseSpinLock(&pEventMultiInt->Spinlock);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync KernFreeSpinLock(&pEventMultiInt->Spinlock);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync RTMemFree(pEventMultiInt);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync }
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync return VINF_SUCCESS;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync}
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsyncRTDECL(int) RTSemEventMultiSignal(RTSEMEVENTMULTI EventMultiSem)
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync{
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync PRTSEMEVENTMULTIINTERNAL pEventMultiInt = (PRTSEMEVENTMULTIINTERNAL)EventMultiSem;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync AssertPtrReturn(pEventMultiInt, VERR_INVALID_HANDLE);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync AssertMsgReturn(pEventMultiInt->u32Magic == RTSEMEVENTMULTI_MAGIC,
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync ("pEventMultiInt=%p u32Magic=%#x\n", pEventMultiInt, pEventMultiInt->u32Magic),
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync VERR_INVALID_HANDLE);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync KernAcquireSpinLock(&pEventMultiInt->Spinlock);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync ASMAtomicXchgU8(&pEventMultiInt->fSignaled, true);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync if (pEventMultiInt->cWaiters > 0)
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync {
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync ASMAtomicXchgU32(&pEventMultiInt->cWaking, pEventMultiInt->cWaking + pEventMultiInt->cWaiters);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync ASMAtomicXchgU32(&pEventMultiInt->cWaiters, 0);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync ULONG cThreads;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync KernWakeup((ULONG)pEventMultiInt, WAKEUP_DATA, &cThreads, VINF_SUCCESS);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync }
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync KernReleaseSpinLock(&pEventMultiInt->Spinlock);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync return VINF_SUCCESS;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync}
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsyncRTDECL(int) RTSemEventMultiReset(RTSEMEVENTMULTI EventMultiSem)
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync{
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync PRTSEMEVENTMULTIINTERNAL pEventMultiInt = (PRTSEMEVENTMULTIINTERNAL)EventMultiSem;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync AssertPtrReturn(pEventMultiInt, VERR_INVALID_HANDLE);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync AssertMsgReturn(pEventMultiInt->u32Magic == RTSEMEVENTMULTI_MAGIC,
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync ("pEventMultiInt=%p u32Magic=%#x\n", pEventMultiInt, pEventMultiInt->u32Magic),
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync VERR_INVALID_HANDLE);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync KernAcquireSpinLock(&pEventMultiInt->Spinlock);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync ASMAtomicXchgU8(&pEventMultiInt->fSignaled, false);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync KernReleaseSpinLock(&pEventMultiInt->Spinlock);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync return VINF_SUCCESS;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync}
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsyncstatic int rtSemEventMultiWait(RTSEMEVENTMULTI EventMultiSem, unsigned cMillies, bool fInterruptible)
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync{
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync PRTSEMEVENTMULTIINTERNAL pEventMultiInt = (PRTSEMEVENTMULTIINTERNAL)EventMultiSem;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync AssertPtrReturn(pEventMultiInt, VERR_INVALID_HANDLE);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync AssertMsgReturn(pEventMultiInt->u32Magic == RTSEMEVENTMULTI_MAGIC,
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync ("pEventMultiInt=%p u32Magic=%#x\n", pEventMultiInt, pEventMultiInt->u32Magic),
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync VERR_INVALID_HANDLE);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync KernAcquireSpinLock(&pEventMultiInt->Spinlock);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync int rc;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync if (pEventMultiInt->fSignaled)
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync rc = VINF_SUCCESS;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync else
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync {
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync ASMAtomicIncU32(&pEventMultiInt->cWaiters);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync ULONG ulData = (ULONG)VERR_INTERNAL_ERROR;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync rc = KernBlock((ULONG)pEventMultiInt,
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync cMillies == RT_INDEFINITE_WAIT ? SEM_INDEFINITE_WAIT : cMillies,
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync BLOCK_SPINLOCK | (fInterruptible ? BLOCK_UNINTERRUPTABLE : 0),
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync &pEventMultiInt->Spinlock,
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync &ulData);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync switch (rc)
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync {
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync case NO_ERROR:
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync rc = (int)ulData;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync Assert(rc == VINF_SUCCESS || rc == VERR_SEM_DESTROYED);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync Assert(pEventMultiInt->cWaking > 0);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync if ( !ASMAtomicDecU32(&pEventMultiInt->cWaking)
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync && pEventMultiInt->u32Magic != RTSEMEVENTMULTI_MAGIC)
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync {
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync /* The event was destroyed (ulData == VINF_SUCCESS if it was after we awoke), as
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync the last thread do the cleanup. */
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync KernReleaseSpinLock(&pEventMultiInt->Spinlock);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync KernFreeSpinLock(&pEventMultiInt->Spinlock);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync RTMemFree(pEventMultiInt);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync return VINF_SUCCESS;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync }
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync rc = VINF_SUCCESS;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync break;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync case ERROR_TIMEOUT:
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync Assert(cMillies != RT_INDEFINITE_WAIT);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync ASMAtomicDecU32(&pEventMultiInt->cWaiters);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync rc = VERR_TIMEOUT;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync break;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync case ERROR_INTERRUPT:
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync Assert(fInterruptible);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync ASMAtomicDecU32(&pEventMultiInt->cWaiters);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync rc = VERR_INTERRUPTED;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync break;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync default:
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync AssertMsgFailed(("rc=%d\n", rc));
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync rc = VERR_GENERAL_FAILURE;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync break;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync }
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync }
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync KernReleaseSpinLock(&pEventMultiInt->Spinlock);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync return rc;
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync}
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsyncRTDECL(int) RTSemEventMultiWait(RTSEMEVENTMULTI EventMultiSem, unsigned cMillies)
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync{
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync return rtSemEventMultiWait(EventMultiSem, cMillies, false /* not interruptable */);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync}
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsyncRTDECL(int) RTSemEventMultiWaitNoResume(RTSEMEVENTMULTI EventMultiSem, unsigned cMillies)
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync{
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync return rtSemEventMultiWait(EventMultiSem, cMillies, true /* interruptable */);
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync}
d1c5a03c19683c719b94496bb998fde2f2e5e622vboxsync