mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Fixed race in task-switching code
svn path=/trunk/; revision=134
This commit is contained in:
parent
3ecc11334b
commit
e007300ee0
2 changed files with 17 additions and 4 deletions
|
@ -106,7 +106,12 @@ VOID KeLowerIrql(KIRQL NewIrql)
|
|||
__asm__("cli\n\t");
|
||||
|
||||
DPRINT("NewIrql %x CurrentIrql %x\n",NewIrql,CurrentIrql);
|
||||
assert(NewIrql <= CurrentIrql);
|
||||
if (NewIrql > CurrentIrql)
|
||||
{
|
||||
DbgPrint("NewIrql %x CurrentIrql %x\n",NewIrql,CurrentIrql);
|
||||
KeDumpStackFrames(0);
|
||||
for(;;);
|
||||
}
|
||||
CurrentIrql = NewIrql;
|
||||
HiSwitchIrql();
|
||||
}
|
||||
|
|
|
@ -74,6 +74,16 @@ static VOID PsInsertIntoThreadList(KPRIORITY Priority, PETHREAD Thread)
|
|||
KeReleaseSpinLock(&ThreadListLock,oldlvl);
|
||||
}
|
||||
|
||||
VOID PsBeginThread(PKSTART_ROUTINE StartRoutine, PVOID StartContext)
|
||||
{
|
||||
NTSTATUS Ret;
|
||||
|
||||
KeReleaseSpinLock(&ThreadListLock,PASSIVE_LEVEL);
|
||||
Ret = StartRoutine(StartContext);
|
||||
PsTerminateSystemThread(Ret);
|
||||
for(;;);
|
||||
}
|
||||
|
||||
static PETHREAD PsScanThreadList(KPRIORITY Priority)
|
||||
{
|
||||
PLIST_ENTRY current_entry;
|
||||
|
@ -134,7 +144,6 @@ VOID PsDispatchThread(VOID)
|
|||
CurrentThread->Tcb.LastTick = GET_LARGE_INTEGER_LOW_PART(TickCount);
|
||||
CurrentThread->Tcb.ThreadState = THREAD_STATE_RUNNING;
|
||||
KeReleaseSpinLock(&ThreadListLock,irql);
|
||||
KeLowerIrql(PASSIVE_LEVEL);
|
||||
return;
|
||||
}
|
||||
if (Candidate != NULL)
|
||||
|
@ -148,9 +157,8 @@ VOID PsDispatchThread(VOID)
|
|||
|
||||
CurrentThread = Candidate;
|
||||
|
||||
KeReleaseSpinLock(&ThreadListLock,irql);
|
||||
KeLowerIrql(PASSIVE_LEVEL);
|
||||
HalTaskSwitch(&CurrentThread->Tcb);
|
||||
KeReleaseSpinLock(&ThreadListLock,irql);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue