Question: Six drummers sit in a circle. Each drummer has a drum, along with a drumstick to their left and their right. Drummers go back and
Six drummers sit in a circle. Each drummer has a drum, along with a drumstick to their left and their right. Drummers go back and forth between brainstorming and drumming. However, they cannot drum unless they are holding each of the two drumsticks to their sides. Consider the following pseudocode which attempts to simulate drummers in such a way that enforces mutual exclusion of the drumsticks:
array of semaphores initialized to
Semaphore drumstick;
void drummerint i
whiletrue
brainstorm;
semWaitdrumsticki;
semWaitdrumsticki mod ;
drum;
semWaitdrumsticki mod ;
semWaitdrumsticki;
Void main
parbegindrummer drummer drummer drummer drummer drummer
Draw the resource allocation diagram
Could this lead to deadlock? Use your resource allocation diagram to justify your answer. Additionally, if it could lead to deadlock, describe how you would modify it so that deadlock is not possible
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
