The following resource controller attempts to associate priorities with request:
type Level is (Urgent, Medium, Low);
task Controller is
entry Request (Level) (D:Data);
end Controlier;
task body Controller is
...
begin
loop
...
select
accept Request (Urgent) (D:Data) do
...
end;
or
when Request (Urgent) 'Count $=0 \Rightarrow$
accept Request (Medium) (D:Data) do
...
end;
or
when Request (Urgent) 'Count $=0$ and
Request (Medium) 'Count $=0 \Rightarrow$
accept Request (Low) (D:Data) do
...
end;
end select
...
end loop;
end controller;
Explain this solution and indicate under what conditions it will fail. Why would it not be advisable to extend the above solution to cope with a numeric priority which falls in the range 0 to 1000 ? Sketch an alternative solution which will cope with larger priority ranges. You may assume that the calling tasks issue simple entry calls and are not aborted.