Question: Please do it in c + + and make sure to show the output is correct with differentfrom the internet and please dont useChatGPTIn this
Please do it in c and make sure to show the output is correct with differentfrom the internet and please dont useChatGPTIn this lab, you will simulate one of the classical synchronization problems to see how the semicritical section problem could be implemented using binary and counting semaphores.Three readers and two writers characterize five processes.Up to two reader processes can be inside their critical section without any writer process. For thewriter process to go into its critical section, it should check whether any reader or writer processis in the critical section.The critical section in this problem is reading the shared data buffer for reader processes andupdating the shared data buffer for writer processes. Implementing real shared data for readersand writers is optional, but you must specify the following things in your sample output. When the reader or writer process enters its critical section, it must report whether any readersor writers other than itself. You may print out the data you read or write when implementing a buffer. Optional You must include the Panic Messages generating function when the rules behind this semicritical section problem are not observed. If your solution is correct, the panic message should notbe printed.You run a random number generator function in your main program to choose a process toexecute. The selected process starts resumes execution. After single instruction, it will bereturned to the main function, and the following process to run will be chosen by the result ofanother random number generator function. You should force each process to run precisely oneinstruction, then returns and wait for its turn.Do not use multithreading, mutex, and semaphore features from the programming language andoperating system level. You are building these from scratch in this project, not using existingtools. You should implement this project with a switch statement in C or CEach reader or writer process comprises one big switch statement and will be returned aftereach instruction. You need to keep track of the global program counter per process to resume atthe right place.Subproject : You should implement this with binary and counting semaphores.Subproject : You should implement this with the TestAndSet function.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
