From 68a209fb2b6b797242dff57462c78ccd900ffae9 Mon Sep 17 00:00:00 2001 From: Alex Ionescu Date: Tue, 19 Apr 2005 06:26:01 +0000 Subject: [PATCH] damn fingers were too fast. sorry, reverting svn path=/trunk/; revision=14697 --- reactos/ntoskrnl/ps/idle.c | 109 ++++++++++++------------------------ reactos/ntoskrnl/ps/psmgr.c | 2 +- 2 files changed, 37 insertions(+), 74 deletions(-) diff --git a/reactos/ntoskrnl/ps/idle.c b/reactos/ntoskrnl/ps/idle.c index 1c1403f5c3a..b8d2598c9b1 100644 --- a/reactos/ntoskrnl/ps/idle.c +++ b/reactos/ntoskrnl/ps/idle.c @@ -19,7 +19,7 @@ extern PEPROCESS PsIdleProcess; /* FUNCTIONS *****************************************************************/ - + /** System idle thread procedure * */ @@ -45,82 +45,45 @@ PsIdleThreadMain(PVOID Context) } } -/* - * 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 -PsInitializeIdleOrFirstThread(PEPROCESS Process, - PETHREAD* ThreadPtr, - PKSTART_ROUTINE StartRoutine, - KPROCESSOR_MODE AccessMode, - BOOLEAN First) -{ - PETHREAD Thread; - PVOID KernelStack; - extern unsigned int init_stack; - PAGED_CODE(); - - Thread = ExAllocatePool(NonPagedPool, sizeof(ETHREAD)); - - RtlZeroMemory(Thread, sizeof(ETHREAD)); - Thread->ThreadsProcess = Process; - - DPRINT("Thread = %x\n",Thread); - - if (First) - { - KernelStack = (PVOID)init_stack; - } - else - { - KernelStack = MmCreateKernelStack(FALSE); - } - - KeInitializeThread(&Process->Pcb, - &Thread->Tcb, - PspSystemThreadStartup, - StartRoutine, - NULL, - NULL, - NULL, - KernelStack); - Thread->Tcb.ApcQueueable = TRUE; - - InitializeListHead(&Thread->IrpList); - - DPRINT("Thread->Cid.UniqueThread %d\n",Thread->Cid.UniqueThread); - - *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 +/** Initialization of system idle thread + * + */ +VOID INIT_FUNCTION PsInitIdleThread(VOID) { - PETHREAD IdleThread; - KIRQL oldIrql; + NTSTATUS Status; + PETHREAD IdleThread; + KIRQL oldIrql; - PsInitializeIdleOrFirstThread(PsIdleProcess, - &IdleThread, - PsIdleThreadMain, - KernelMode, - FALSE); + Status = PsInitializeThread(PsIdleProcess, + &IdleThread, + NULL, + KernelMode, + FALSE); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Couldn't create idle system thread! Status: 0x%x\n", Status); + KEBUGCHECK(0); + return; + } + + IdleThread->StartAddress = PsIdleThreadMain; + Status = KiArchInitThread(&IdleThread->Tcb, PsIdleThreadMain, NULL); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Couldn't initialize system idle thread! Status: 0x%x\n", Status); + ObDereferenceObject(IdleThread); + KEBUGCHECK(0); + return; + } - oldIrql = KeAcquireDispatcherDatabaseLock (); - KiUnblockThread(&IdleThread->Tcb, NULL, 0); - KeReleaseDispatcherDatabaseLock(oldIrql); + oldIrql = KeAcquireDispatcherDatabaseLock (); + KiUnblockThread(&IdleThread->Tcb, NULL, 0); + KeReleaseDispatcherDatabaseLock(oldIrql); + + KeGetCurrentPrcb()->IdleThread = &IdleThread->Tcb; + KeSetPriorityThread(&IdleThread->Tcb, LOW_PRIORITY); + KeSetAffinityThread(&IdleThread->Tcb, 1 << 0); - KeGetCurrentPrcb()->IdleThread = &IdleThread->Tcb; - KeSetPriorityThread(&IdleThread->Tcb, LOW_PRIORITY); - KeSetAffinityThread(&IdleThread->Tcb, 1 << 0); } diff --git a/reactos/ntoskrnl/ps/psmgr.c b/reactos/ntoskrnl/ps/psmgr.c index 70e99d9b5f6..4d2118ebe9a 100644 --- a/reactos/ntoskrnl/ps/psmgr.c +++ b/reactos/ntoskrnl/ps/psmgr.c @@ -103,7 +103,7 @@ PsInitThreadManagment(VOID) ObpCreateTypeObject(PsThreadType); - PsInitializeIdleOrFirstThread(PsInitialSystemProcess, &FirstThread, NULL, KernelMode, TRUE); + PsInitializeThread(NULL, &FirstThread, NULL, KernelMode, TRUE); FirstThread->Tcb.State = Running; FirstThread->Tcb.FreezeCount = 0; FirstThread->Tcb.UserAffinity = (1 << 0); /* Set the affinity of the first thread to the boot processor */