Thread pool task manager queue work item

For an overview of the thread pool task manager please see: Thread pool task manager: overview.

Thread pool task manager queue work item sequence

Work items are queued on the processing or GUI thread depending on the isGui flag as shown in the following sequence diagram:

mtf-runtime-taskman-queuework.png

In the case of work items destined for the processing pool, if the thread index is not explicitly specified then the thread index of the emptiest queue is selected. This ensures that processing is evenly distributed between the hardware threads and keeps as many of them busy as possible.

In the case of work items destined for the GUI pool, the emptiest GUI queue is always selected for the same reason.

Hardware thread affinity

For the processing pool, the thread index can be explicitly specified to localize data access to a particular hardware thread and avoid unnecessary cache hits, where appropriate.

For the GUI pool there is no explicit thread index override.

Thread worker queue work item sequence

Work items are queued on an individual ThreadWorker according to the following sequence:

mtf-runtime-threadworker-queuework.png

Queueing a work item involves the following steps:
  1. Lock() the work lock to gain exclusive access to the work queue
  2. Enqueue() the item on the work queue
  3. Increment the count of work items
  4. If a thread is blocked waiting for work then Release() it and decrement the waiter count
  5. Unlock() the work lock to allow others to access the work queue

Last edited Aug 30, 2012 at 10:09 AM by jaorme, version 13

Comments

No comments yet.