Question: Write a c++ program that creates a semaphone using an atomic counter, a mutex and a condition variable and does the following: I. Given a
Write a c++ program that creates a semaphone using an atomic counter, a mutex and a condition variable and does the following: I. Given a statement s-screate (d where screate is a Keyword and S is the name of the semaphore, and d is an integer constant used as the initial value of the semaphore S, it will set up the semaphore S, thus initializing and setting up the associated waiting queue. Given a command II. wait(S) where wait is a keyword, and S is a semaphore, it will implement the semantics of wait. lI. Given a command signal(S) where signal is a keyword, and S is a semaphore, it will implement the semantics of signal You must provide a trace of the execution of the program and document any arbitrary, but valid, sequence by two concurrent processes synchronized by semaphores. Your output must display these results a) The value and the status of the semaphore queue; b) the instructions being executed at each cycle; c) and annotations explaining the event that arises in each cycle - meaning why a particular command in the arbitrary sequence is "not valid" and hence ignored
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
