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.

202 lines
3.2 KiB

  1. /*++
  2. Copyright (c) 1998-2001 Microsoft Corporation
  3. Module Name:
  4. pipeline.h
  5. Abstract:
  6. This module contains public declarations for the pipeline package.
  7. Author:
  8. Keith Moore (keithmo) 10-Jun-1998
  9. Revision History:
  10. --*/
  11. #ifndef _PIPELINE_H_
  12. #define _PIPELINE_H_
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. //
  17. // A simple lock used to serialize access to a pipeline queue. Use
  18. // UlInterlockedCompareExchange() to see if you can acquire it.
  19. //
  20. typedef LONG UL_PIPELINE_QUEUE_LOCK;
  21. #define L_LOCKED 0
  22. #define L_UNLOCKED 1
  23. //
  24. // An ordinal used to identify a specific queue within a pipeline.
  25. //
  26. typedef SHORT UL_PIPELINE_QUEUE_ORDINAL, *PUL_PIPELINE_QUEUE_ORDINAL;
  27. //
  28. // A queueable work item.
  29. //
  30. typedef struct _UL_PIPELINE_WORK_ITEM // WorkItem
  31. {
  32. //
  33. // Links onto the pipeline queue's work queue.
  34. //
  35. LIST_ENTRY WorkQueueEntry;
  36. } UL_PIPELINE_WORK_ITEM, *PUL_PIPELINE_WORK_ITEM;
  37. //
  38. // Pointer to a queue handler. The handler is invoked for each queued
  39. // work item.
  40. //
  41. typedef
  42. VOID
  43. (NTAPI * PFN_UL_PIPELINE_HANDLER)(
  44. IN PUL_PIPELINE_WORK_ITEM WorkItem
  45. );
  46. //
  47. // A pipeline queue. Note that two queues will fit into a single cache line.
  48. //
  49. typedef struct _UL_PIPELINE_QUEUE // Queue
  50. {
  51. //
  52. // The list of enqueued work items.
  53. //
  54. LIST_ENTRY WorkQueueHead;
  55. //
  56. // The lock protecting this queue.
  57. //
  58. UL_PIPELINE_QUEUE_LOCK QueueLock;
  59. //
  60. // Pointer to the handler for this queue.
  61. //
  62. PFN_UL_PIPELINE_HANDLER pHandler;
  63. } UL_PIPELINE_QUEUE, *PUL_PIPELINE_QUEUE;
  64. //
  65. // A pipeline.
  66. //
  67. typedef struct _UL_PIPELINE // Pipeline
  68. {
  69. //
  70. // The spinlock protecting this pipeline.
  71. //
  72. UL_SPIN_LOCK PipelineLock;
  73. //
  74. // The number of threads currently servicing queue requests.
  75. //
  76. SHORT ThreadsRunning;
  77. //
  78. // The number of queues with non-empty work queue lists.
  79. //
  80. SHORT QueuesWithWork;
  81. //
  82. // The maximum number of threads allowed to run simultaneously
  83. // for this pipeline.
  84. //
  85. SHORT MaximumThreadsRunning;
  86. //
  87. // The number of queues in this pipeline.
  88. //
  89. SHORT QueueCount;
  90. //
  91. // Shutdown flag.
  92. //
  93. BOOLEAN ShutdownFlag;
  94. BOOLEAN Spares[3];
  95. //
  96. // An event object signalled whenever there's work to be done. We take
  97. // great pains to ensure this event is never signalled frivolously.
  98. //
  99. KEVENT WorkAvailableEvent;
  100. //
  101. // The actual queues go here.
  102. //
  103. UL_PIPELINE_QUEUE Queues[ANYSIZE_ARRAY];
  104. //
  105. // Additional opaque (pipeline package-specific) data may go here,
  106. // but don't count on it.
  107. //
  108. } UL_PIPELINE, *PUL_PIPELINE;
  109. //
  110. // Public functions.
  111. //
  112. NTSTATUS
  113. UlCreatePipeline(
  114. OUT PUL_PIPELINE * ppPipeline,
  115. IN SHORT QueueCount,
  116. IN SHORT ThreadsPerCpu
  117. );
  118. VOID
  119. UlInitializeQueuePipeline(
  120. IN PUL_PIPELINE pPipeline,
  121. IN UL_PIPELINE_QUEUE_ORDINAL QueueOrdinal,
  122. IN PFN_UL_PIPELINE_HANDLER pHandler
  123. );
  124. NTSTATUS
  125. UlDestroyPipeline(
  126. IN PUL_PIPELINE pPipeline
  127. );
  128. VOID
  129. UlQueueWorkPipeline(
  130. IN PUL_PIPELINE pPipeline,
  131. IN UL_PIPELINE_QUEUE_ORDINAL QueueOrdinal,
  132. IN PUL_PIPELINE_WORK_ITEM pWorkItem
  133. );
  134. #ifdef __cplusplus
  135. }; // extern "C"
  136. #endif
  137. #endif // _PIPELINE_H_