mirror of
https://github.com/reactos/reactos.git
synced 2025-06-04 08:50:27 +00:00
- Re-merge 24062+24063, with a minor difference, they work now.
svn path=/trunk/; revision=24080
This commit is contained in:
parent
6b1e4db5b5
commit
2829cc5982
4 changed files with 80 additions and 118 deletions
|
@ -544,10 +544,19 @@ MainLoop:
|
|||
#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
|
||||
|
|
|
@ -292,7 +292,6 @@
|
|||
</directory>
|
||||
<directory name="ps">
|
||||
<file>debug.c</file>
|
||||
<file>idle.c</file>
|
||||
<file>job.c</file>
|
||||
<file>kill.c</file>
|
||||
<file>notify.c</file>
|
||||
|
|
|
@ -1,115 +0,0 @@
|
|||
/*
|
||||
* 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);
|
||||
}
|
|
@ -64,6 +64,75 @@ NTSTATUS STDCALL INIT_FUNCTION PspLookupKernelUserEntryPoints(VOID);
|
|||
|
||||
/* 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
|
||||
|
@ -72,7 +141,7 @@ PiInitProcessManager(VOID)
|
|||
PsInitJobManagment();
|
||||
PsInitProcessManagment();
|
||||
PsInitThreadManagment();
|
||||
PsInitIdleThread();
|
||||
PsInitHackThread();
|
||||
}
|
||||
|
||||
VOID
|
||||
|
@ -115,7 +184,7 @@ PsInitThreadManagment(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 */
|
||||
|
|
Loading…
Reference in a new issue