VirtualBox

Changeset 7232 in vbox


Ignore:
Timestamp:
Mar 3, 2008 11:13:15 AM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
28564
Message:

Get rid of the no longer needed hacky wait for the async I/O threads to exit code, and replace it with the official way to wait for thread termination.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/DevATA.cpp

    r7151 r7232  
    52735273    {
    52745274        uint64_t    u64Start = RTTimeMilliTS();
    5275         bool        fAllDone;
    5276         for (;;)
    5277         {
    5278             /* check */
    5279             fAllDone = true;
    5280             for (uint32_t i = 0; i < RT_ELEMENTS(pData->aCts) && fAllDone; i++)
    5281                 fAllDone &= (pData->aCts[i].AsyncIOThread == NIL_RTTHREAD);
    5282 
    5283             if (    fAllDone
    5284                 ||  RTTimeMilliTS() - u64Start >= 5000)
    5285                 break;
    5286 
    5287             /* Sleep for a bit. */
    5288             RTThreadSleep(100);
    5289         }
    5290         AssertMsg(fAllDone, ("Some of the async I/O threads are still running!\n"));
     5275        int rc2 = VINF_SUCCESS;
     5276        for (unsigned i = 0; i < RT_ELEMENTS(pData->aCts); i++)
     5277        {
     5278            /* Wait for at most 5 seconds, and if that is elapsed for 100msec
     5279             * per remaining thread. Just to be on the safe side. */
     5280            rc = RTThreadWait(pData->aCts[i].AsyncIOThread,
     5281                              RT_MAX(RTTimeMilliTS() - u64Start + 5000, 100),
     5282                              NULL);
     5283            if (VBOX_FAILURE(rc) && rc != VERR_INVALID_HANDLE)
     5284                rc2 = rc;
     5285        }
     5286        AssertMsg(VBOX_SUCCESS(rc2), ("Some of the async I/O threads are still running!\n"));
    52915287    }
    52925288    else
     
    60786074        AssertRC(rc);
    60796075        ataAsyncIOClearRequests(pCtl);
    6080         rc = RTThreadCreate(&pCtl->AsyncIOThread, ataAsyncIOLoop, (void *)pCtl, 128*1024, RTTHREADTYPE_IO, 0, "ATA");
     6076        rc = RTThreadCreate(&pCtl->AsyncIOThread, ataAsyncIOLoop, (void *)pCtl, 128*1024, RTTHREADTYPE_IO, RTTHREADFLAGS_WAITABLE, "ATA");
    60816077        AssertRC(rc);
    60826078        Assert(pCtl->AsyncIOThread != NIL_RTTHREAD && pCtl->AsyncIOSem != NIL_RTSEMEVENT && pCtl->SuspendIOSem != NIL_RTSEMEVENT && pCtl->AsyncIORequestMutex != NIL_RTSEMMUTEX);
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