Click to See Complete Forum and Search --> : ???a problem about producer/comsumer


dragooooon
May 7th, 2006, 09:32 PM
the context is producer/consumer

thread1
----------------------------------------------
p(empty)
mutexRW.lock()
produce(item)
mutexRW.unlock()
v(full)
-----------------------------------------------------
thread2
----------------------------------------------
p(full)
mutexRW.lock()
comsume(item)
mutexRW.unlock()
v(empty)
-----------------------------------------------------

I need to stop thread1 and thread2 sinultaneously in thread3.
How to avoid deadlock at p(empty) in thread1 for buffer is full or deadlock at p(full) in thread2 for buffer is empty ?
and I can't use a third mutex to achieve that because a third mutex would be unefficient for producer/consumer. so give me some clues to solve this problem please. thanks

Ejaz
May 8th, 2006, 01:42 AM
[ Redirected Thread ]

dragooooon
May 8th, 2006, 04:30 AM
what is [ Redirected Thread ]????

dragooooon
May 8th, 2006, 10:25 PM
none?

Arjay
May 9th, 2006, 12:15 AM
none?negative, ghost rider.

Ejaz
May 9th, 2006, 02:27 AM
what is [ Redirected Thread ]????

You posted the thread in the VC++ section, but there is another baord which is more appropriate for this thread (Multithreading). So, I've redirected your thead, means that the thread originally moved to new board (Multithreading), but in the earlier one (VC++), there is a link of this thread as well.

So this way, your thread has chances to get more audience and placed at the suitable place. To let you know that your thread has been redirected, I've posted [ Redirected Thread ].