A system and method maintains order among a plurality of threads in a multi-threaded
processing system. The processing system, which may be disposed at an intermediate
network device, has a plurality of processors each supporting a plurality of threads.
The ordering system includes a dispatcher that assigns work, such as the processing
of received packets to free threads, an order manager that keeps track of the relative
order of the threads, and a thread client associated with each thread for enforcing
the determined order. Packets to be processed by the processing system are assigned
to an initial order group by the order manager based on a selected attribute, and
those packets sharing the same attribute value are assigned to the same order group.
During processing, a thread may request reassignment to other order groups in response
to other attributes of the packets. The order manager preferably manages the switching
of threads among order groups and ensures that the threads within each order group
process their packets in order.