reactos/reactos/ntoskrnl/ps/idle.c
David Welch ead0eeacdd Some bug fixes.
Corrected LPC implementation.

svn path=/trunk/; revision=814
1999-12-02 20:53:55 +00:00

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));
}