c program about multithreading
Budget: $10 – $15 USD
* The product type should be 1 or 2 depending on the process that created the product
* product id should increase by one each time one is produced
* consumer id will always be 1,2,3, or 4 depending on which thread consumer consumes the product
*consumer count will increase by 1 each time one is consumed
And product type should only be 1 or 2
i think i need to change the code up a bit and add condition variables and locks .But stuck at that
I have most of it done but it has some issues.
the errors are but i don't know much about the
Your consumer process (the parent process) creates a queue, and it creates four threads that are supposed to read from the queue, but then it joins those same four threads before it ever puts anything in to the queue. How is that supposed to work?
Your consumer process joins the four consumer() threads, but you have not provided any way for the consumer() function to ever return. What's the point of join()ing it in that case? and what's the point of putting any code after the join() calls?
Your put(Q, value) returns a boolean value to indicate success or failure (Q full). But the call site never tests the return value. Likewise, get(Q) prints a message if the queue is empty, but the caller has no way to know that the call failed.
* product id should increase by one each time one is produced
* consumer id will always be 1,2,3, or 4 depending on which thread consumer consumes the product
*consumer count will increase by 1 each time one is consumed
And product type should only be 1 or 2
i think i need to change the code up a bit and add condition variables and locks .But stuck at that
I have most of it done but it has some issues.
the errors are but i don't know much about the
Your consumer process (the parent process) creates a queue, and it creates four threads that are supposed to read from the queue, but then it joins those same four threads before it ever puts anything in to the queue. How is that supposed to work?
Your consumer process joins the four consumer() threads, but you have not provided any way for the consumer() function to ever return. What's the point of join()ing it in that case? and what's the point of putting any code after the join() calls?
Your put(Q, value) returns a boolean value to indicate success or failure (Q full). But the call site never tests the return value. Likewise, get(Q) prints a message if the queue is empty, but the caller has no way to know that the call failed.