Patent ID: 7490178

Claim:
An apparatus, including a processor, for controlling a switch of context between an execution context of a producer of a packet and an execution context of a consumer of the packet, comprising: a buffer for storage said packet produced by said producer and removal of said packet by said consumer; a count for incrementing and decrementing, respectively responsive to storage of said packet in the buffer and removal of said packet from the buffer; a threshold imposed on said count, said threshold having a threshold pre-set value and an on and off state; a limit on the count, said limit having a limit pre-set value; a first means for (a) delaying said producer from a switch of said producer context to the execution context of the consumer if said threshold is on and said count is less than the pre-set value of the threshold, wherein said first means set the threshold off before said producer context is switched, and (b) stopping said delaying said producer from a switch of said context to the execution context of the consumer if said threshold is on and a buffer flush is required to allow the consumer to process any remaining packets in the buffer, wherein said first means set the threshold off before said context is switched; if said count is zero, a second means for setting said threshold on and forcing said context switch to said producer.