Question: write by c Write a program that creates an array of length 10, then creates 8 threads. a. The first four should start creation of

write by c

Write a program that creates an array of length 10, then creates 8 threads.

a. The first four should start creation of random numbers of values between 0 and 1000, then enters their critical sections that are controlled through semaphores, and write the generated value into the pre-defined array and into a file named "Producers activity" with the following format: "Producer number- produced item number -with the value -" The total of four producers should produce a total of 10,000,000 random values

b. The second four should request entrance to their critical sections that is controlled through semaphores, read the values written in the array, and write it to the screen with the following format: "Consumer number - consumed item number-with the value -" And to a file named "Consumer activity", then exit the critical section, and repeat till the producers stop production. The total number of elements generated by the producer and consumed by the consumers should be 10,000,000 number

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!