Á¦ 7ȸ ±¹Á¦ Á¤º¸ ¿Ã¸²ÇǾƵå 3¹ø¹®Á¦ÀÇ Ã·ºÎ ¹®¼­

¹®¼­ 1: ¼¼¸¶Æ÷¾îÀÇ ¼Ó¼º

¹®¼­ 2: Ŭ¶óÀ̾ðÆ®ÀÇ ¼Ó¼º

¹®¼­ 3: ¸Þ½ÃÁö¿¡ ´ëÇÏ¿©

¹®¼­ 4: ¹®Á¦ A.3ÀÇ ´ä¾ÈÁö

¹®¼­ 5: ¹®Á¦ A.1, A.2ÀÇ ´ä¾ÈÁö (³»¿ë¾øÀ½)

¹®¼­ 6: °úÁ¦ BÀÇ ¼³¸í°ú ´ä¾ÈÁö

¹®¼­ 7: ¹®Á¦ C.1ÀÇ ´ä¾ÈÁö (³»¿ë¾øÀ½)

¹®¼­ 8: ¹®Á¦ C.2ÀÇ ´ä¾ÈÁö (³»¿ë¾øÀ½)


¹®¼­ 1: ¼¼¸¶Æ÷¾îÀÇ ¼Ó¼º

ÀÀ´ä ÀýÂ÷

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

¹®¼­ 2: Ŭ¶óÀ̾ðÆ®ÀÇ ¼Ó¼º

ÀÀ´ä ÀýÂ÷

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

¹®¼­ 3: ¸Þ½ÃÁö¿¡ ´ëÇÏ¿©

¸Þ½ÃÁö Á¤º¸(i, j, k´Â ÀÚ¿¬¼ö)


¹®¼­ 4: ¹®Á¦ A.3ÀÇ ´ä¾ÈÁö


¹®¼­ 5: ¹®Á¦ A.1, A.2ÀÇ ´ä¾ÈÁö

¡¡


¹®¼­ 6: °úÁ¦ BÀÇ ¼³¸í°ú ´ä¾ÈÁö

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)¿¡¼­ ÀμâµÉ °ÍÀÌ´Ù.


¹®¼­ 7: ¹®Á¦ C.1ÀÇ ´ä¾ÈÁö

¡¡


¹®¼­ 8: ¹®Á¦ C.2ÀÇ ´ä¾ÈÁö

¡¡


Á¦ 12ȸ ±¹Á¦ Á¤º¸ ¿Ã¸²ÇǾƵå 6¹ø¹®Á¦ÀÇ Ã·ºÎ ³»¿ë

 types.inÀÇ ³»¿ë

 

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