Aviad Ezra
Check me out on the web at Design Codes.
I am a software developer and architect specializing in development of soft real time applications using .NET technologies. I have over 9 years of experience in architecture, design and development of successful applications.
Programming in the Age of Concurrency: Software Transactional Memory
Jan 31, 2010 at 5:22 PMWhen STM detects a long transaction that conflict - it immediately switches to more pessimistic approach (which works a lot like reader/writer locks).
For such cases STM employ the use of a contention manager (CM) that detect conflicts and decides, according to a pre-defined policy, which read-mode technique to use. By default, when transaction starts, CM attempts to use the optimistic read technique, once it detects a conflict, it considers switching to a more pessimistic approach (using reader/writer locks) depending on the transaction size (defined by the reads count) and the re-execution count.
As you mentioned, a naive optimistic read technique with automatic execution schema can lead to starvation in cases where a large transaction conflict with smaller transactions that execute periodically.