Fixed crash due to thread priority out of bonuds bug... not sure if I did this right, but it seems to fix the crash. Someone should probobly look at this.

svn path=/trunk/; revision=1370
This commit is contained in:
Phillip Susi 2000-09-24 23:55:21 +00:00
parent 08982a387e
commit 0ea51977f6

View file

@ -1,4 +1,4 @@
/* $Id: thread.c,v 1.54 2000/09/06 03:08:22 phreak Exp $ /* $Id: thread.c,v 1.55 2000/09/24 23:55:21 phreak Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -124,10 +124,9 @@ HANDLE STDCALL PsGetCurrentThreadId(VOID)
static VOID PsInsertIntoThreadList(KPRIORITY Priority, PETHREAD Thread) static VOID PsInsertIntoThreadList(KPRIORITY Priority, PETHREAD Thread)
{ {
// DPRINT("PsInsertIntoThreadList(Priority %x, Thread %x)\n",Priority, DPRINT("PsInsertIntoThreadList(Priority %x, Thread %x)\n",Priority,
// Thread); Thread);
// DPRINT("Offset %x\n", THREAD_PRIORITY_MAX + Priority); DPRINT("Offset %x\n", THREAD_PRIORITY_MAX + Priority);
InsertTailList(&PriorityListHead[THREAD_PRIORITY_MAX+Priority], InsertTailList(&PriorityListHead[THREAD_PRIORITY_MAX+Priority],
&Thread->Tcb.QueueListEntry); &Thread->Tcb.QueueListEntry);
PiNrRunnableThreads++; PiNrRunnableThreads++;
@ -443,14 +442,20 @@ KeSetPriorityThread (
{ {
KPRIORITY OldPriority; KPRIORITY OldPriority;
KIRQL oldIrql; KIRQL oldIrql;
OldPriority = Thread->Priority;
Thread->Priority = Priority;
KeAcquireSpinLock(&PiThreadListLock, &oldIrql); KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
RemoveEntryList(&Thread->QueueListEntry); // Truncate priority to the max value
PsInsertIntoThreadList(Thread->BasePriority, Priority = Priority > THREAD_PRIORITY_MAX ? THREAD_PRIORITY_MAX : Priority;
CONTAINING_RECORD(Thread,ETHREAD,Tcb)); OldPriority = Thread->Priority;
Thread->Priority = Priority;
// Remove thread from run queue, and plcae it back on using the new priority
// but only if it is already on the runqueue!
if( Thread->State == THREAD_STATE_RUNNABLE )
{
RemoveEntryList(&Thread->QueueListEntry);
PsInsertIntoThreadList(Thread->Priority,
CONTAINING_RECORD(Thread,ETHREAD,Tcb));
}
KeReleaseSpinLock(&PiThreadListLock, oldIrql); KeReleaseSpinLock(&PiThreadListLock, oldIrql);
return(OldPriority); return(OldPriority);
} }