搜索
热搜: 活动 交友 discuz
Hi~登录注册
高流量广告位招租 QQ:2725332302
查看: 389|回复: 0

为什么《石器时代》使用信号量?

[复制链接]

181

主题

188

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
15816
发表于 2019-7-6 18:40:08 | 显示全部楼层 |阅读模式
C++11 和 Boost.Thread 都没有提供信号量。对此 Boost 是这样解释的:

Semaphore was removed as too error prone. The same effect can be achieved with greater safety by the combination of a mutex and a condition variable. Dijkstra (the semaphore's inventor), Hoare, and Brinch Hansen all depreciated semaphores and advocated more structured alternatives. In a 1969 letter to Brinch Hansen, Wirth said "semaphores ... are not suitable for higher level languages." [Andrews-83] summarizes typical errors as "omitting a P or a V, or accidentally coding a P on one semaphore and a V on on another", forgetting to include all references to shared objects in critical sections, and confusion caused by using the same primitive for "both condition synchronization and mutual exclusion".
回复

使用道具 举报

游客
回复
您需要登录后才可以回帖 登录 | 立即注册

QQ|Archiver|手机版|小黑屋|爱上石器,你就知道石器时代 ( 沪ICP备19006672号-2 )|网站地图

GMT+8, 2019-9-24 01:53 , Processed in 0.053490 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表