skydevgit / crisscross

Automatically exported from code.google.com/p/crisscross
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Mutex Types #22

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Recursive mutexes, and read/write locks would be nice, thanks.

Original issue reported on code.google.com by ARPl...@gmail.com on 18 May 2007 at 6:08

GoogleCodeExporter commented 9 years ago
Alastair, could you state (in detail) what these are and how they're meant to be
used, so that it's all here for my reference?

Original comment by steven.n...@gmail.com on 20 May 2007 at 9:08

GoogleCodeExporter commented 9 years ago
Sure.

Recursive mutexes do not cause single-thread deadlocks. With a normal mutex:

Lock();
Lock();
Unlock();
Unlock();

would deadlock after the second Lock() call. With a recursive mutex, this would 
not 
happen, and only after the second Unlock() call would the mutex be available 
for 
other threads to lock.

Read/Write locks are to allow concurrent reading, but only allowing one thread 
to 
write at a time.

The ReadLock operation would block until there was no write lock and would then 
continue. The WriteLock operation would block until there was no write lock and 
no 
read locks before allowing operation to continue. Unlock works as expected.

This is so that multiple threads can read data from a class at the same time, 
but 
when data is being written only one thread can access it.

Original comment by ARPl...@gmail.com on 21 May 2007 at 12:53

GoogleCodeExporter commented 9 years ago
Git commit 46a26211aa68e9ad84d481629d6ce1ebef0d9f85 contains read/write locks 
and a rewritten mutex 
interface. See attached for the changes.

Original comment by steven.n...@gmail.com on 31 Jan 2009 at 3:18

Attachments: