J
J.Marsch
Issue:
I have 3 threads, syncing with a ReaderWriterLock (in "real life", there
will be more).
Thread 1 (there could be any number of these) Gets a read lock with infinite
timeout. It runs in a loop. The readlocks are requested and released very
often.
Thread 2 (only one, this is my deadlock testing thread) represents a longer
running process. It gets a ReadLock as well.
(so far the world is good)
Thread 3 (timer thread, there will only ever be one of these) requests a
Write Lock with a 5 second timeout.
Thread 3 fails to get the WriteLock ApplicationException is thrown. This is
expected behavior as well -- the purpose of the test is to force the
writelock to time out.
Now here's the part that looks like a bug:
Even though Thread 3 failed to acquire the lock, the ReaderWriter stops
handing out Readlocks -- just like it would if the write lock were in force.
It does not resume handing out readlocks until Thread 2 releases its
readlock (presumably this frees an internal deadlock on the readerwriter
lock, allowing it to clear the failed write lock).
My problem: Using timeouts on ReaderWriterLocks appears to be a useless
gesture, as it appears to leave the structure in an unstable state.
Further, since the timeouts don't work, I'm left with a potential deadlock
in my applicaiton.
Have I got something wrong here, or is there a problem?
I have 3 threads, syncing with a ReaderWriterLock (in "real life", there
will be more).
Thread 1 (there could be any number of these) Gets a read lock with infinite
timeout. It runs in a loop. The readlocks are requested and released very
often.
Thread 2 (only one, this is my deadlock testing thread) represents a longer
running process. It gets a ReadLock as well.
(so far the world is good)
Thread 3 (timer thread, there will only ever be one of these) requests a
Write Lock with a 5 second timeout.
Thread 3 fails to get the WriteLock ApplicationException is thrown. This is
expected behavior as well -- the purpose of the test is to force the
writelock to time out.
Now here's the part that looks like a bug:
Even though Thread 3 failed to acquire the lock, the ReaderWriter stops
handing out Readlocks -- just like it would if the write lock were in force.
It does not resume handing out readlocks until Thread 2 releases its
readlock (presumably this frees an internal deadlock on the readerwriter
lock, allowing it to clear the failed write lock).
My problem: Using timeouts on ReaderWriterLocks appears to be a useless
gesture, as it appears to leave the structure in an unstable state.
Further, since the timeouts don't work, I'm left with a potential deadlock
in my applicaiton.
Have I got something wrong here, or is there a problem?