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++;
@ -444,13 +443,19 @@ KeSetPriorityThread (
KPRIORITY OldPriority; KPRIORITY OldPriority;
KIRQL oldIrql; KIRQL oldIrql;
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
// Truncate priority to the max value
Priority = Priority > THREAD_PRIORITY_MAX ? THREAD_PRIORITY_MAX : Priority;
OldPriority = Thread->Priority; OldPriority = Thread->Priority;
Thread->Priority = Priority; Thread->Priority = Priority;
// Remove thread from run queue, and plcae it back on using the new priority
KeAcquireSpinLock(&PiThreadListLock, &oldIrql); // but only if it is already on the runqueue!
RemoveEntryList(&Thread->QueueListEntry); if( Thread->State == THREAD_STATE_RUNNABLE )
PsInsertIntoThreadList(Thread->BasePriority, {
CONTAINING_RECORD(Thread,ETHREAD,Tcb)); RemoveEntryList(&Thread->QueueListEntry);
PsInsertIntoThreadList(Thread->Priority,
CONTAINING_RECORD(Thread,ETHREAD,Tcb));
}
KeReleaseSpinLock(&PiThreadListLock, oldIrql); KeReleaseSpinLock(&PiThreadListLock, oldIrql);
return(OldPriority); return(OldPriority);
} }