由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - question about the read/write locker
相关主题
连续release mutex/semphore 2次有什么问题吗?Monitor和semaphore, mutex是什么关系?
pthread mutex能不能用与thread和process之间问个semaphore 和 mutex的问题
Restaurant Reservation System...编程题又一道
about critical section请问这些问题应该在那种书上找到答案?
how to answer this question, thanksc++是不是准备加一个glue layer把系统给隔离出来?
mutex和semaphore的差别到底是什么?问一个读写锁的问题
谁能推荐一个read-writer lock的C++实现? (转载)java里用synchronized包住block就可以保护多线程同步问题了,这就是c里面的mutex吧?
精华区翻出来的MS老题,thread safeMulti-thread可以mutex锁资源,Multi-process怎么锁资源?
相关话题的讨论汇总
话题: semaphore话题: locker话题: write话题: read话题: writes
进入Programming版参与讨论
1 (共1页)
g*********s
发帖数: 1782
1
learning read/write locker and find the following on line:
http://doc.qt.nokia.com/qq/qq11-mutex.html
i just don't get it. how does it works? it seems to me lockWrite() just
directly set the semaphore to its max value. how are multiple writes
prevented?
g*********s
发帖数: 1782
2
can any da niu share ideas of implementing class semaphore and class
rwlock using pthread mutex only?

【在 g*********s 的大作中提到】
: learning read/write locker and find the following on line:
: http://doc.qt.nokia.com/qq/qq11-mutex.html
: i just don't get it. how does it works? it seems to me lockWrite() just
: directly set the semaphore to its max value. how are multiple writes
: prevented?

t****t
发帖数: 6806
3
if you want pthread, pthread has rwlock...

【在 g*********s 的大作中提到】
: can any da niu share ideas of implementing class semaphore and class
: rwlock using pthread mutex only?

g*********s
发帖数: 1782
4
i want to learn how to implement it.
somehow my pthread only has header and lib files. where can i find its
source code?

【在 t****t 的大作中提到】
: if you want pthread, pthread has rwlock...
p***o
发帖数: 1252
5
http://sourceware.org/pthreads-win32/

【在 g*********s 的大作中提到】
: i want to learn how to implement it.
: somehow my pthread only has header and lib files. where can i find its
: source code?

g*********s
发帖数: 1782
6
is it the same as linux version?

【在 p***o 的大作中提到】
: http://sourceware.org/pthreads-win32/
p***o
发帖数: 1252
7
Obviously the implementation is not.

【在 g*********s 的大作中提到】
: is it the same as linux version?
s**********o
发帖数: 197
8
for multiple writes, the first one fills semphore full gets in.

【在 g*********s 的大作中提到】
: learning read/write locker and find the following on line:
: http://doc.qt.nokia.com/qq/qq11-mutex.html
: i just don't get it. how does it works? it seems to me lockWrite() just
: directly set the semaphore to its max value. how are multiple writes
: prevented?

z***e
发帖数: 5393
9
It seems the semaphore is used to block readers.
so for "semaphore++", if semaphore reaches maxReaders, the instruction will
be blocked. That's why lockWrite() just set the semaphore to the max value
so no other reader thread will enter.
for multiple writes, it's protected by:
QMutexLocker locker(&mutex);

【在 g*********s 的大作中提到】
: learning read/write locker and find the following on line:
: http://doc.qt.nokia.com/qq/qq11-mutex.html
: i just don't get it. how does it works? it seems to me lockWrite() just
: directly set the semaphore to its max value. how are multiple writes
: prevented?

1 (共1页)
进入Programming版参与讨论
相关主题
Multi-thread可以mutex锁资源,Multi-process怎么锁资源?how to answer this question, thanks
C++ InitializeCriticalSection问题mutex和semaphore的差别到底是什么?
EBUSY 的定义谁能推荐一个read-writer lock的C++实现? (转载)
c++问题精华区翻出来的MS老题,thread safe
连续release mutex/semphore 2次有什么问题吗?Monitor和semaphore, mutex是什么关系?
pthread mutex能不能用与thread和process之间问个semaphore 和 mutex的问题
Restaurant Reservation System...编程题又一道
about critical section请问这些问题应该在那种书上找到答案?
相关话题的讨论汇总
话题: semaphore话题: locker话题: write话题: read话题: writes