VirtualBox

Ignore:
Timestamp:
Apr 6, 2012 9:05:19 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
77321
Message:

RTSpinlock: Redid the interface, eliminating NoInts and Tmp. Whether a spinlock is interrupt safe or not is now defined at creation time, preventing stupid bugs arrising from calling the wrong acquire and/or release methods somewhere. The saved flags are stored in the spinlock strucutre, eliminating the annoying Tmp variable. Needs testing on each platform before fixing the build burn.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/darwin/SUPDrv-darwin.cpp

    r37970 r40806  
    239239             */
    240240            memset(g_apSessionHashTab, 0, sizeof(g_apSessionHashTab)); /* paranoia */
    241             rc = RTSpinlockCreate(&g_Spinlock);
     241            rc = RTSpinlockCreate(&g_Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxDrvDarwin");
    242242            if (RT_SUCCESS(rc))
    243243            {
     
    370370        RTPROCESS       Process = RTProcSelf();
    371371        unsigned        iHash = SESSION_HASH(Process);
    372         RTSPINLOCKTMP   Tmp = RTSPINLOCKTMP_INITIALIZER;
    373         RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);
     372        RTSpinlockAcquire(g_Spinlock);
    374373
    375374        pSession = g_apSessionHashTab[iHash];
     
    393392            rc = VERR_GENERAL_FAILURE;
    394393
    395         RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     394        RTSpinlockReleaseNoInts(g_Spinlock);
    396395#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
    397396        kauth_cred_unref(&pCred);
     
    442441static int VBoxDrvDarwinIOCtl(dev_t Dev, u_long iCmd, caddr_t pData, int fFlags, struct proc *pProcess)
    443442{
    444     RTSPINLOCKTMP       Tmp = RTSPINLOCKTMP_INITIALIZER;
    445443    const RTPROCESS     Process = proc_pid(pProcess);
    446444    const unsigned      iHash = SESSION_HASH(Process);
     
    450448     * Find the session.
    451449     */
    452     RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);
     450    RTSpinlockAcquire(g_Spinlock);
    453451    pSession = g_apSessionHashTab[iHash];
    454452    if (pSession && pSession->Process != Process)
     
    457455        while (pSession && pSession->Process != Process);
    458456    }
    459     RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     457    RTSpinlockReleaseNoInts(g_Spinlock);
    460458    if (!pSession)
    461459    {
     
    982980                 */
    983981                unsigned iHash = SESSION_HASH(m_pSession->Process);
    984                 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    985                 RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);
     982                RTSpinlockAcquire(g_Spinlock);
    986983
    987984                PSUPDRVSESSION pCur = g_apSessionHashTab[iHash];
     
    1002999                    rc = VERR_ALREADY_LOADED;
    10031000
    1004                 RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     1001                RTSpinlockReleaseNoInts(g_Spinlock);
    10051002                if (RT_SUCCESS(rc))
    10061003                {
     
    10341031     */
    10351032    const unsigned  iHash = SESSION_HASH(Process);
    1036     RTSPINLOCKTMP   Tmp = RTSPINLOCKTMP_INITIALIZER;
    1037     RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);
     1033    RTSpinlockAcquire(g_Spinlock);
    10381034    PSUPDRVSESSION  pSession = g_apSessionHashTab[iHash];
    10391035    if (pSession)
     
    10651061        }
    10661062    }
    1067     RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     1063    RTSpinlockReleaseNoInts(g_Spinlock);
    10681064    if (!pSession)
    10691065    {
Note: See TracChangeset for help on using the changeset viewer.

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