[NTOS:MM] Quick fix: use SIZE_T instead of ULONG, because ULONG is 32-bit and on...
[reactos.git] / ntoskrnl / ke / thrdobj.c
index cfccf0d..142ff18 100644 (file)
@@ -241,7 +241,7 @@ KeBoostPriorityThread(IN PKTHREAD Thread,
     {
         /* Lock the thread */
         KiAcquireThreadLock(Thread);
-        
+
         /* Check again, and make sure there's not already a boost */
         if ((Thread->Priority < LOW_REALTIME_PRIORITY) &&
             !(Thread->PriorityDecrement))
@@ -266,7 +266,7 @@ KeBoostPriorityThread(IN PKTHREAD Thread,
         /* Release thread lock */
         KiReleaseThreadLock(Thread);
     }
-    
+
     /* Release the dispatcher lokc */
     KiReleaseDispatcherLock(OldIrql);
 }
@@ -457,6 +457,7 @@ KeRundownThread(VOID)
     {
         /* Get the Mutant */
         Mutant = CONTAINING_RECORD(NextEntry, KMUTANT, MutantListEntry);
+        ASSERT_MUTANT(Mutant);
 
         /* Make sure it's not terminating with APCs off */
         if (Mutant->ApcDisable)
@@ -485,7 +486,7 @@ KeRundownThread(VOID)
         }
 
         /* Move on */
-        NextEntry = NextEntry->Flink;
+        NextEntry = Thread->MutantListHead.Flink;
     }
 
     /* Release the Lock */
@@ -529,7 +530,12 @@ KeStartThread(IN OUT PKTHREAD Thread)
     NodePrcb = KiProcessorBlock[Process->ThreadSeed];
 
     /* Calculate affinity mask */
+#ifdef _M_ARM
+    DbgBreakPoint();
+    Set = 0;
+#else
     Set = ~NodePrcb->MultiThreadProcessorSet;
+#endif
     Mask = (ULONG)(Node->ProcessorMask & Process->Affinity);
     Set &= Mask;
     if (Set) Mask = Set;
@@ -771,7 +777,7 @@ KeInitThread(IN OUT PKTHREAD Thread,
     PKTIMER Timer;
     NTSTATUS Status;
 
-    /* Initalize the Dispatcher Header */
+    /* Initialize the Dispatcher Header */
     Thread->Header.Type = ThreadObject;
     Thread->Header.ThreadControlFlags = 0;
     Thread->Header.DebugActive = FALSE;
@@ -802,8 +808,8 @@ KeInitThread(IN OUT PKTHREAD Thread,
     Thread->ServiceTable = KeServiceDescriptorTable;
 
     /* Setup APC Fields */
-    InitializeListHead(&Thread->ApcState.ApcListHead[0]);
-    InitializeListHead(&Thread->ApcState.ApcListHead[1]);
+    InitializeListHead(&Thread->ApcState.ApcListHead[KernelMode]);
+    InitializeListHead(&Thread->ApcState.ApcListHead[UserMode]);
     Thread->ApcState.Process = Process;
     Thread->ApcStatePointer[OriginalApcEnvironment] = &Thread->ApcState;
     Thread->ApcStatePointer[AttachedApcEnvironment] = &Thread->SavedApcState;
@@ -837,8 +843,9 @@ KeInitThread(IN OUT PKTHREAD Thread,
     TimerWaitBlock->WaitListEntry.Flink = &Timer->Header.WaitListHead;
     TimerWaitBlock->WaitListEntry.Blink = &Timer->Header.WaitListHead;
 
-    /* Set the TEB */
+    /* Set the TEB and process */
     Thread->Teb = Teb;
+    Thread->Process = Process;
 
     /* Check if we have a kernel stack */
     if (!KernelStack)
@@ -861,7 +868,7 @@ KeInitThread(IN OUT PKTHREAD Thread,
     Status = STATUS_SUCCESS;
     _SEH2_TRY
     {
-        /* Initalize the Thread Context */
+        /* Initialize the Thread Context */
         KiInitializeContextThread(Thread,
                                   SystemRoutine,
                                   StartRoutine,
@@ -883,7 +890,7 @@ KeInitThread(IN OUT PKTHREAD Thread,
     }
     _SEH2_END;
 
-    /* Set the Thread to initalized */
+    /* Set the Thread to initialized */
     Thread->State = Initialized;
     return Status;
 }