430d4acd00107e2d066c720a24002c867fdc2a29
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 extern PEPROCESS PsIdleProcess
;
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();
49 /** Initialization of system idle thread
53 PsInitIdleThread(VOID
)
59 Status
= PsInitializeThread(PsIdleProcess
,
64 if (!NT_SUCCESS(Status
))
66 DPRINT1("Couldn't create idle system thread! Status: 0x%x\n", Status
);
71 IdleThread
->StartAddress
= PsIdleThreadMain
;
72 Status
= KiArchInitThread(&IdleThread
->Tcb
, PsIdleThreadMain
, NULL
);
73 if (!NT_SUCCESS(Status
))
75 DPRINT1("Couldn't initialize system idle thread! Status: 0x%x\n", Status
);
76 ObDereferenceObject(IdleThread
);
81 oldIrql
= KeAcquireDispatcherDatabaseLock ();
82 PsUnblockThread(IdleThread
, NULL
, 0);
83 KeReleaseDispatcherDatabaseLock(oldIrql
);
85 KeGetCurrentPrcb()->IdleThread
= &IdleThread
->Tcb
;
86 KeSetPriorityThread(&IdleThread
->Tcb
, LOW_PRIORITY
);
87 KeSetAffinityThread(&IdleThread
->Tcb
, 1 << 0);