Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
2.2 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. spxtimer.h
  5. Abstract:
  6. This module contains routines to schedule timer events.
  7. Author:
  8. Jameel Hyder (jameelh@microsoft.com)
  9. Nikhil Kamkolkar (nikhilk@microsoft.com)
  10. Revision History:
  11. 19 Jun 1992 Initial Version
  12. Notes: Tab stop: 4
  13. --*/
  14. #define TIMER_DONT_REQUEUE 0
  15. #define TIMER_REQUEUE_CUR_VALUE 1
  16. typedef ULONG (*TIMER_ROUTINE)(IN PVOID Context, IN BOOLEAN TimerShuttingDown);
  17. extern
  18. NTSTATUS
  19. SpxTimerInit(
  20. VOID);
  21. extern
  22. ULONG
  23. SpxTimerScheduleEvent(
  24. IN TIMER_ROUTINE Worker, // Routine to invoke when time expires
  25. IN ULONG DeltaTime, // Schedule after this much time
  26. IN PVOID pContext); // Context to pass to the routine
  27. extern
  28. VOID
  29. SpxTimerFlushAndStop(
  30. VOID);
  31. extern
  32. BOOLEAN
  33. SpxTimerCancelEvent(
  34. IN ULONG TimerId,
  35. IN BOOLEAN ReEnqueue);
  36. #define TMR_SIGNATURE *(PULONG)"ATMR"
  37. #if DBG
  38. #define VALID_TMR(pTmr) (((pTmr) != NULL) && \
  39. ((pTmr)->tmr_Signature == TMR_SIGNATURE))
  40. #else
  41. #define VALID_TMR(pTmr) ((pTmr) != NULL)
  42. #endif
  43. typedef struct _TimerList
  44. {
  45. #if DBG
  46. ULONG tmr_Signature;
  47. #endif
  48. struct _TimerList * tmr_Next; // Link to next
  49. struct _TimerList ** tmr_Prev; // Link to prev
  50. struct _TimerList * tmr_Overflow; // Link to overflow entry in hash table
  51. ULONG tmr_AbsTime; // Absolute time, for re-enqueue
  52. ULONG tmr_RelDelta; // Relative to the previous entry
  53. ULONG tmr_Id; // Unique Id for this event
  54. BOOLEAN tmr_Cancelled; // Was the timer cancelled?
  55. TIMER_ROUTINE tmr_Worker; // Real Worker
  56. PVOID tmr_Context; // Real context
  57. } TIMERLIST, *PTIMERLIST;
  58. #define SpxGetCurrentTime() (SpxTimerCurrentTime/SPX_TIMER_FACTOR)
  59. #define SpxGetCurrentTick() SpxTimerCurrentTime
  60. // Keep this at a ONE second level.
  61. #define SPX_TIMER_FACTOR 10 // i.e. 10 ticks per second
  62. #define SPX_MS_TO_TICKS 100 // Divide ms by this to get ticks
  63. #define SPX_TIMER_TICK -1000000L // 100ms in 100ns units
  64. #define SPX_TIMER_WAIT 50 // Time to wait in FlushAndStop in ms
  65. #define TIMER_HASH_TABLE 32
  66. VOID
  67. spxTimerDpcRoutine(
  68. IN PKDPC pKDpc,
  69. IN PVOID pContext,
  70. IN PVOID SystemArgument1,
  71. IN PVOID SystemArgument2);
  72. VOID
  73. spxTimerWorker(
  74. IN PTIMERLIST pList);
  75. VOID
  76. spxTimerEnqueue(
  77. PTIMERLIST pListNew);