开发者

Semaphore On Multiple Producer Single Consumer Problem

I need to suggestion on this case studies on C++.

I have taken Queue where multiple Thread 20 Producer thread is writing on it.there is single Consumer thread which will Read from the queue and process it. I am planning to use critical section and Semaphore to achieve synchronization.

AddTail-Adding message in the Queue. RemoveHead-Remove data from Queue.

I have restricted the queue length to 10.

Crtical section will protect wrting or/Reading problem. Semaphore will synchronized access to the queue.

Let me know any other POs开发者_JAVA技巧sible solution on this.


There are many ways to write such a queue. For example, you could use a mutex and a condition variable as in my example at http://www.justsoftwaresolutions.co.uk/threading/implementing-a-thread-safe-queue-using-condition-variables.html

Herb Sutter discusses queues in his articles at Dr Dobb's. See http://www.drdobbs.com/high-performance-computing/211601363 and http://www.drdobbs.com/high-performance-computing/210604448

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜