Question: In C! Implement a solution to the critical section problem with threads using semaphores . Make a counting thread which counts by 1 each time

In C!

Implement a solution to the critical section problem with threads using semaphores. Make a counting thread which counts by 1 each time it enters its critical section to 2,000,000. Each counts to 2,000,000 for a total of 6,000,000.

use seminit, semwait, and sempost.

Make comments indicating the following sections in your code:

entry section

critical section

exit section

remainder section

Expected output:

both threads need to report the number of updates done at the end of their remainder sections.

both threads need to report the current value of the shared variable counter at the end of their remainder sections.

thread1 needs to report the number of times it got the bonus at the end of its remainder sections.

Im thread1, I did 2000000 updates and I got the bonus for 18562 times, counter = 2106222 Im thread3, I did 2000000 updates, counter = 5573136 Im thread2, I did 2000000 updates, counter = 6000000 from parent counter = 6000000

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!