diff --git a/ntoskrnl/include/internal/ke_x.h b/ntoskrnl/include/internal/ke_x.h index ae431649773..b0a9123461d 100644 --- a/ntoskrnl/include/internal/ke_x.h +++ b/ntoskrnl/include/internal/ke_x.h @@ -423,6 +423,8 @@ KiSetThreadSwapBusy(IN PKTHREAD Thread) { /* Make sure nobody already set it */ ASSERT(Thread->SwapBusy == FALSE); + ASSERT(KeGetCurrentIrql() >= DISPATCH_LEVEL); + ASSERT(Thread == KeGetCurrentThread()); /* Set it ourselves */ Thread->SwapBusy = TRUE; diff --git a/ntoskrnl/ke/amd64/stubs.c b/ntoskrnl/ke/amd64/stubs.c index b4e6377a138..a2e0f426c99 100644 --- a/ntoskrnl/ke/amd64/stubs.c +++ b/ntoskrnl/ke/amd64/stubs.c @@ -107,6 +107,8 @@ KiIdleLoop(VOID) /* Now loop forever */ while (TRUE) { + ASSERT(KeGetCurrentThread()->SwapBusy == FALSE); + /* Start of the idle loop: disable interrupts */ _enable(); YieldProcessor(); @@ -131,6 +133,9 @@ KiIdleLoop(VOID) /* Enable interrupts */ _enable(); + // Do we need this? + KiSetThreadSwapBusy(Prcb->IdleThread); + /* Capture current thread data */ OldThread = Prcb->CurrentThread; NewThread = Prcb->NextThread;