
응답 절차
procedure Are_you_open?(Client,Semaphore)
begin
if State = S1
then State <- S2
Send("Open(Semaphore,Client)")
else
if State = S2
then Send("Closed(Semaphore,Client)")
end
procedure Ready(Server, Semaphore)
begin
State <- S1
end

응답 절차
procedure C_Job(User,Client,Document)
begin
if State = SA
then State <- SB
Send("Are_you_open?(Client,
SEMAPHORE(Semaphore_Index))")
else
if State = SB
then Send("Try_later(Client,User,
Client_is_busy)")
else
if State = SC
then Send("Try_later(Client,User,
All_Servers_are_busy)")
end
procedure Open(Semaphore,Client)
begin
if State = SB
then State <- SC
Send("S_Job(Client,Server,
Document)")
end
procedure Closed(Semaphore,Client)
begin
Countdown <- Waiting_Period
Send("Wait(Client,Client)")
end
procedure Wait(Client,Client)
begin
Countdown <- Countdown - 1
if Countdown > 0
then Send("Wait(Client,Client)")
else Send("Are_you_open?(Client,
SEMAPHORE(Semaphore_Index))")
end
procedure C_Ready(Server,Client)
begin
State <- SA
end
메시지 정보(i, j, k는 자연수)



C_Job와 Wait 함수에서 바뀐 부분에 밑줄을 그어 놓았다.
procedure C_Job(User,Client)
begin
if State = SA
then State <- SB
for Semaphore_Index <- 1 step 1 until Number_of_Servers
Send("Are_you_open?(Client,SEMAPHORE(Semaphore_Index))")
else
if State = SB
then Send("Try_later(Client,User,Client_is_busy)")
else
if State = SC
then Send(,Try_later(Client,User,All_Servers_are_busy)')
end
procedure Wait(Client,Client)
begin
if State = SB
then Countdown <- Countdown -1
if Countdown > 0
then Send("Wait(Client,Client)")
else
if Countdown < 0
then Countdown <- 0
else for Semaphore_Index <- 1 step 1 until Number_of_Servers
Send("Are_you_open?(Client,SEMAPHORE(Semaphore_Index))")
end
과제 B의 정답으로 올바른 것을 표기하라.
(a) CLIENT(1)의 문서가 SERVER(1)과 SERVER(2)에서 인쇄될 것이다.
CLIENT(2)의 문서는 인쇄되지 않을 것이다.
(b) CLIENT(1)의 문서가 SERVER(1)에서 한 번 인쇄될 것이다.
CLIENT(2)의 문서가 SERVER(2)에서 한 번 인쇄될 것이다.
(c) CLIENT(1)의 문서가 SERVER(1)에서 한 번 인쇄될 것이다.
CLIENT(2)의 문서가 SERVER(1)에서 한 번 인쇄될 것이다.
(d) CLIENT(1)의 문서가 SERVER(2)에서 한 번 인쇄될 것이다.
CLIENT(2)의 문서가 SERVER(2)에서 한 번 인쇄될 것이다.
(e) CLIENT(1)의 문서는 인쇄되지 않을 것이다.
CLIENT(2)의 문서가 SERVER(1)과 SERVER(2)에서 인쇄될 것이다.
1 1 1 1 1 2 2 1 1 1 1 2 1 3 3 1 1 1 1 2 1 1 3 1 4 3 1 1 1 1 2 1 1 1 2 5 4 1 1 1 1 2 1 1 3 1 1 4 1 6 4 1 1 1 1 2 1 1 1 2 1 2 2 7 4 1 1 1 1 2 1 1 1 2 1 1 3 8 4 1 1 1 1 2 1 1 3 1 1 2 2 9 4 1 2 1 1 3 1 1 1 2 1 2 2 10 4 2 1 1 1 2 1 2 2 1 2 1 2 11 4 1 1 1 1 2 1 2 2 1 1 1 2 12 4 2 2 1 2 1 2 1 2 2 2 2 2