文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Mesa style monitor 为什么使用while而非if?

Mesa style monitor 为什么使用while而非if?

时间:2010-05-28  来源:sinodragon21

Mesa vs. Hoare monitors

Need to be careful about the precise definition of signal and
wait.
Mesa-style: (Nachos, most real operating systems)
Signaller keeps lock, processor
Waiter simply put on ready queue, with no special priority.
(in other words, waiter may have to wait for lock)
Hoare-style: (most textbooks)
Signaller gives up lock, CPU to waiter; waiter runs
immediately
Waiter gives lock, processor back to signaller when it exits
critical section or if it waits again.
Above code for synchronized queuing happens to work with
either style, but for many programs it matters which you are
using. With Hoare-style, can change "while" in
RemoveFromQueue to an "if", because the waiter only gets
woken up if item is on the list. With Mesa-style monitors,
waiter may need to wait again after being
woken up, because some other thread may have acquired the
lock, and removed the item, before the original waiting thread
gets to the front of the ready queue.
This means as a general principle, you almost always need to
check the condition after the wait, with Mesa-style monitors (in
other words, use a "while" instead of an "if").
排行榜 更多 +
哥布林弹球b服手游下载

哥布林弹球b服手游下载

休闲益智 下载
小马样式盒游戏下载

小马样式盒游戏下载

休闲益智 下载
异变小镇中文版下载安装

异变小镇中文版下载安装

冒险解谜 下载