I was asked to write code for consumer and producer threads accessing shared queue in an interview with the given primitives
ADDNEW.Process
PROCESS.SET
PROCESS.RESET
ENTER CS
EXIT CS
LOOP
EXIT LOOP
WAIT# PROCESS
I was asked to write code for consumer and producer threads accessing shared queue in an interview with the given primitives
ADDNEW.Process
PROCESS.SET
PROCESS.RESET
ENTER CS
EXIT CS
LOOP
EXIT LOOP
WAIT# PROCESS
... And what have you got so far?
createevent write
setevent write
if read
wait
enter cs
write
exit cs
sleep
reset
This what I told and he told it is incorrect
Let me Google that for you:
http://lmgtfy.com/?q=producer+consumer+c%2B%2B+pthread
Third link on first page:
http://richiejp.com/pthread-producer-consumer-example-in-c/
here's a good application that simulates the consumer-producer problem : http://sourceforge.net/projects/bufferanimation/
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.