Hi Friends, I am trying to understand the UDPCast source code. Can anybody explain me the producer/consumer concept in the source code both on sender and receiver's side ??
Thanks , Sai
__________________________________ Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo. http://search.yahoo.com
On Wednesday 07 May 2003 01:41, Saikrishna Dasari wrote:
Hi Friends, I am trying to understand the UDPCast source code. Can anybody explain me the producer/consumer concept in the source code both on sender and receiver's side ??
Thanks , Sai
Producer/consumer is just an internal "pipe" between threads. Rather than actually using a real (OS level) pipe, it uses shared memory, and two pointer & condition variables for synchronization.
The producer "produces" data, and puts it into the ring buffer (advancing the "written" pointer). The consumer "consumes" data from the ring buffer (advancing the "read" pointer).
Producer blocks if ring buffer is full (waiting until the consumer frees up space by advancing its read pointer)
Consumer blocks if ring buffer is empty (waiting until the producers "produces" data, and advances its ring buffer)
Producer/consumer is a well-known design pattern for which you can find numerous examples on google: http://www.google.com/search?q=%22producer+consumer%22
Udpcast's implementation has some additional wrinkles due to the presence of a multi-stage pipeline sharing a same ring buffer:
Net read -> FEC decode -> Disk write
Thus FEC decode is consumer for the first pipe, but producer for the second pipe, so you have multiple read/write pointer pairs, but the basic principle stays the same.
Regards,
Alain