VirtualBox

Changeset 30552 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Jul 1, 2010 12:24:21 PM (14 years ago)
Author:
vboxsync
Message:

Runtime/r0drv/solaris: SemEventMulti fix.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/solaris/semeventmulti-r0drv-solaris.c

    r30491 r30552  
    5959    /** Set if the event object is signaled. */
    6060    uint8_t volatile    fSignaled;
    61     /** The number of threads in the process of waking up. */
     61    /** The number of threads in the process of waking up, doubles up as a ref counter. */
    6262    uint32_t volatile   cWaking;
     63    /** Object version indicating a valid signal event occurred. */
     64    uint32_t volatile   u32Version;
    6365    /** The Solaris mutex protecting this structure and pairing up the with the cv. */
    6466    kmutex_t            Mtx;
     
    9092        pThis->cWaking = 0;
    9193        pThis->fSignaled = 0;
     94        pThis->u32Version = 0;
    9295        mutex_init(&pThis->Mtx, "IPRT Multiple Release Event Semaphore", MUTEX_DRIVER, (void *)ipltospl(DISP_LEVEL));
    9396        cv_init(&pThis->Cnd, "IPRT CV", CV_DRIVER, NULL);
     
    168171        ASMAtomicXchgU32(&pThis->cWaking, pThis->cWaking + pThis->cWaiters);
    169172        ASMAtomicXchgU32(&pThis->cWaiters, 0);
     173        ASMAtomicIncU32(&pThis->u32Version);
    170174        cv_broadcast(&pThis->Cnd);
    171175    }
     
    265269    else
    266270    {
     271        ASMAtomicIncU32(&pThis->cWaiters);
    267272        for (;;)
    268273        {
    269             uint32_t cWakingBeforeWait = ASMAtomicUoReadU32((uint32_t volatile *)&pThis->cWaking);
    270             ASMAtomicIncU32(&pThis->cWaiters);
     274            uint32_t u32VersionBeforeWait = ASMAtomicUoReadU32((uint32_t volatile *)&pThis->u32Version);
    271275            rc = rtSemEventMultiWaitWorker(pThis, cMillies, fInterruptible);
     276            uint32_t u32Version = ASMAtomicUoReadU32((uint32_t volatile *)&pThis->u32Version);
    272277            if (rc > 0)
    273278            {
    274                 /* Retured due to call to cv_signal() or cv_broadcast() */
    275279                if (RT_LIKELY(pThis->u32Magic == RTSEMEVENTMULTI_MAGIC))
    276280                {
    277                     uint32_t cWaking = ASMAtomicUoReadU32((uint32_t volatile *)&pThis->cWaking);
    278                     if (cWaking > cWakingBeforeWait)
     281                    /* Retured due to call to cv_signal() or cv_broadcast() */
     282                    if (u32Version > u32VersionBeforeWait)
    279283                    {
    280284                        rc = VINF_SUCCESS;
     
    290294                else
    291295                {
     296                    /* We're being destroyed */
    292297                    rc = VERR_SEM_DESTROYED;
    293298                    if (!ASMAtomicDecU32(&pThis->cWaking))
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette