读书人

软件工程师的自小弟我修养 - 链接、装

发布时间: 2012-11-26 11:48:49 作者: rapoo

程序员的自我修养 -- 链接、装载与库

首先声明,这是一本好书。:)


-- 但是存在一些问题,也有可能是我理解的不够。。 ?


2012.11.22

1.6.2 线程安全

互斥量(Mutex)描述说,哪个线程获取了互斥量,哪个线程就要负责释放,其他线程越俎代庖去释放互斥量是无效的。

---------------------------------

这里说法是错误的,最起码针对Linux实现的pthread_mutex是错误的。

一个简单的测试程序即可验证上述错误:

In computer science, mutual exclusion refers to the problem of ensuring that no two processes or threads (henceforth referred to only as processes) can be in their critical section at the same time. Here, a critical section refers to a period of time when the process accesses a shared resource, such as shared memory. The problem of mutual exclusion was first identified and solved by Edsger W. Dijkstra in his seminal 1965 paper titled: Solution of a problem in concurrent programming control.

也有可能windows平台的实现另有玄机吧?

------

此外,作者对于三种线程模型的看法,与我颇有差异,不过此处无硬伤,不提也罢了。

读书人网 >软件架构设计

热点推荐