[Solved] Need Share One Resource X Three Threads P Q R Write Critical Section Code Threads Use Sema Q37298354
(a) You need to share one resource X between three threads P, Q and R. Write the critical section code for each of the threads and use semaphores to guarantee exclusive access by just one of the threads at a time to the resource X (which can be accessed by just calling “XO”). (b) Rewrite the critical section code of part (a) to allow at most two of the three threads to access the resource at the same time. (c) Is your implementation in the previous two parts of this question susceptible to (i) deadlock, (ii) starvation and/or (iii) priority inversion. Explain. Show transcribed image text (a) You need to share one resource X between three threads P, Q and R. Write the critical section code for each of the threads and use semaphores to guarantee exclusive access by just one of the threads at a time to the resource X (which can be accessed by just calling “XO”). (b) Rewrite the critical section code of part (a) to allow at most two of the three threads to access the resource at the same time. (c) Is your implementation in the previous two parts of this question susceptible to (i) deadlock, (ii) starvation and/or (iii) priority inversion. Explain.
Expert Answer
Answer to (a) You need to share one resource X between three threads P, Q and R. Write the critical section code for each of the t… . . .
OR

