Questions tagged [readerwriterlock]

71 questions
3
votes
3 answers

Reader-Writer Lock in Haskell

I am implementing a web-app that holds some data in memory. Some requests read this data for processing and some requests update this data. In this scenario, multiple readers can concurrently operate on the data, but a writer needs exclusive access…
donatello
  • 5,727
  • 6
  • 32
  • 56
3
votes
2 answers

How is this "container Design Pattern" called?

While creating my app. architecture I faced the need for one structure, that will be described below. I'm pretty sure, that there is a well known design pattern with the same functionality, because I think that problem, for which I develop it is…
3
votes
5 answers

How to synchronize getter and setter in threading

public class IntermediateMessage { private final ReentrantReadWriteLock readWriteLock = new ReentrantReadWriteLock(); private final Lock read = readWriteLock.readLock(); private final Lock write = readWriteLock.writeLock(); private…
codereviewanskquestions
  • 13,460
  • 29
  • 98
  • 167
3
votes
1 answer

Readers-Writers Synchronisation Issue

I am having trouble understanding why the first readers-writers problem can starve write processes, i.e.: how does the code provide reader processes with priority? Should the writer process not be able to gain a lock when one of the reader processes…
mino
  • 6,978
  • 21
  • 62
  • 75
2
votes
4 answers

Readers writers problem concurrent Java

This is an implementation of readers writers, i.e. many readers can read but only one writer can write at any one time. Does this work as expected? public class ReadersWriters extends Thread{ static int num_readers = 0; static int writing =…
Ferguzz
  • 5,777
  • 7
  • 34
  • 41
2
votes
1 answer

Ordering in ReaderWriterLock

When I use lock(){...}, I cannot garantee which thread will enter the lock first. What about ReaderWriterLock? Does it works like a FIFO for the writers or not?
Marcus
  • 113
  • 1
  • 7
2
votes
5 answers

How do I find the lockholder (reader) of my ReaderWriterLock in windbg

I've got a dump of a .Net process that has hung due to a deadlock (the gui thread is no longer responding, and my logs show that some threads have stopped responding). I have taken a snapshot and am now looking through it in windbg, and all threads…
Oskar
  • 2,234
  • 5
  • 28
  • 35
2
votes
2 answers

How to program critical section for reader-writer systems?

Lets say, I have a reader-writer system where reader and writer are concurrently running. 'a' and 'b' are two shared variables, which are related to each other, so modification to them needs to be an atomic operation. A reader-writer system can be…
user290273
2
votes
1 answer

How using readerwriterlock correctly

Hello i need to use writerreaderlock in my method. I want to know how use it correctly. I got a dictionary of ObjectA public class ObjectA { public ReaderWriterLock RWL {get;set;} public ObjectB obj {get;set;} public ObjectA() { …
Cédric Boivin
  • 10,854
  • 13
  • 57
  • 98
2
votes
2 answers

Reader-Writer using semaphores and shared memory in C

I'm trying to make a simple reader/writer program using POSIX named semaphores, its working, but on some systems, it halts immediately on the first semaphore and thats it ... I'm really desperate by now. Can anyone help please? Its working fine on…
Salamander
  • 193
  • 1
  • 2
  • 13
1
vote
1 answer

Reader-Writer Preference Using Semaphores

I'm currently working on a correct implementation of the Reader-Writer problem (see here). I found this solution in the Qt docks guaranteeing fair treatment of Reader and Writer threads by using a semaphore and mutex. The basic code is this: sem_t…
IAE
  • 2,213
  • 13
  • 37
  • 71
1
vote
0 answers

Readers-writers problem, I need to let in 5 readers per writer in the database

I need to let 5 readers per writer into the database if there's a writer waiting, otherwise, let every reader into the database Debugging this is very difficult and every time I try anything, I end up with deadlocks everywhere. Does anyone have a…
AstroD_
  • 11
  • 2
1
vote
1 answer

About shared_mutex and shared_ptr across multiple threads

I implemented code such that multiple instances running on different threads reads other instances' data using reader-writer lock and shared_ptr. It seemed fine, but I am not 100% sure about that and I came up with some questions about usage of…
1
vote
1 answer

LockRecursionException in multiple threaded function

I dont know how to describe it but I'm getting exception that schouldn't have a place when a code is good written. This exception is about issue with ReaderWriterLockSlim and it's LockRecursionException; it is appearing at…
1
vote
1 answer

Does an Arc allow an RwLock to have more than one writer?

I have this toy structure I'm playing around with: pub struct Community { pub community_contents: RwLock, } pub struct CommunityContents { pub friends: RefCell>, pub index:…
Gman man
  • 475
  • 1
  • 4
  • 8