The algorithm uses the test-and-set instruction is shown in the
following.(12%)
waiting[i] = true;
key = true;
while(waiting[i] and key) do key = test-and-set(lock);
waiting[i] = false;
CRITICAL SECTION
j=i+1 mod n;
while ((j<>i) and (not waiting[j])) doj=j+1 mod n;
if j=i then
lock=false;
else waiting[j]=false;
想問第三題,Can we remove waiting[i]=false statement? Why?
可否舉個例子給我看...
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.193.80.151