IA-32 Intel® Architecture Optimization
Producer-Consumer Threading Models
Figure 7-3 illustrates the basic scheme of interaction between a pair of
producer and consumer threads. The horizontal direction represents
time. Each block represents a task unit, processing the buffer assigned to
a thread. The gap between each task represents synchronization
overhead. The decimal number in the parenthesis represents a buffer
index. On an Intel Core Duo processor, the producer thread can store
data in the second-level cache to allow the consumer thread to continue
work requiring minimal bus traffic.
Figure 7-3 Execution of Producer-consumer Threading Model on a Multi-core
Processor
The basic structure to implement the producer and consumer thread
functions with synchronization to communicate buffer index is shown in
Example 7-2.
7-10
Main
P(1)
Thread
P: producer
C: consumer
P(2)
P(1)
P(2)
C(1)
C(2)
P(1)
C(1)
C(2)
Need help?
Do you have a question about the ARCHITECTURE IA-32 and is the answer not in the manual?