c++ - Semaphore On Multiple Producer Single Consumer Problem -
i need suggestion on case studies on c++.
i have taken queue multiple thread 20 producer thread writing on it.there single consumer thread read queue , process it. planning use critical section , semaphore achieve synchronization.
addtail-adding message in queue. removehead-remove data queue.
i have restricted queue length 10.
crtical section protect wrting or/reading problem. semaphore synchronized access queue.
let me know other possible solution on this.
there many ways write such queue. example, use mutex , condition variable in example @ http://www.justsoftwaresolutions.co.uk/threading/implementing-a-thread-safe-queue-using-condition-variables.html
herb sutter discusses queues in articles @ dr dobb's. see http://www.drdobbs.com/high-performance-computing/211601363 , http://www.drdobbs.com/high-performance-computing/210604448
Comments
Post a Comment