/** * Called For VM power off. * * @param pVM Pointer to the VM. */ void pdmR3ThreadDestroyAll(PVM pVM) { PUVM pUVM = pVM->pUVM; RTCritSectEnter(&pUVM->pdm.s.ListCritSect); PPDMTHREAD pThread = pUVM->pdm.s.pThreads; while (pThread) { PPDMTHREAD pNext = pThread->Internal.s.pNext; int rc2 = PDMR3ThreadDestroy(pThread, NULL); AssertRC(rc2); pThread = pNext; } Assert(!pUVM->pdm.s.pThreads && !pUVM->pdm.s.pThreadsTail); RTCritSectLeave(&pUVM->pdm.s.ListCritSect); }
/** * Closes a test file. * * @returns nothing. * @param pTestFile Pointer to the test file. */ static void tstPDMACStressTestFileClose(PPDMACTESTFILE pTestFile) { int rcThread; int rc; RTPrintf("Terminating I/O thread, please wait...\n"); /* Let the thread know that it should terminate. */ pTestFile->fRunning = false; /* Wait for the thread to terminate. */ rc = PDMR3ThreadDestroy(pTestFile->hThread, &rcThread); RTPrintf("Thread terminated with status code rc=%Rrc\n", rcThread); /* Free resources */ RTMemFree(pTestFile->paTasks); RTMemFree(pTestFile->paSegs); PDMR3AsyncCompletionEpClose(pTestFile->hEndpoint); PDMR3AsyncCompletionTemplateDestroy(pTestFile->pTemplate); }
/** * Destroys all threads associated with a driver. * * This function is called by PDMDriver when a driver is destroyed. * * @returns VBox status code of the first failure. * @param pVM Pointer to the VM. * @param pDrvIns The driver instance. */ int pdmR3ThreadDestroyDriver(PVM pVM, PPDMDRVINS pDrvIns) { int rc = VINF_SUCCESS; PUVM pUVM = pVM->pUVM; AssertPtr(pDrvIns); RTCritSectEnter(&pUVM->pdm.s.ListCritSect); PPDMTHREAD pThread = pUVM->pdm.s.pThreads; while (pThread) { PPDMTHREAD pNext = pThread->Internal.s.pNext; if ( pThread->Internal.s.enmType == PDMTHREADTYPE_DRIVER && pThread->u.Drv.pDrvIns == pDrvIns) { int rc2 = PDMR3ThreadDestroy(pThread, NULL); if (RT_FAILURE(rc2) && RT_SUCCESS(rc)) rc = rc2; } pThread = pNext; } RTCritSectLeave(&pUVM->pdm.s.ListCritSect); return rc; }