2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: ntoskrnl/ps/idle.c
5 * PURPOSE: Using idle time
7 * PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
8 * David Welch (welch@cwcom.net)
11 /* INCLUDES *****************************************************************/
15 #include <internal/debug.h>
17 #if defined (ALLOC_PRAGMA)
18 #pragma alloc_text(INIT, PsInitIdleThread)
21 /* FUNCTIONS *****************************************************************/
23 /** System idle thread procedure
27 PsIdleThreadMain(PVOID Context
)
31 PKPRCB Prcb
= KeGetCurrentPrcb();
35 if (Prcb
->DpcData
[0].DpcQueueDepth
> 0)
37 KeRaiseIrql(DISPATCH_LEVEL
,&oldlvl
);
38 KiDispatchInterrupt();
54 * Antique vestigial code left alive for the sole purpose of First/Idle Thread
55 * creation until I can merge my fix for properly creating them.
59 PsInitializeIdleOrFirstThread(PEPROCESS Process
,
61 PKSTART_ROUTINE StartRoutine
,
62 KPROCESSOR_MODE AccessMode
,
68 Thread
= ExAllocatePool(NonPagedPool
, sizeof(ETHREAD
));
69 RtlZeroMemory(Thread
, sizeof(ETHREAD
));
70 Thread
->ThreadsProcess
= Process
;
73 KernelStack
= P0BootStack
;
77 KernelStack
= (PVOID
)((ULONG_PTR
)MmCreateKernelStack(FALSE
) +
80 KeInitializeThread(&Process
->Pcb
,
82 PspSystemThreadStartup
,
88 InitializeListHead(&Thread
->IrpList
);
90 return STATUS_SUCCESS
;
95 * Antique vestigial code left alive for the sole purpose of First/Idle Thread
96 * creation until I can merge my fix for properly creating them.
101 PsInitIdleThread(VOID
)
106 PsInitializeIdleOrFirstThread(PsIdleProcess
,
112 oldIrql
= KeAcquireDispatcherDatabaseLock ();
113 KiReadyThread(&IdleThread
->Tcb
);
114 KeReleaseDispatcherDatabaseLock(oldIrql
);
116 KeGetCurrentPrcb()->IdleThread
= &IdleThread
->Tcb
;
117 KeSetPriorityThread(&IdleThread
->Tcb
, LOW_PRIORITY
);
118 KeSetAffinityThread(&IdleThread
->Tcb
, 1 << 0);