KD System Rewrite:
[reactos.git] / reactos / ntoskrnl / ke / kthread.c
index 1f5183f..709f45d 100644 (file)
@@ -782,7 +782,11 @@ KeInitializeThread(PKPROCESS Process,
     /* Set the Thread to initalized */
     Thread->State = Initialized;
        
-    /* Insert the Thread into the Process's Thread List */
+    /* 
+     * Insert the Thread into the Process's Thread List 
+     * Note, this is the KTHREAD Thread List. It is removed in
+     * ke/kthread.c!KeTerminateThread.
+     */
     InsertTailList(&Process->ThreadListHead, &Thread->ThreadListEntry);
     DPRINT("Thread initalized\n");
 }
@@ -1137,6 +1141,9 @@ KeTerminateThread(IN KPRIORITY Increment)
     /* Lock the Dispatcher Database and the APC Queue */
     DPRINT("Terminating\n");
     OldIrql = KeAcquireDispatcherDatabaseLock();
+
+    /* Remove the thread from the list */
+    RemoveEntryList(&Thread->ThreadListEntry);
     
     /* Insert into the Reaper List */
     DPRINT("List: %p\n", PspReaperList);