→ lightergogo:P(),V()就是Semaphore的wait(),signal() 03/03 18:29
Give the follwing variables and their initial values as follows:
X:integer,initial value is 0
y:integer,initial value is 23
m:general semaphore,initial value is 1
m1:general semaphore,initial value is 0
For each of the following program,list values possible for x when the
program terminates. Note that"cobegin P1||P2 ;coend" means P1 and P2
are executed concurrently, and ":=" is the assignment operator.
(1)cobegin P(m1);x:=x+1;V(m) || P(m);x=y+1;V(m1) coend
(2)cobegin V(m1);x:=x+1;P(m) || V(m1);x:=y+1;P(m1); coend
答案(1) 25 (2) 1,24 or 25
我想請問一下P(m1) V(m1) P(m) V(m)是什麼意思呢?
另外(2)的結果是怎麼推算出來的
謝謝各位指教
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.41.112.218
※ 編輯: bigrat2 來自: 114.41.112.218 (03/03 18:26)