UNUSED_PARAM( arg1 );\r
UNUSED_PARAM( arg2 );\r
\r
+ cl_spinlock_acquire( &p_timer->spinlock );\r
p_timer->timeout_time = 0;\r
+ cl_spinlock_release( &p_timer->spinlock );\r
\r
(p_timer->pfn_callback)( (void*)p_timer->context );\r
}\r
\r
KeInitializeTimer( &p_timer->timer );\r
KeInitializeDpc( &p_timer->dpc, __timer_callback, p_timer );\r
+ cl_spinlock_init( &p_timer->spinlock );\r
\r
return( CL_SUCCESS );\r
}\r
IN const uint32_t time_ms )\r
{\r
LARGE_INTEGER due_time;\r
+ uint64_t timeout_time;\r
\r
CL_ASSERT( p_timer );\r
CL_ASSERT( p_timer->pfn_callback );\r
\r
/* Due time is in 100 ns increments. Negative for relative time. */\r
due_time.QuadPart = -(int64_t)(((uint64_t)time_ms) * 10000);\r
+ timeout_time = cl_get_time_stamp() + (((uint64_t)time_ms) * 1000);\r
\r
- /* Store the timeout time in the timer object. */\r
- p_timer->timeout_time = cl_get_time_stamp() + (((uint64_t)time_ms) * 1000);\r
-\r
+ cl_spinlock_acquire( &p_timer->spinlock );\r
+ p_timer->timeout_time = timeout_time;\r
KeSetTimer( &p_timer->timer, due_time, &p_timer->dpc );\r
+ cl_spinlock_release( &p_timer->spinlock );\r
+\r
return( CL_SUCCESS );\r
}\r
\r
IN cl_timer_t* const p_timer,\r
IN const uint32_t time_ms )\r
{\r
+ LARGE_INTEGER due_time;\r
uint64_t timeout_time;\r
\r
CL_ASSERT( p_timer );\r
CL_ASSERT( p_timer->pfn_callback );\r
\r
- /* Calculate the timeout time in the timer object. */\r
+ /* Due time is in 100 ns increments. Negative for relative time. */\r
+ due_time.QuadPart = -(int64_t)(((uint64_t)time_ms) * 10000);\r
timeout_time = cl_get_time_stamp() + (((uint64_t)time_ms) * 1000);\r
\r
/* Only pull in the timeout time. */\r
- if( p_timer->timeout_time && p_timer->timeout_time < timeout_time )\r
- return( CL_SUCCESS );\r
-\r
- return cl_timer_start( p_timer, time_ms );\r
+ cl_spinlock_acquire( &p_timer->spinlock );\r
+ if( !p_timer->timeout_time || p_timer->timeout_time > timeout_time )\r
+ {\r
+ p_timer->timeout_time = timeout_time;\r
+ KeSetTimer( &p_timer->timer, due_time, &p_timer->dpc );\r
+ }\r
+ cl_spinlock_release( &p_timer->spinlock );\r
+ return( CL_SUCCESS );\r
}\r
\r
\r
CL_ASSERT( KeGetCurrentIrql() <= DISPATCH_LEVEL );\r
\r
/* Cancel the timer. This also cancels any queued DPCs for the timer. */\r
- KeCancelTimer( &p_timer->timer );\r
-\r
+ cl_spinlock_acquire( &p_timer->spinlock );\r
p_timer->timeout_time = 0;\r
+ KeCancelTimer( &p_timer->timer );\r
+ cl_spinlock_release( &p_timer->spinlock );\r
}\r