VirtualBox

Changeset 19826 in vbox for trunk/src/VBox/Runtime/r0drv


Ignore:
Timestamp:
May 19, 2009 2:26:00 PM (16 years ago)
Author:
vboxsync
Message:

Implemented a non-blocking RTMpPokeCpu for Windows hosts.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/nt/mp-r0drv-nt.cpp

    r15896 r19826  
    330330}
    331331
     332static KDPC aPokeDpcs[MAXIMUM_PROCESSORS] = {0};
     333static bool fPokeDPCsInitialized = false;
     334
     335static VOID rtMpNtPokeCpuDummy(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
     336{
     337    NOREF(Dpc);
     338    NOREF(DeferredContext);
     339    NOREF(SystemArgument1);
     340    NOREF(SystemArgument2);
     341}
     342
     343
     344RTDECL(int) RTMpPokeCpu(RTCPUID idCpu)
     345{
     346    if (!RTMpIsCpuOnline(idCpu))
     347        return !RTMpIsCpuPossible(idCpu)
     348              ? VERR_CPU_NOT_FOUND
     349              : VERR_CPU_OFFLINE;
     350
     351    if (!fPokeDPCsInitialized)
     352    {
     353        for (unsigned i = 0; i < RT_ELEMENTS(aPokeDpcs); i++)
     354        {
     355            KeInitializeDpc(&aPokeDpcs[i], rtmpNtDPCWrapper, NULL);
     356            KeSetImportanceDpc(&aPokeDpcs[i], HighImportance);
     357            KeSetTargetProcessorDpc(&aPokeDpcs[i], (int)i);
     358        }
     359        fPokeDPCsInitialized = true;
     360    }
     361
     362    /* Raise the IRQL to DISPATCH_LEVEL so we can't be rescheduled to another cpu.
     363     * KeInsertQueueDpc must also be executed at IRQL >= DISPATCH_LEVEL.
     364     */
     365    KIRQL oldIrql;
     366    KeRaiseIrql(DISPATCH_LEVEL, &oldIrql);
     367
     368    /* Assuming here that high importance DPCs will be delivered immediately; or at least an IPI will be sent immediately.
     369     * Todo: verify!
     370     */
     371    BOOLEAN ret = KeInsertQueueDpc(&aPokeDpcs[idCpu], 0, 0);
     372    Assert(ret);
     373
     374    KeLowerIrql(oldIrql);
     375    return VINF_SUCCESS;
     376}
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