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");
|
__asm__("cli\n\t");
|
||||||
|
|
||||||
DPRINT("NewIrql %x CurrentIrql %x\n",NewIrql,CurrentIrql);
|
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;
|
CurrentIrql = NewIrql;
|
||||||
HiSwitchIrql();
|
HiSwitchIrql();
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,16 @@ static VOID PsInsertIntoThreadList(KPRIORITY Priority, PETHREAD Thread)
|
||||||
KeReleaseSpinLock(&ThreadListLock,oldlvl);
|
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)
|
static PETHREAD PsScanThreadList(KPRIORITY Priority)
|
||||||
{
|
{
|
||||||
PLIST_ENTRY current_entry;
|
PLIST_ENTRY current_entry;
|
||||||
|
@ -134,7 +144,6 @@ VOID PsDispatchThread(VOID)
|
||||||
CurrentThread->Tcb.LastTick = GET_LARGE_INTEGER_LOW_PART(TickCount);
|
CurrentThread->Tcb.LastTick = GET_LARGE_INTEGER_LOW_PART(TickCount);
|
||||||
CurrentThread->Tcb.ThreadState = THREAD_STATE_RUNNING;
|
CurrentThread->Tcb.ThreadState = THREAD_STATE_RUNNING;
|
||||||
KeReleaseSpinLock(&ThreadListLock,irql);
|
KeReleaseSpinLock(&ThreadListLock,irql);
|
||||||
KeLowerIrql(PASSIVE_LEVEL);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Candidate != NULL)
|
if (Candidate != NULL)
|
||||||
|
@ -148,9 +157,8 @@ VOID PsDispatchThread(VOID)
|
||||||
|
|
||||||
CurrentThread = Candidate;
|
CurrentThread = Candidate;
|
||||||
|
|
||||||
KeReleaseSpinLock(&ThreadListLock,irql);
|
|
||||||
KeLowerIrql(PASSIVE_LEVEL);
|
|
||||||
HalTaskSwitch(&CurrentThread->Tcb);
|
HalTaskSwitch(&CurrentThread->Tcb);
|
||||||
|
KeReleaseSpinLock(&ThreadListLock,irql);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue