• If a c1 thread produces a c1 when no p1 are present, it has to
wait for two p1 to be produced.
• If a p1 thread produces two p1 when no c1 is present, it has to
wait for a c1 to be produced.
It takes a random amount of time, between 2 and 5 seconds, to
create each p1 or c1. You may find sleep() and rand() useful
functions for you to use.
Write synchronization code for p1 and c1 producers, as well as the
shipper, that enforces these constraints. Note that:
• There is one p1 thread and one c1 thread.
• There is a s1 thread that consumes two p1 and one c1 to produce a
sale package.
When an element is created you are to output what was produced. For
example,
We have a p1.
We have a c1.
When you have two p1 and one c1, they are consumed to form a sales
package. For example,
We now have a s1!
write a c PROGRAMM
• If a c1 thread produces a c1 when no p1 are present, it has to wait for two p1 to be produced. • If a p1 thread produc
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am