semevent-r0drv-solaris.c revision 175770d4533d92ff4ef576d5ea97e566cc488472
00fa3bc989ffe84474e828c8b90b24284dcfdf0cvboxsync * IPRT - Single Release Event Semaphores, Ring-0 Driver, Solaris.
00fa3bc989ffe84474e828c8b90b24284dcfdf0cvboxsync * Copyright (C) 2006-2010 Oracle Corporation
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * available from http://www.virtualbox.org. This file is free software;
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * you can redistribute it and/or modify it under the terms of the GNU
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * General Public License (GPL) as published by the Free Software
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * The contents of this file may alternatively be used under the terms
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * of the Common Development and Distribution License Version 1.0
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * VirtualBox OSE distribution, in which case the provisions of the
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * CDDL are applicable instead of those of the GPL.
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsync * You may elect to license modified versions of this file under the
0c437bb10c61b229407a7517efde04dfe3b1e4a1vboxsync * terms and conditions of either the GPL or the CDDL or both.
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync/*******************************************************************************
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync* Header Files *
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync*******************************************************************************/
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync/*******************************************************************************
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync* Structures and Typedefs *
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync*******************************************************************************/
addc480d0d7650db6323467bbdab6c21836a2928vboxsync * Waiter entry. Lives on the stack.
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * @remarks Unfortunately, we cannot easily use cv_signal because we cannot
9347f1987dfb760943aba5a9ef094c6066901be3vboxsync * distinguish between it and the spurious wakeups we get after fork.
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * So, we keep an unprioritized FIFO with the sleeping threads.
1999ae03c34840fa4d712fd2e020120b2cb7182avboxsync /** The list node. */
1999ae03c34840fa4d712fd2e020120b2cb7182avboxsync /** The thread. */
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync /** Flag set when waking up the thread by signal or destroy. */
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync bool volatile fWokenUp;
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync/** Pointer to waiter entry. */
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * Solaris event semaphore.
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync /** Magic value (RTSEMEVENT_MAGIC). */
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync /** The number of threads referencing this object. */
ec21c063515d0931111f0c1f8d6f4bc8e7a6c882vboxsync /** Set if the object is signalled when there are no waiters. */
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync /** List of waiting and woken up threads. */
ec21c063515d0931111f0c1f8d6f4bc8e7a6c882vboxsync /** The Solaris mutex protecting this structure and pairing up the with the cv. */
ec21c063515d0931111f0c1f8d6f4bc8e7a6c882vboxsync /** The Solaris condition variable. */
ec21c063515d0931111f0c1f8d6f4bc8e7a6c882vboxsyncRTDECL(int) RTSemEventCreate(PRTSEMEVENT phEventSem)
ec21c063515d0931111f0c1f8d6f4bc8e7a6c882vboxsync return RTSemEventCreateEx(phEventSem, 0 /*fFlags*/, NIL_RTLOCKVALCLASS, NULL);
ec21c063515d0931111f0c1f8d6f4bc8e7a6c882vboxsyncRTDECL(int) RTSemEventCreateEx(PRTSEMEVENT phEventSem, uint32_t fFlags, RTLOCKVALCLASS hClass, const char *pszNameFmt, ...)
ec21c063515d0931111f0c1f8d6f4bc8e7a6c882vboxsync AssertCompile(sizeof(RTSEMEVENTINTERNAL) > sizeof(void *));
ec21c063515d0931111f0c1f8d6f4bc8e7a6c882vboxsync AssertReturn(!(fFlags & ~(RTSEMEVENT_FLAGS_NO_LOCK_VAL | RTSEMEVENT_FLAGS_BOOTSTRAP_HACK)), VERR_INVALID_PARAMETER);
ec21c063515d0931111f0c1f8d6f4bc8e7a6c882vboxsync Assert(!(fFlags & RTSEMEVENT_FLAGS_BOOTSTRAP_HACK) || (fFlags & RTSEMEVENT_FLAGS_NO_LOCK_VAL));
ec21c063515d0931111f0c1f8d6f4bc8e7a6c882vboxsync PRTSEMEVENTINTERNAL pThis = (PRTSEMEVENTINTERNAL)RTMemAlloc(sizeof(*pThis));
addc480d0d7650db6323467bbdab6c21836a2928vboxsync mutex_init(&pThis->Mtx, "IPRT Event Semaphore", MUTEX_DRIVER, (void *)ipltospl(DISP_LEVEL));
faa31dfcb46e5e2fb9c2bf224d113a0ca136ddecvboxsync * Retain a reference to the semaphore.
8de98485a60eb742b1d720a8cb9747dc03e821a8vboxsync * @param pThis The semaphore.
faa31dfcb46e5e2fb9c2bf224d113a0ca136ddecvboxsyncDECLINLINE(void) rtR0SemEventSolRetain(PRTSEMEVENTINTERNAL pThis)
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * The destruct.
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * @param pThis The semaphore.
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsyncstatic void rtR0SemEventSolDtor(PRTSEMEVENTINTERNAL pThis)
return VINF_SUCCESS;
AssertMsgReturn(pThis->u32Magic == RTSEMEVENT_MAGIC, ("u32Magic=%RX32 pThis=%p\n", pThis->u32Magic, pThis), VERR_INVALID_HANDLE);
return VINF_SUCCESS;
AssertMsgReturn(pThis->u32Magic == RTSEMEVENT_MAGIC, ("u32Magic=%RX32 pThis=%p\n", pThis->u32Magic, pThis), VERR_INVALID_HANDLE);
return VINF_SUCCESS;
AssertMsgReturn(pThis->u32Magic == RTSEMEVENT_MAGIC, ("%p u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_PARAMETER);
int rc;
return rc;
#ifndef RTSEMEVENT_STRICT
return rtR0SemSolWaitGetResolution();