From 67d68774ab18d932f4d0644b6abdb1233bf7a6fa Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 31 Aug 2004 06:08:38 +0000 Subject: [PATCH] - Revise order of PsInitializeThread to insert the thread to the lists after *all* the fields are initialized and while holding the PiThreadListLock lock acquired. svn path=/trunk/; revision=10747 --- reactos/ntoskrnl/ps/create.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/reactos/ntoskrnl/ps/create.c b/reactos/ntoskrnl/ps/create.c index ae767db7ed4..7d64a116c2a 100644 --- a/reactos/ntoskrnl/ps/create.c +++ b/reactos/ntoskrnl/ps/create.c @@ -1,4 +1,4 @@ -/* $Id: create.c,v 1.79 2004/08/15 16:39:10 chorns Exp $ +/* $Id: create.c,v 1.80 2004/08/31 06:08:38 navaraf Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -475,11 +475,6 @@ PsInitializeThread(HANDLE ProcessHandle, KeInitializeThread(&Process->Pcb, &Thread->Tcb, First); Thread->ThreadsProcess = Process; - /* - * FIXME: What lock protects this? - */ - InsertTailList(&Thread->ThreadsProcess->ThreadListHead, - &Thread->Tcb.ProcessThreadListEntry); InitializeListHead(&Thread->TerminationPortList); KeInitializeSpinLock(&Thread->ActiveTimerListLock); InitializeListHead(&Thread->IrpList); @@ -490,11 +485,6 @@ PsInitializeThread(HANDLE ProcessHandle, Thread->Win32Thread = 0; DPRINT("Thread->Cid.UniqueThread %d\n",Thread->Cid.UniqueThread); - *ThreadPtr = Thread; - - KeAcquireSpinLock(&PiThreadListLock, &oldIrql); - InsertTailList(&PiThreadListHead, &Thread->Tcb.ThreadListEntry); - KeReleaseSpinLock(&PiThreadListLock, oldIrql); Thread->Tcb.BasePriority = (CHAR)Thread->ThreadsProcess->Pcb.BasePriority; Thread->Tcb.Priority = Thread->Tcb.BasePriority; @@ -509,6 +499,14 @@ PsInitializeThread(HANDLE ProcessHandle, Thread->LpcExitThreadCalled = FALSE; Thread->LpcReceivedMsgIdValid = FALSE; + KeAcquireSpinLock(&PiThreadListLock, &oldIrql); + InsertTailList(&Thread->ThreadsProcess->ThreadListHead, + &Thread->Tcb.ProcessThreadListEntry); + InsertTailList(&PiThreadListHead, &Thread->Tcb.ThreadListEntry); + KeReleaseSpinLock(&PiThreadListLock, oldIrql); + + *ThreadPtr = Thread; + return(STATUS_SUCCESS); }