3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/ps/idle.c
6 * PURPOSE: Using idle time
8 * PROGRAMMERS: David Welch (welch@cwcom.net)
11 /* INCLUDES *****************************************************************/
15 #include <internal/debug.h>
17 /* GLOBALS *******************************************************************/
19 /* FUNCTIONS *****************************************************************/
21 /** System idle thread procedure
25 PsIdleThreadMain(PVOID Context
)
29 PKPCR Pcr
= KeGetCurrentKPCR();
33 if (Pcr
->PrcbData
.DpcData
[0].DpcQueueDepth
> 0)
35 KeRaiseIrql(DISPATCH_LEVEL
,&oldlvl
);
36 KiDispatchInterrupt();
47 /** Initialization of system idle thread
51 PsInitIdleThread(VOID
)
55 HANDLE IdleThreadHandle
;
57 Status
= PsCreateSystemThread(&IdleThreadHandle
,
64 if(!NT_SUCCESS(Status
))
66 DPRINT("Couldn't create Idle System Thread!");
70 Status
= ObReferenceObjectByHandle(IdleThreadHandle
,
76 if(!NT_SUCCESS(Status
))
78 DPRINT("Couldn't get pointer to Idle System Thread!");
82 NtClose(IdleThreadHandle
);
83 KeGetCurrentKPCR()->PrcbData
.IdleThread
= &IdleThread
->Tcb
;
84 KeSetPriorityThread(&IdleThread
->Tcb
, LOW_PRIORITY
);
85 KeSetAffinityThread(&IdleThread
->Tcb
, 1 << 0);