mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Fixes to waitable timer implementation
svn path=/trunk/; revision=1630
This commit is contained in:
parent
3d4886b292
commit
e9143b26d7
6 changed files with 38 additions and 39 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $Id: timer.c,v 1.8 2001/02/17 00:07:49 ekohl Exp $
|
||||
/* $Id: timer.c,v 1.9 2001/02/18 19:43:14 phreak Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -30,9 +30,9 @@ CreateWaitableTimerW(LPSECURITY_ATTRIBUTES lpTimerAttributes,
|
|||
ULONG TimerType;
|
||||
|
||||
if (bManualReset)
|
||||
TimerType = 1;
|
||||
TimerType = NotificationTimer;
|
||||
else
|
||||
TimerType = 2;
|
||||
TimerType = SynchronizationTimer;
|
||||
|
||||
RtlInitUnicodeString(&UnicodeName, lpTimerName);
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
|
|
|
@ -87,7 +87,10 @@ BOOLEAN KeDispatcherObjectWake(DISPATCHER_HEADER* hdr);
|
|||
#if 0
|
||||
VOID KiInterruptDispatch(ULONG irq);
|
||||
#endif
|
||||
VOID KeExpireTimers(VOID);
|
||||
VOID KeExpireTimers( PKDPC Apc,
|
||||
PVOID Arg1,
|
||||
PVOID Arg2,
|
||||
PVOID Arg3 );
|
||||
NTSTATUS KeAddThreadTimeout(struct _KTHREAD* Thread,
|
||||
PLARGE_INTEGER Interval);
|
||||
VOID KeInitializeDispatcherHeader(DISPATCHER_HEADER* Header, ULONG Type,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: timer.c,v 1.38 2001/02/06 00:11:18 dwelch Exp $
|
||||
/* $Id: timer.c,v 1.39 2001/02/18 19:43:15 phreak Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -74,6 +74,7 @@ volatile ULONG KiRawTicks = 0;
|
|||
*/
|
||||
static LIST_ENTRY TimerListHead;
|
||||
static KSPIN_LOCK TimerListLock;
|
||||
static KDPC ExpireTimerDpc;
|
||||
|
||||
/* must raise IRQL to HIGH_LEVEL and grab spin lock there, to sync with ISR */
|
||||
|
||||
|
@ -247,8 +248,7 @@ KeSetTimerEx (PKTIMER Timer,
|
|||
KIRQL oldlvl;
|
||||
|
||||
DPRINT("KeSetTimerEx(Timer %x), DueTime: \n",Timer);
|
||||
KeRaiseIrql( HIGH_LEVEL, &oldlvl );
|
||||
KeAcquireSpinLockAtDpcLevel(&TimerListLock);
|
||||
KeAcquireSpinLock( &TimerListLock, &oldlvl );
|
||||
|
||||
Timer->Dpc = Dpc;
|
||||
if (DueTime.QuadPart < 0)
|
||||
|
@ -379,7 +379,10 @@ static void HandleExpiredTimer(PKTIMER current)
|
|||
NULL);
|
||||
DPRINT("Finished dpc routine\n");
|
||||
}
|
||||
KeAcquireDispatcherDatabaseLock( FALSE );
|
||||
current->Header.SignalState = TRUE;
|
||||
KeDispatcherObjectWake( ¤t->Header );
|
||||
KeReleaseDispatcherDatabaseLock( FALSE );
|
||||
if (current->Period != 0)
|
||||
{
|
||||
current->DueTime.QuadPart +=
|
||||
|
@ -392,22 +395,18 @@ static void HandleExpiredTimer(PKTIMER current)
|
|||
}
|
||||
}
|
||||
|
||||
VOID KeExpireTimers(VOID)
|
||||
VOID KeExpireTimers( PKDPC Dpc,
|
||||
PVOID Context1,
|
||||
PVOID Arg1,
|
||||
PVOID Arg2 )
|
||||
{
|
||||
PLIST_ENTRY current_entry = NULL;
|
||||
PKTIMER current = NULL;
|
||||
KIRQL oldlvl;
|
||||
|
||||
DPRINT("KeExpireTimers()\n");
|
||||
|
||||
current_entry = TimerListHead.Flink;
|
||||
|
||||
// DPRINT("&TimerListHead %x\n",&TimerListHead);
|
||||
// DPRINT("current_entry %x\n",current_entry);
|
||||
// DPRINT("current_entry->Flink %x\n",current_entry->Flink);
|
||||
// DPRINT("current_entry->Flink->Flink %x\n",current_entry->Flink->Flink);
|
||||
|
||||
KeRaiseIrql(HIGH_LEVEL, &oldlvl);
|
||||
KeAcquireSpinLockAtDpcLevel(&TimerListLock);
|
||||
|
||||
while (current_entry!=(&TimerListHead))
|
||||
|
@ -422,8 +421,7 @@ VOID KeExpireTimers(VOID)
|
|||
}
|
||||
}
|
||||
|
||||
KeReleaseSpinLock(&TimerListLock, oldlvl);
|
||||
// DPRINT("Finished KeExpireTimers()\n");
|
||||
KeReleaseSpinLockFromDpcLevel( &TimerListLock );
|
||||
}
|
||||
|
||||
|
||||
|
@ -487,7 +485,7 @@ VOID KiUpdateSystemTime (VOID)
|
|||
*vidmem=0x7;
|
||||
vidmem++;
|
||||
}
|
||||
KeExpireTimers();
|
||||
KeInsertQueueDpc( &ExpireTimerDpc, 0, 0 );
|
||||
}
|
||||
|
||||
|
||||
|
@ -507,7 +505,7 @@ VOID KeInitializeTimerImpl(VOID)
|
|||
|
||||
InitializeListHead(&TimerListHead);
|
||||
KeInitializeSpinLock(&TimerListLock);
|
||||
|
||||
KeInitializeDpc( &ExpireTimerDpc, KeExpireTimers, 0 );
|
||||
TimerInitDone = TRUE;
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: nttimer.c,v 1.7 2001/02/04 17:28:13 ekohl Exp $
|
||||
/* $Id: nttimer.c,v 1.8 2001/02/18 19:43:15 phreak Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -74,23 +74,18 @@ NtpTimerDpcRoutine(PKDPC Dpc,
|
|||
PVOID SystemArgument2)
|
||||
{
|
||||
PNTTIMER Timer;
|
||||
KIRQL OldIrql;
|
||||
|
||||
DPRINT("NtpTimerDpcRoutine()\n");
|
||||
|
||||
Timer = (PNTTIMER)DeferredContext;
|
||||
|
||||
OldIrql = KeRaiseIrqlToDpcLevel();
|
||||
|
||||
if (Timer->Running == TRUE)
|
||||
if ( Timer->Running )
|
||||
{
|
||||
KeInsertQueueApc(&Timer->Apc,
|
||||
SystemArgument1,
|
||||
SystemArgument2,
|
||||
KernelMode);
|
||||
}
|
||||
|
||||
KeLowerIrql(OldIrql);
|
||||
}
|
||||
|
||||
|
||||
|
@ -265,7 +260,7 @@ NtSetTimer(IN HANDLE TimerHandle,
|
|||
Timer->Running = FALSE;
|
||||
KeLowerIrql(OldIrql);
|
||||
}
|
||||
|
||||
if( TimerApcRoutine )
|
||||
KeInitializeApc(&Timer->Apc,
|
||||
KeGetCurrentThread(),
|
||||
0,
|
||||
|
@ -278,10 +273,11 @@ NtSetTimer(IN HANDLE TimerHandle,
|
|||
Result = KeSetTimerEx (&Timer->Timer,
|
||||
*DueTime,
|
||||
Period,
|
||||
&Timer->Dpc);
|
||||
if (Result == FALSE)
|
||||
TimerApcRoutine ? &Timer->Dpc : 0 );
|
||||
if (Result == TRUE)
|
||||
{
|
||||
ObDereferenceObject(Timer);
|
||||
DPRINT1( "KeSetTimer says the timer was already running, this shouldn't be\n" );
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; $Id: ntoskrnl.def,v 1.96 2001/01/29 00:32:13 ekohl Exp $
|
||||
; $Id: ntoskrnl.def,v 1.97 2001/02/18 19:43:14 phreak Exp $
|
||||
;
|
||||
; reactos/ntoskrnl/ntoskrnl.def
|
||||
;
|
||||
|
@ -503,6 +503,7 @@ NtBuildNumber DATA
|
|||
NtClose@4
|
||||
NtConnectPort@32
|
||||
NtCreateEvent@20
|
||||
NtCreateTimer@16
|
||||
NtOpenEvent@12
|
||||
NtCreateFile@44
|
||||
NtCreateSection@28
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; $Id: ntoskrnl.edf,v 1.83 2001/01/29 00:32:13 ekohl Exp $
|
||||
; $Id: ntoskrnl.edf,v 1.84 2001/02/18 19:43:14 phreak Exp $
|
||||
;
|
||||
; reactos/ntoskrnl/ntoskrnl.def
|
||||
;
|
||||
|
@ -503,6 +503,7 @@ NtBuildNumber DATA
|
|||
NtClose=NtClose@4
|
||||
NtConnectPort=NtConnectPort@32
|
||||
NtCreateEvent=NtCreateEvent@20
|
||||
NtCreateTimer=NtCreateTimer@16
|
||||
NtOpenEvent=NtOpenEvent@12
|
||||
NtCreateFile=NtCreateFile@44
|
||||
NtCreateSection=NtCreateSection@28
|
||||
|
|
Loading…
Reference in a new issue