Quantitative Analysis.
Trading Platform.
Python for Excel.
Author.
I.Installation.
II.OTS Scheduler.
1.Threading primitives.
A.Encapsulation of primitives.
B.Preventing starvation.
a.RWMutex.
b.Exception safe locking of RWMutex.
C.Preventing race condition.
D.Barriers.
2.NonBlockingQueue.
3.ThreadPool.
4.ThreadMaster.
5.Scheduler implementation.
III.OTS Python Object Browser.
Bibliography.
Forum Index Contents Downloads

Preventing starvation.


onsider several threads reading some piece of data. We protect that data with a shared mutex. Each thread obtains a shared lock before accessing the data and releases the lock after the access is completed. It is possible that the data is being read by at least one thread at all times. If some thread also aims to write into the data field then such thread needs exclusive ownership. If the thread simply attempts a lock of the shared mutex and waits for the exclusive ownership then the waiting time may be too long. This is a situation of starvation: one of the threads is unable to obtain a resource that it requires. The RWMutex provides a solution for the difficulty.




a.RWMutex.
b.Exception safe locking of RWMutex.

Forum Index Contents Download


















Copyright 2009.