Questions tagged [readerwriterlock]
71 questions
22
votes
5 answers
Faster TMultiReadExclusiveWriteSynchronizer?
Is there a faster kind of TMultiReadExclusiveWriteSynchronizer out there? FastCode perhaps?
Starting with Windows Vista, Microsoft added a Slim Reader/Writer lock. It performs much better than Delphi's TMultiReadExclusiveWriteSynchronizer.…

Ian Boyd
- 246,734
- 253
- 869
- 1,219
11
votes
5 answers
How would you simplify Entering and Exiting a ReaderWriterLock?
This seems very noisy to me. Five lines of overhead is just too much.
m_Lock.EnterReadLock()
Try
Return m_List.Count
Finally
m_Lock.ExitReadLock()
End Try
So how would you simply this?

Jonathan Allen
- 68,373
- 70
- 259
- 447
9
votes
6 answers
Cross-process read-write synchronization primative in .NET?
Is there a read/write locking mechanism that works across processes (similar to Mutex, but read/write instead exclusive locking)? I would like to allow concurrent read access, but exclusive write access.

Jeremy
- 44,950
- 68
- 206
- 332
9
votes
2 answers
What are the differences among mutex, semaphore and read write locks
Any real-time scenarios explaining on each would be appreciated.
Is there any other way to handle synchronization apart from these in pthreads.
How do mutex differ from recursive-mutexes(any real-time scenario)?

user2601350
- 207
- 1
- 3
- 12
7
votes
2 answers
What are the real downsides of using ReaderWriterLock
We have project targeted .NET 2.0 RTM (yes, it should be .NET 2.0 RTM, we have some orthodox clients). And I'm just wondering what are the downsides of ReaderWriterLock? Why is it so bad that everyone tell "don't use it, try to use something else…

Dmitrii Lobanov
- 4,897
- 1
- 33
- 50
6
votes
2 answers
C++ Syncing threads in most elegant way
I am try to solve the following problem, I know there are multiple solutions but I'm looking for the most elegant way (less code) to solve it.
I've 4 threads, 3 of them try to write a unique value (0,1,or 2) to a volatile integer variable in an…

Hawk89
- 233
- 1
- 2
- 12
5
votes
5 answers
Swapping buffers in single-writer-multiple-reader threads
The Story
There is a writer thread, periodically gathering data from somewhere (in real-time, but that doesn't matter much in the question). There are many readers then reading from these data. The usual solution for this is with two reader-writer's…

Shahbaz
- 46,337
- 19
- 116
- 182
5
votes
3 answers
ReaderWriterLockSlim vs. Monitor
I have an IDictionary implementation that internally holds n other Dictionary and distributes that insertions by the HashCode of the key to the invidual sub-dictionaries. With 16 sub-dictionaries, the number of collisions…

Rauhotz
- 7,914
- 6
- 40
- 44
4
votes
2 answers
Fair Reader-Writer Ticket Spinlock in C++ running slow
I have recently implemented a fair reader-writer ticket-spinlock in C++. The code is fairly simple and I thought it was working great. I have integrated the spinlock into a larger application and I noticed that on some rare occasions, the code is…

Guillaume Holley
- 71
- 4
4
votes
3 answers
Reader Writer Lock supporting low priority writers
I am trying to find (or implement) a Reader/Writer Lock which supports low-priority writers, but have been unsuccessful in researching any existing solutions.
What I mean by low-priority writer is: "will yield its place in line" to incoming readers…

mmocny
- 8,775
- 7
- 40
- 50
4
votes
1 answer
ReaderWriterLock not working in ServiceBehavior constructor
I have a WCF service where InstanceContextMode is Single and ConcurrencyMode is Multiple. The aim is to create a cache of values on instantiation, without holding up other service calls not reliant upon the creation of the cache.
This way only…

Microsoft Developer
- 1,919
- 1
- 20
- 27
4
votes
4 answers
Writer/Reader buffer mechanism for large size - high freq data c++
I need a single writer and multiple reader (up to 5) mechanism that the writer pushes the data of size almost 1 MB each and 15 packages per second continuously which will be writtern in c++. What I’m trying to do is one thread keeps writing the data…

user2955554
- 309
- 3
- 14
3
votes
2 answers
Reader/Writer: multiple heavy readers, only 1 write per day
I have a huge tbb::concurrent_unordered_map that gets "read" heavily by multiple (~60) threads concurrently.
Once per day I need to clear it (either fully, or selectively). Erasing is obviously not thread safe in tbb implementation, so some…

Santiago
- 379
- 3
- 14
3
votes
0 answers
When is writer-preferred reader-writer lock used?
I know there are many reader-preferred rwlock, and there are even more aggressive design such as RCU, which are usually considered reader-preferred.
But what if the writers are not much less than the readers? I know a writer-only rwlock will fall…

Zihan
- 405
- 3
- 13
3
votes
2 answers
How can I implement a C++ Reader-Writer lock using a single unlock method, which can be called be a reader or writer?
I'm working on a project, which requires the use of specific OS abstractions and I need to implement a reader-writer lock using their semaphore and mutex. I currently, have a setup in the format:
class ReadWriteLock
{
public:
…

L-S
- 107
- 7