semevent-r0drv-solaris.c revision 56665b35e85d3cd7d4232957d09b488ab44d81cf
86b51be433c7032578ae50e94ebe590cc428448bvboxsync * innotek Portable Runtime - Semaphores, Ring-0 Driver, Solaris.
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync * Copyright (C) 2006-2007 innotek GmbH
86b51be433c7032578ae50e94ebe590cc428448bvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
86b51be433c7032578ae50e94ebe590cc428448bvboxsync * available from http://www.virtualbox.org. This file is free software;
86b51be433c7032578ae50e94ebe590cc428448bvboxsync * you can redistribute it and/or modify it under the terms of the GNU
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * General Public License as published by the Free Software Foundation,
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * distribution. VirtualBox OSE is distributed in the hope that it will
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * be useful, but WITHOUT ANY WARRANTY of any kind.
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync/*******************************************************************************
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync* Header Files *
86b51be433c7032578ae50e94ebe590cc428448bvboxsync*******************************************************************************/
86b51be433c7032578ae50e94ebe590cc428448bvboxsync/*******************************************************************************
86b51be433c7032578ae50e94ebe590cc428448bvboxsync* Structures and Typedefs *
86b51be433c7032578ae50e94ebe590cc428448bvboxsync*******************************************************************************/
86b51be433c7032578ae50e94ebe590cc428448bvboxsync * Solaris event semaphore.
86b51be433c7032578ae50e94ebe590cc428448bvboxsync /** Magic value (RTSEMEVENT_MAGIC). */
86b51be433c7032578ae50e94ebe590cc428448bvboxsync /** The number of waiting threads. */
86b51be433c7032578ae50e94ebe590cc428448bvboxsync /** Set if the event object is signaled. */
86b51be433c7032578ae50e94ebe590cc428448bvboxsync /** The number of threads in the process of waking up. */
86b51be433c7032578ae50e94ebe590cc428448bvboxsync /** The Solaris mutex protecting this structure and pairing up the with the cv. */
86b51be433c7032578ae50e94ebe590cc428448bvboxsync /** The Solaris condition variable. */
86b51be433c7032578ae50e94ebe590cc428448bvboxsync Assert(sizeof(RTSEMEVENTINTERNAL) > sizeof(void *));
86b51be433c7032578ae50e94ebe590cc428448bvboxsync PRTSEMEVENTINTERNAL pEventInt = (PRTSEMEVENTINTERNAL)RTMemAlloc(sizeof(*pEventInt));
86b51be433c7032578ae50e94ebe590cc428448bvboxsync mutex_init(&pEventInt->Mtx, "IPRT Event Semaphore", MUTEX_DRIVER, NULL);
86b51be433c7032578ae50e94ebe590cc428448bvboxsync cv_init(&pEventInt->Cnd, "IPRT CV", CV_DRIVER, NULL);
86b51be433c7032578ae50e94ebe590cc428448bvboxsync PRTSEMEVENTINTERNAL pEventInt = (PRTSEMEVENTINTERNAL)EventSem;
86b51be433c7032578ae50e94ebe590cc428448bvboxsync AssertMsgReturn(pEventInt->u32Magic == RTSEMEVENT_MAGIC,
86b51be433c7032578ae50e94ebe590cc428448bvboxsync ("pEventInt=%p u32Magic=%#x\n", pEventInt, pEventInt->u32Magic),
86b51be433c7032578ae50e94ebe590cc428448bvboxsync ASMAtomicIncU32(&pEventInt->u32Magic); /* make the handle invalid */
86b51be433c7032578ae50e94ebe590cc428448bvboxsync /* abort waiting thread, last man cleans up. */
86b51be433c7032578ae50e94ebe590cc428448bvboxsync ASMAtomicXchgU32(&pEventInt->cWaking, pEventInt->cWaking + pEventInt->cWaiters);
78edef1df590edefed7cef91b6bcbf4d84f79947vboxsync /* the last waking thread is gonna do the cleanup */
86b51be433c7032578ae50e94ebe590cc428448bvboxsync PRTSEMEVENTINTERNAL pEventInt = (PRTSEMEVENTINTERNAL)EventSem;
86b51be433c7032578ae50e94ebe590cc428448bvboxsync AssertMsgReturn(pEventInt->u32Magic == RTSEMEVENT_MAGIC,
86b51be433c7032578ae50e94ebe590cc428448bvboxsync ("pEventInt=%p u32Magic=%#x\n", pEventInt, pEventInt->u32Magic),
return VINF_SUCCESS;
int rc;
if (fInterruptible)
if (fInterruptible)
if (rc > 0)
return rc;
return rc;