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.

142 lines
3.9 KiB

  1. //
  2. // Scheduler
  3. //
  4. #ifndef _H_SCH
  5. #define _H_SCH
  6. //
  7. //
  8. // CONSTANTS
  9. //
  10. //
  11. #define SCH_MODE_ASLEEP 0
  12. #define SCH_MODE_NORMAL 1
  13. #define SCH_MODE_TURBO 2
  14. //
  15. // All of the following values are times in milliseconds.
  16. //
  17. #define SCH_PERIOD_NORMAL 200
  18. #define SCH_PERIOD_TURBO 100
  19. #define SCH_TURBO_MODE_DURATION 1000
  20. #define SCH_EVENT_NAME "DCS_SCHEDULE_EVENT"
  21. //
  22. //
  23. // PROTOTYPES
  24. //
  25. //
  26. // Name: SCH_Init
  27. //
  28. // Purpose: Scheduler initialization function.
  29. //
  30. // Params: None.
  31. //
  32. BOOL SCH_Init(void);
  33. // Name: SCH_Term
  34. //
  35. // Purpose: Scheduler termination function.
  36. //
  37. // Returns: Nothing.
  38. //
  39. // Params: None.
  40. //
  41. void SCH_Term(void);
  42. // Name: SCH_ContinueScheduling
  43. //
  44. // Purpose: Called by components when they want periodic scheduling to
  45. // continue. They are guaranteed to get at least one more
  46. // periodic callback following a call to this function.
  47. // If they want further callbacks then they must call this
  48. // function again during their periodic processing.
  49. //
  50. // Returns: Nothing.
  51. //
  52. // Params: schedulingMode - either SCH_MODE_NORMAL or SCH_MODE_TURBO
  53. //
  54. // Operation:
  55. // SCH_MODE_NORMAL triggers periodic processing at 200ms
  56. // intervals (5 times a second)
  57. //
  58. // SCH_MODE_TURBO triggers periodic processing at 100ms
  59. // intervals (10 times a second)
  60. //
  61. // The scheduler automatically drops from SCH_MODE_TURBO back
  62. // to SCH_MODE_NORMAL after 1 second of turbo mode processing.
  63. //
  64. // SCH_MODE_TURBO overrides SCH_MODE_NORMAL, so if calls to
  65. // this function are made with SCH_MODE_NORMAL when the
  66. // scheduler is in TURBO mode, TURBO mode continues.
  67. //
  68. // If this function is not called during processing of a
  69. // scheduler callback message then the scheduler enters
  70. // SLEEP mode - and will not generate any more periodic
  71. // callbacks until it is woken by another call to
  72. // this function, or until the output accumulation code
  73. // signals the scheduler's event.
  74. //
  75. void SCH_ContinueScheduling(UINT schedulingMode);
  76. // Name: SCH_SchedulingMessageProcessed
  77. //
  78. // Purpose: A feedback function called by the Share Core to signal that
  79. // a scheduler message has been received. This ensures that
  80. // that the scheduler only ever has one scheduler message
  81. // outstanding at a time.
  82. //
  83. // Returns: Nothing.
  84. //
  85. // Params: None.
  86. //
  87. void SCH_SchedulingMessageProcessed(void);
  88. // Name: SCH_PacingProcessor
  89. //
  90. // Purpose: The main function executed by the scheduling thread.
  91. //
  92. // Returns: Zero.
  93. //
  94. // Params: syncObject - object to pass back to COM_SignalThreadStarted
  95. //
  96. // Operation: The thread enters a main loop which continues while the
  97. // scheduler is initialized.
  98. //
  99. // The thread sets its priority to TIME_CRITICAL in order
  100. // that it runs as soon as possible when ready.
  101. //
  102. // The thread waits on an event (schEvent) with a timeout that
  103. // is set according to the current scheduler mode.
  104. //
  105. // The thread runs due to either:
  106. // - the timeout expiring, which is the normal periodic
  107. // scheduler behavior, or
  108. // - schEvent being signalled, which is how the scheduler is
  109. // woken from ASLEEP mode.
  110. //
  111. // The thread then posts a scheduler message the the Share Core
  112. // (if there is not one already outstanding) and loops back
  113. // to wait on schEvent.
  114. //
  115. // Changes in the scheduler mode are caused by calls to
  116. // SCH_ContinueScheduling updating variables accessed in this
  117. // routine, or by calculations made within the main loop of
  118. // this routine (e.g. TURBO mode timeout).
  119. //
  120. DWORD WINAPI SCH_PacingProcessor(LPVOID lpParam);
  121. void SCHSetMode(UINT newMode);
  122. void SCHPostSchedulingMessage(void);
  123. #endif // _H_SCH