爱上石器,你就知道石器时代

 找回密码
 立即注册
查看: 1926|回复: 1

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

[复制链接]

185

主题

196

帖子

3万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
36975
发表于 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".
回复

使用道具 举报

0

主题

11

帖子

41

积分

新手上路

Rank: 1

积分
41
发表于 2020-2-18 20:10:51 | 显示全部楼层
学习了 学习了
回复

使用道具 举报

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

本版积分规则

QQ|Archiver|手机版|小黑屋|爱上石器,你就知道石器时代

GMT+8, 2024-4-27 05:21 , Processed in 0.054642 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

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