VirtualBox

Changeset 81561 in vbox


Ignore:
Timestamp:
Oct 28, 2019 12:44:44 PM (5 years ago)
Author:
vboxsync
Message:

PDMR3Task: The task thread (pdmR3TaskThread) should quit eventually when shutdown is signalled. Old code just keep processing tasks till nothing was pending. Will now do three loops trying to quice things and assert before exiting. bugref:9218

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/PDMR3Task.cpp

    r81488 r81561  
    225225            if (iTask == 0)
    226226                break;
     227            uint32_t cShutdown = 3;
    227228            do
    228229            {
     
    282283                iTask = ASMBitFirstSetU64(fTriggered);
    283284            } while (iTask != 0);
     285
     286            /*
     287             * If we're shutting down, we'll try drain the pending tasks by
     288             * looping three more times before just quitting.  We don't want
     289             * to get stuck here if some stuff is misbehaving.
     290             */
     291            if (!ASMAtomicReadBool(&pTaskSet->fShutdown))
     292            { /* likely */ }
     293            else if (--cShutdown == 0)
     294                break;
    284295        }
    285296
    286297        /*
    287          * Wait.
     298         * Wait unless we're shutting down.
    288299         */
    289         if (pTaskSet->fRZEnabled)
    290             SUPSemEventWaitNoResume(pTaskSet->pVM->pSession, pTaskSet->hEventR0, RT_MS_15SEC);
    291         else
    292             RTSemEventWaitNoResume(pTaskSet->hEventR3, RT_MS_15SEC);
    293     }
     300        if (!ASMAtomicReadBool(&pTaskSet->fShutdown))
     301        {
     302            if (pTaskSet->fRZEnabled)
     303                SUPSemEventWaitNoResume(pTaskSet->pVM->pSession, pTaskSet->hEventR0, RT_MS_15SEC);
     304            else
     305                RTSemEventWaitNoResume(pTaskSet->hEventR3, RT_MS_15SEC);
     306        }
     307    }
     308
     309    /*
     310     * Complain about pending tasks.
     311     */
     312    uint64_t const fTriggered = ASMAtomicReadU64(&pTaskSet->fTriggered);
     313    AssertLogRelMsg(fTriggered == 0, ("fTriggered=%#RX64 - %u %s\n", fTriggered, ASMBitFirstSetU64(fTriggered) - 1,
     314                                      pTaskSet->aTasks[ASMBitFirstSetU64(fTriggered) - 1].pszName));
    294315
    295316    return VINF_SUCCESS;
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