Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Programming Language : C Assignment description: Implement a solution to the critical section problem with threads using semaphores. You will modify the same code as
Programming Language : C
Assignment description: Implement a solution to the critical section problem with threads using semaphores. You will modify the same code as in the previous programming assignment (PA2), but you must add a third 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. You will need to read about semaphore operations from Linux manual pages. The important ones are 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 thread 3.1 did 2000000 updates, counter =5573136 Im thread2, I did 2000000 updates, counter =6000000 from parent counter =6000000Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started