文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
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").
排行榜 更多 +
杀戮尖塔mod手机版下载

杀戮尖塔mod手机版下载

棋牌卡牌 下载
ok交易平台官网免费版

ok交易平台官网免费版

金融理财 下载
僵尸运行3d城市逃生

僵尸运行3d城市逃生

冒险解谜 下载