I am currently learning about semaphores as a means of preparing for next semester (Im going back to uni) and while answer questions in an Operating Systems book, I got stuck on a question. Briefly:
A processor concurrently runs process A & B that arrive after each other (execution time and speed not given).I need to make sure that statement G does not commence until D has completed.Code:
procedure A procedure B
begin begin
A; F;
B; G;
C; H;
D; I;
E; J;
end end
It says I have to do this by determining the number of semaphores, their type, the initial state for each and the placement in the code of the semaphore operations wait and signal
I have done the following but do not know if it is right. Semaphore S1=1 and S2=0 at startAll comments welcome because I want to make sure I understand this properly.Code:
procedure A procedure B
begin begin
A; F;
wait(S1); wait(S1);
B; G;
C; H;
signal(S1); signal(S1);
D; I;
signal(S2); wait(S2);
E; J;
end end
Thanx
Jules