VirtualBox

Changeset 40806 in vbox for trunk/src/VBox/VMM/VMMR0


Ignore:
Timestamp:
Apr 6, 2012 9:05:19 PM (13 years ago)
Author:
vboxsync
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/VMM/VMMR0/GVMMR0.cpp

    r40595 r40806  
    416416                                         &pGVMM->aHostCpus[iCpu]);
    417417                    if (RT_SUCCESS(rc))
    418                         rc = RTSpinlockCreate(&pGVMM->aHostCpus[iCpu].Ppt.hSpinlock);
     418                        rc = RTSpinlockCreate(&pGVMM->aHostCpus[iCpu].Ppt.hSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "GVMM/CPU");
    419419                    if (RT_FAILURE(rc))
    420420                    {
     
    21762176     * Do the house keeping.
    21772177     */
    2178     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    2179     RTSpinlockAcquireNoInts(pCpu->Ppt.hSpinlock, &Tmp);
     2178    RTSpinlockAcquire(pCpu->Ppt.hSpinlock);
    21802179
    21812180    if (++pCpu->Ppt.iTickHistorization >= pCpu->Ppt.cTicksHistoriziationInterval)
     
    21972196                uHistMaxHz = pCpu->Ppt.aHzHistory[i];
    21982197        if (uHistMaxHz == pCpu->Ppt.uTimerHz)
    2199             RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock, &Tmp);
     2198            RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock);
    22002199        else if (uHistMaxHz)
    22012200        {
     
    22142213            else
    22152214                pCpu->Ppt.cTicksHistoriziationInterval = 1;
    2216             RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock, &Tmp);
     2215            RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock);
    22172216
    22182217            /*SUPR0Printf("Cpu%u: change to %u Hz / %u ns\n", pCpu->idxCpuSet, uHistMaxHz, cNsInterval);*/
     
    22272226            pCpu->Ppt.uTimerHz    = 0;
    22282227            pCpu->Ppt.cNsInterval = 0;
    2229             RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock, &Tmp);
     2228            RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock);
    22302229
    22312230            /*SUPR0Printf("Cpu%u: stopping (%u Hz)\n", pCpu->idxCpuSet, uHistMaxHz);*/
     
    22342233    }
    22352234    else
    2236         RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock, &Tmp);
     2235        RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock);
    22372236}
    22382237#endif /* GVMM_SCHED_WITH_PPT */
     
    22812280                    && !pCpu->Ppt.fStarting /* solaris paranoia */))
    22822281    {
    2283         RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    2284         RTSpinlockAcquireNoInts(pCpu->Ppt.hSpinlock, &Tmp);
     2282        RTSpinlockAcquire(pCpu->Ppt.hSpinlock);
    22852283
    22862284        pCpu->Ppt.uDesiredHz = uHz;
     
    23022300        }
    23032301
    2304         RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock, &Tmp);
     2302        RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock);
    23052303
    23062304        if (cNsInterval)
     
    23102308            AssertRC(rc);
    23112309
    2312             RTSpinlockAcquireNoInts(pCpu->Ppt.hSpinlock, &Tmp);
     2310            RTSpinlockAcquire(pCpu->Ppt.hSpinlock);
    23132311            if (RT_FAILURE(rc))
    23142312                pCpu->Ppt.fStarted = false;
    23152313            pCpu->Ppt.fStarting = false;
    2316             RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock, &Tmp);
     2314            RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock);
    23172315        }
    23182316    }
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