Due date: July 13, 2022 How to submit? : Email your source code and sample result In this lab, you will simulate one of
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Due date: July 13, 2022 How to submit? : Email your source code and sample result In this lab, you will simulate one of
Due date: July 13, 2022 How to submit? : Email your source codeand sample result In this lab, you will simulate one of theclassical synchronization problems to see how the (semi) criticalsection problem could be implemented using binary and countingsemaphores. The lab is due in 2 weeks, July 13, 2022. 3 readers and2 writers characterize 5 processes. Up to two reader processes canbe inside their critical section without any writer process. Forthe writer process to go into its critical section, it should checkwhether any reader or writer process is in the critical section.The critical section in this problem is reading the shared databuffer for the reader and updating the shared data buffer forwriter processes. It is up to you to implement any shared data forreaders and writers, but you must specify the following things inyour sample output. • When the reader or writer enters its criticalsection, it has to report whether there are any reader(s) orwriter(s) other than itself. • You may print out the data you reador write when implementing an actual buffer. (Optional) • You mustprint out “Panic Messages” when the rules behind this semi-criticalsection problem are not observed. You run the random numbergenerator function in your main program to choose a process toexecute. The selected process starts (resumes) execution, and afterone instruction, it will be returned. (You should force eachprocess to run precisely one instruction, then return and wait forits turn.) You can implement this using a switch statement in C orC++. Do not use any multi-threading or mutex feature from aprogramming language. Each process is one big switch statement andwill be returned after each instruction. You need to keep track ofthe program counter of each process to resume at the right placeonce it is chosen to run by keeping a global counter variable perprocess. Subproject 1: You should implement binary and countingsemaphores as studied in the class for this project. Subproject 2:You should implement a test and set operation as studied in theclass for this project.