Question: Question 1 : Read - Write Semaphore ( Max Mark: 3 0 / 1 0 0 ) This question requires you to implement Read -
Question : ReadWrite Semaphore Max Mark: This question requires you to implement ReadWrite semaphores for xv Two files semaphore.h and semaphore.c are provided for you as a reference design for semaphore implementation in xv A structure representing a semaphore is defined in semaphore.h There are three functions associated with the semaphore initsema downsema and upsema that initialize, decrement and increment a semaphore respectively. The code for these functions is provided in semaphore.c Study them in conjunction with the lecture slides to make sure you understand them. You may want to compile them with the xv kernel and see how it works with the user program sematest.c provided for you. In order to do so add the function provided in syssematest.c to sysfile.c and make sematest a system call for xv in the usual way. Then compile xv with make qemu CPUS and run sematest. Running xv on a single CPU prevents the displayed messages from being garbled. Task: Implement ReadWrite Semaphore that can be used to solve the ReaderWriter problem as discussed in class. In semaphore.h there is already an empty struct rwsemaphore. There are also five associated function prototypes: void initrwsemastruct rwsemaphore rws; int downreadsemastruct rwsemaphore rws; int upreadsemsstruct rwsemaphore rws; void downwritesemastruct rwsemaphore rws; void upwritesemastruct rwsemaphore rws; You will need to design an appropriate struct rwsemaphore, and implement these five functions in semaphore.c Your struct rwsemaphore should be defined using the semaphore in semaphore.c That is do not use the xv locks. Note AUT that you do not need to wake up the waiting threadsprocesses in the same order as semaphores are requested. There is a function called sysrwsematest in syssematest.c Make rwsematest a system call like sematest above. A user test program has been provided in rwsematest.c It makes use of this system call. The test program conducts three tests read lock test, write lock test, and read & write lock test. You will need to work out from this program what the correct output of each test should be Capture your test output and paste it into a document. Then explain why this output shows that your implementation is correct.
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
