VirtualBox

Changeset 22128 in vbox


Ignore:
Timestamp:
Aug 10, 2009 11:56:08 AM (15 years ago)
Author:
vboxsync
Message:

VBoxGuest.cpp: RTSpinlockAcquireNoInts vs RTSemEventMultiSignal on solaris.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp

    r21632 r22128  
    1919 * additional information or have any questions.
    2020 */
    21 
    2221
    2322
     
    930929static int VBoxGuestCommonIOCtl_CancelAllWaitEvents(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession)
    931930{
    932     RTSPINLOCKTMP   Tmp = RTSPINLOCKTMP_INITIALIZER;
    933     PVBOXGUESTWAIT  pWait;
    934     int             rc = 0;
     931    RTSPINLOCKTMP           Tmp   = RTSPINLOCKTMP_INITIALIZER;
     932#if defined(RT_OS_SOLARIS)
     933    RTTHREADPREEMPTSTATE    State = RTTHREADPREEMPTSTATE_INITIALIZER;
     934#endif
     935    PVBOXGUESTWAIT          pWait;
     936    int                     rc = 0;
    935937
    936938    Log(("VBoxGuestCommonIOCtl: CANCEL_ALL_WAITEVENTS\n"));
     
    938940    /*
    939941     * Walk the event list and wake up anyone with a matching session.
    940      */
     942     *
     943     * Note! On Solaris we have to do really ugly stuff here because
     944     *       RTSemEventMultiSignal cannot be called with interrupts disabled.
     945     *       The hack is racy, but what we can we do... (Eliminate this
     946     *       termination hack, perhaps?)
     947     */
     948#if defined(RT_OS_SOLARIS)
     949    RTThreadPreemptDisable(&State);
     950    RTSpinlockAcquireNoInts(pDevExt->EventSpinlock, &Tmp);
     951    do
     952    {
     953        for (pWait = pDevExt->WaitList.pHead; pWait; pWait = pWait->pNext)
     954            if (    pWait->pSession   == pSession
     955                &&  pWait->fResEvents != UINT32_MAX)
     956            {
     957                RTSEMEVENTMULTI     hEvent;
     958                pWait->fResEvents = UINT32_MAX;
     959                RTSpinlockReleaseNoInts(pDevExt->EventSpinlock, &Tmp);
     960                /* HACK ALRET! This races wakeup + reuse! */
     961                rc |= RTSemEventMultiSignal(hEvent);
     962                RTSpinlockAcquireNoInts(pDevExt->EventSpinlock, &Tmp);
     963                break;
     964            }
     965    } while (pWait);
     966    RTSpinlockReleaseNoInts(pDevExt->EventSpinlock, &Tmp);
     967    RTThreadPreemptDisable(&State);
     968#else
    941969    RTSpinlockAcquireNoInts(pDevExt->EventSpinlock, &Tmp);
    942970    for (pWait = pDevExt->WaitList.pHead; pWait; pWait = pWait->pNext)
     
    947975        }
    948976    RTSpinlockReleaseNoInts(pDevExt->EventSpinlock, &Tmp);
     977#endif
    949978    Assert(rc == 0);
    950979
     
    16291658    /*
    16301659     * Enter the spinlock and check if it's our IRQ or not.
    1631      */
     1660     *
     1661     * Note! Solaris cannot do RTSemEventMultiSignal with interrupts disabled
     1662     *       so we're entering the spinlock without disabling them.  This works
     1663     *       fine as long as we never called in a nested fashion.
     1664     */
     1665#if defined(RT_OS_SOLARIS)
     1666    RTSpinlockAcquire(pDevExt->EventSpinlock, &Tmp);
     1667#else
    16321668    RTSpinlockAcquireNoInts(pDevExt->EventSpinlock, &Tmp);
     1669#endif
    16331670    fOurIrq = pDevExt->pVMMDevMemory->V.V1_04.fHaveEvents;
    16341671    if (fOurIrq)
     
    17031740     * Do this outside the spinlock to prevent some recursive spinlocking.
    17041741     */
     1742#if defined(RT_OS_SOLARIS)
     1743    RTSpinlockRelease(pDevExt->EventSpinlock, &Tmp);
     1744#else
    17051745    RTSpinlockReleaseNoInts(pDevExt->EventSpinlock, &Tmp);
     1746#endif
    17061747
    17071748    if (fMousePositionChanged)
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