#endif
jz CheckSchedule
+ /* Raise to DISPATCH_LEVEL */
+ mov ecx, DISPATCH_LEVEL
+ call @KfRaiseIrql@4
+ mov edi, eax
+
/* Handle the above */
lea ecx, [ebx+KPCR_PRCB_DATA]
call @KiRetireDpcList@4
+ /* Lower IRQL */
+ mov ecx, edi
+ call @KfLowerIrql@4
+
CheckSchedule:
/* Check if a next thread is queued */
cmp dword ptr [ebx+KPCR_PRCB_NEXT_THREAD], 0
</directory>
<directory name="ps">
<file>debug.c</file>
- <file>idle.c</file>
<file>job.c</file>
<file>kill.c</file>
<file>notify.c</file>
+++ /dev/null
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * FILE: ntoskrnl/ps/idle.c
- * PURPOSE: Using idle time
- *
- * PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
- * David Welch (welch@cwcom.net)
- */
-
-/* INCLUDES *****************************************************************/
-
-#include <ntoskrnl.h>
-#define NDEBUG
-#include <internal/debug.h>
-
-#if defined (ALLOC_PRAGMA)
-#pragma alloc_text(INIT, PsInitIdleThread)
-#endif
-
-/* FUNCTIONS *****************************************************************/
-
-/** System idle thread procedure
- *
- */
-VOID STDCALL
-PsIdleThreadMain(PVOID Context)
-{
- KIRQL oldlvl;
-
- PKPRCB Prcb = KeGetCurrentPrcb();
-
- for(;;)
- {
- if (Prcb->DpcData[0].DpcQueueDepth > 0)
- {
- KeRaiseIrql(DISPATCH_LEVEL,&oldlvl);
- KiDispatchInterrupt();
- KeLowerIrql(oldlvl);
- }
-
- NtYieldExecution();
-
- Ke386HaltProcessor();
- }
-}
-
-/*
- * HACK-O-RAMA
- * Antique vestigial code left alive for the sole purpose of First/Idle Thread
- * creation until I can merge my fix for properly creating them.
- */
-NTSTATUS
-NTAPI
-PsInitializeIdleOrFirstThread(PEPROCESS Process,
- PETHREAD* ThreadPtr,
- PKSTART_ROUTINE StartRoutine,
- KPROCESSOR_MODE AccessMode,
- BOOLEAN First)
-{
- PETHREAD Thread;
- PVOID KernelStack;
-
- Thread = ExAllocatePool(NonPagedPool, sizeof(ETHREAD));
- RtlZeroMemory(Thread, sizeof(ETHREAD));
- Thread->ThreadsProcess = Process;
- if (First)
- {
- KernelStack = P0BootStack;
- }
- else
- {
- KernelStack = (PVOID)((ULONG_PTR)MmCreateKernelStack(FALSE) +
- KERNEL_STACK_SIZE);
- }
- KeInitializeThread(&Process->Pcb,
- &Thread->Tcb,
- PspSystemThreadStartup,
- StartRoutine,
- NULL,
- NULL,
- NULL,
- KernelStack);
- InitializeListHead(&Thread->IrpList);
- *ThreadPtr = Thread;
- return STATUS_SUCCESS;
-}
-
-/*
- * HACK-O-RAMA
- * Antique vestigial code left alive for the sole purpose of First/Idle Thread
- * creation until I can merge my fix for properly creating them.
- */
-VOID
-INIT_FUNCTION
-NTAPI
-PsInitIdleThread(VOID)
-{
- PETHREAD IdleThread;
- KIRQL oldIrql;
-
- PsInitializeIdleOrFirstThread(PsIdleProcess,
- &IdleThread,
- PsIdleThreadMain,
- KernelMode,
- FALSE);
-
- oldIrql = KiAcquireDispatcherLock ();
- KiReadyThread(&IdleThread->Tcb);
- KiReleaseDispatcherLock(oldIrql);
-
- KeGetCurrentPrcb()->IdleThread = &IdleThread->Tcb;
- KeSetPriorityThread(&IdleThread->Tcb, LOW_PRIORITY);
- KeSetAffinityThread(&IdleThread->Tcb, 1 << 0);
-}
/* FUNCTIONS ***************************************************************/
+VOID
+FASTCALL
+KiIdleLoop(VOID);
+
+/* FUNCTIONS *****************************************************************/
+
+/*
+ * HACK-O-RAMA
+ * Antique vestigial code left alive for the sole purpose of First/Idle Thread
+ * creation until I can merge my fix for properly creating them.
+ */
+VOID
+INIT_FUNCTION
+NTAPI
+PsInitHackThread(VOID)
+{
+ PETHREAD IdleThread;
+ KIRQL oldIrql;
+
+ IdleThread = ExAllocatePool(NonPagedPool, sizeof(ETHREAD));
+ RtlZeroMemory(IdleThread, sizeof(ETHREAD));
+ IdleThread->ThreadsProcess = PsIdleProcess;
+ KeInitializeThread(&PsIdleProcess->Pcb,
+ &IdleThread->Tcb,
+ PspSystemThreadStartup,
+ (PVOID)KiIdleLoop,
+ NULL,
+ NULL,
+ NULL,
+ (PVOID)((ULONG_PTR)MmCreateKernelStack(FALSE) +
+ KERNEL_STACK_SIZE));
+ InitializeListHead(&IdleThread->IrpList);
+
+ oldIrql = KiAcquireDispatcherLock ();
+ KiReadyThread(&IdleThread->Tcb);
+ KiReleaseDispatcherLock(oldIrql);
+
+ KeGetCurrentPrcb()->IdleThread = &IdleThread->Tcb;
+ KeSetPriorityThread(&IdleThread->Tcb, LOW_PRIORITY);
+ KeSetAffinityThread(&IdleThread->Tcb, 1 << 0);
+}
+
+/*
+ * HACK-O-RAMA
+ * Antique vestigial code left alive for the sole purpose of First/Idle Thread
+ * creation until I can merge my fix for properly creating them.
+ */
+VOID
+INIT_FUNCTION
+NTAPI
+PsInitHackThread2(IN PETHREAD *Hack)
+{
+ PETHREAD IdleThread;
+
+ IdleThread = ExAllocatePool(NonPagedPool, sizeof(ETHREAD));
+ RtlZeroMemory(IdleThread, sizeof(ETHREAD));
+ IdleThread->ThreadsProcess = PsInitialSystemProcess;
+ KeInitializeThread(&PsInitialSystemProcess->Pcb,
+ &IdleThread->Tcb,
+ PspSystemThreadStartup,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ P0BootStack);
+ InitializeListHead(&IdleThread->IrpList);
+ *Hack = IdleThread;
+}
+
VOID
INIT_FUNCTION
NTAPI
PsInitJobManagment();
PsInitProcessManagment();
PsInitThreadManagment();
- PsInitIdleThread();
+ PsInitHackThread();
}
VOID
ObjectTypeInitializer.DeleteProcedure = PspDeleteThread;
ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &PsThreadType);
- PsInitializeIdleOrFirstThread(PsInitialSystemProcess, &FirstThread, NULL, KernelMode, TRUE);
+ PsInitHackThread2(&FirstThread);
FirstThread->Tcb.State = Running;
FirstThread->Tcb.FreezeCount = 0;
FirstThread->Tcb.UserAffinity = (1 << 0); /* Set the affinity of the first thread to the boot processor */