mirror of
https://github.com/reactos/reactos.git
synced 2025-06-03 00:10:39 +00:00
63 lines
1.4 KiB
C
63 lines
1.4 KiB
C
/*
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
* PROJECT: ReactOS kernel
|
|
* FILE: ntoskrnl/ps/idle.c
|
|
* PURPOSE: Using idle time
|
|
* PROGRAMMER: David Welch (welch@cwcom.net)
|
|
* UPDATE HISTORY:
|
|
* Created 22/05/98
|
|
*/
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
#include <ddk/ntddk.h>
|
|
#include <internal/ke.h>
|
|
|
|
#define NDEBUG
|
|
#include <internal/debug.h>
|
|
|
|
/* GLOBALS *******************************************************************/
|
|
|
|
HANDLE PsIdleThreadHandle = NULL;
|
|
extern ULONG DpcQueueSize;
|
|
PETHREAD PiIdleThread;
|
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
static NTSTATUS PsIdleThreadMain(PVOID Context)
|
|
{
|
|
KIRQL oldlvl;
|
|
|
|
for(;;)
|
|
{
|
|
// DPRINT1("Idling DpcQueueSize %d, Irql\n",DpcQueueSize,
|
|
// KeGetCurrentIrql());
|
|
// DbgPrint(".");
|
|
if (DpcQueueSize > 0)
|
|
{
|
|
KeRaiseIrql(DISPATCH_LEVEL,&oldlvl);
|
|
KeDrainDpcQueue();
|
|
KeLowerIrql(oldlvl);
|
|
}
|
|
NtYieldExecution();
|
|
}
|
|
}
|
|
|
|
VOID PsInitIdleThread(VOID)
|
|
{
|
|
KPRIORITY Priority;
|
|
|
|
PsCreateSystemThread(&PsIdleThreadHandle,
|
|
THREAD_ALL_ACCESS,
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
PsIdleThreadMain,
|
|
NULL);
|
|
|
|
Priority = THREAD_PRIORITY_IDLE;
|
|
ZwSetInformationThread(PsIdleThreadHandle,
|
|
ThreadPriority,
|
|
&Priority,
|
|
sizeof(Priority));
|
|
}
|