A concurrent system consists of 3 processes using a shared resource R in a…
PYQ GATE 1997
A concurrent system consists of 3 processes using a shared resource R in a non-preemptible and mutually exclusive manner. The processes have unique priorities in the range 1 to 3, with 3 being the highest priority. It is required to synchronize the processes such that the resource is always allocated to the highest-priority requester. The pseudocode for the system is as follows.
Shared data
mutex: semaphore = 1; /* initialized to 1 */
proceed[3]: semaphore = 0; /* all initialized to 0 */
R_requested[3]: boolean = false; /* all initialized to false */
busy: boolean = false; /* initialized to false */Code for processes
begin process
my-priority: integer;
my-priority := ____; /* unique value in the range 1 to 3 */
repeat
request_R(my-priority);
P(proceed[my-priority]);
{use shared resource R}
release_R(my-priority);
forever
end process;Procedure
procedure request_R(priority);
begin
P(mutex);
if busy = true then
R_requested[priority] := true;
else
begin
busy := true;
V(proceed[priority]);
end;
V(mutex);
end;Give the pseudocode for the procedure release_R.
Sign up free to check your answer
Sign up freeLoading lesson…

