Understanding the Thread Ordering Service

Understanding the Thread Ordering Service

This article describes the new Thread Ordering Service and thread ordering groups in Windows Server® 2008. A detailed discussion on developing scalable applications using this feature can be found in the companion topic Developing with the Thread Ordering Service.

Applications use thread ordering groups to have the Thread Ordering Service execute a collection of threads in a specific order and within a specified time interval. Each thread ordering group has a parent thread and zero or more client threads. The parent thread is the thread that creates the thread ordering group. The parent thread creates a thread ordering group with a unique group identifier and specifies the amount of time within which every thread in the group must execute once. The time is specified as a time interval and timeout value. Client threads join the group and can specify whether they should be scheduled for execution before or after the parent thread. Client threads are scheduled either before or after the parent, and then in the order in which they joined the group.

During execution, the Thread Ordering Service iterates over all of the threads in the group, scheduling each thread for execution while suspending the other threads in the group. The thread ordering group executes the client thread predecessors, then the parent thread, and finally the client thread successors. When a thread executes, it must finish its processing within the allotted time. If a client thread does not finish executing within the time period, the Thread Ordering Service removes the thread from the group. The parent thread also must complete its processing within the allotted time. If the parent thread fails to do so, the service deletes the thread ordering group, and the client threads resume execution. If all threads have finished executing before the time period elapses, the threads in the group block until the time period elapses.

Client threads can leave a thread group at any time. The parent thread should not leave the group. When the thread group is no longer needed, the parent thread is responsible for deleting the group.

Community Additions

ADD
Show:
© 2016 Microsoft