Question: I have a producer & consumer C program .. I am supposed to use threads and metaphores(not Mutex) is in Unix : i have 3
I have a producer & consumer C program .. I am supposed to use threads and metaphores(not Mutex) is in Unix : i have 3 arrays a: 0-19 b: 1-20 C : [20] elements all initilized to zero ..
i'm supposed to create 3 threads 2 producers and 1 consumer ! the producer reads the value of a & b and sums them in C and updates global sum variable .
this is supposed to be the output :

Output from a sample run can be Producer 1 has written c[0] and updated global sun. Nunber of itens available for consuner: 1. Producer 2 has written c[1] and updated global sun. Number of itens available for consumer: 2. Consuner 1 has read c[0] 1 Consumer 1 has read global summ4 Nunber of itens available for consumer 1 Producer has written c[21 and updated guobau sun. Number of itens available for consumer: 2. Consumer 1 has read c 1] 3 Consuner 1 has read global suna9 Nunber of itens available for consuner: 1. Producer 1 has written c[3] and updated global sun. Nunber of itens available for consuner: 2. Consuner 1 has read c[2] 5 Consuner 1 has read global sun 16 Number of items avatlable for consumer 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
