LWN.net Logo

A realtime preemption overview

A realtime preemption overview

Posted Aug 18, 2005 7:35 UTC (Thu) by goaty (guest, #17783)
Parent article: A realtime preemption overview

Concerning the multiple reader problem, if you'll forgive my naivety, isn't it sufficient just to upgrade one reader at a time? This is assuming that upgrades are transitive, so if the upgraded reader is waiting on an un-upgraded reader, the upgrade will be passed down the chain. Assuming each lock has a linked-list of readers, this seems straightforward. Obviously once a reader releases the lock, we need to give the next reader an upgrade, as long as there are readers remaining. This should limit the scheduler overhead to be proportional to the number of locks, rather than the number of readers.


(Log in to post comments)

A realtime preemption overview

Posted Aug 19, 2005 21:43 UTC (Fri) by PaulMcKenney (subscriber, #9624) [Link]

One could indeed upgrade a single reader at a time, and on a single-CPU system this might make sense (and rumor has it that some RTOSes actually do take this approach). But on (say) a 4-CPU system, you could potentially be handling four readers at a time, and so upgrading a single reader at a time would result in delaying the high-priority waiting writer four times longer than necessary. This added scheduling delay will be unacceptable for some applications. And commodity multi-CPU systems (hyperthreading, dual cores) are becoming readily available at reasonable cost. A single-chip 4-CPU ARM system was demoed recently, so even the deep embedded CPUs are starting to take this approach.

OK, so you could upgrade N readers at a time, where N is the number of CPUs. But suppose we are doing priority inheritance for semaphores, and one of the readers blocks. Then we again have an idle CPU that could be getting readers out of the way of the high-priority waiting writer, again, needlessly degrading the waiting writer's scheduling latency.

And this latter issue causes problems even on a single-CPU system. :-(

Therefore, the current approach is to allow only one reader task at a time to hold a reader-writer lock or semaphore.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds