Maxim S. Shatskih Guest
|
Posted: Thu Jul 17, 2008 9:05 pm Post subject: RTOSes |
|
|
My notions about the possible OS design with respect to latency and about
RTOSes.
I see 3 possible OS designs:
1) ISRs and threads, nothing else. Threads can be awaken from ISR.
Drawback: you cannot limit the execution time of ISR except by a crash, so,
you cannot guarantee any ISR latency. Since ISRs interrupt the threads, you
cannot guarantee the thread scheduling latency too.
2) Windows or old Linux design: ISRs, DPCs and threads, with the
requirement of keeping the ISR as fast as possible and do most of the work in
DPC.
Advantage: DPC can be interrupted by other ISRs and thus decreases their
latency. The overall interrupt latency in the OS is better.
Drawback: still no guarantees. Also, DPCs are scheduled using very
primitive policy, and they preempt any thread. So, very bad DPC latencies and
very bad thread scheduling latencies.
3) Only ISRs and threads, but the ISRs are very simple and their only job
is to signal the "ISR thread". Drivers cannot add code to ISRs, they are
required to use ISR threads instead.
With this, the ISR latency is best and predictable, and so is the thread
scheduling latency.
Now note that the thread scheduler must be able of applying the policies of
"guaranteed thread wake latency" (time from KeSetEvent or analog till the
thread actually starts to run), and "guaranteed hard timeslice" (thread cannot
be preempted for this time after wake unless it will voluntarily wait once
more).
These policies are based on preallocation, and, if the times were
allocated, they are guaranteed. They override the usual notion of thread
priorities.
Now note that the ISR threads are also subject to the same policies, so,
the real ISR latency (from hardware to driver's code) is the ISR thread's wake
latency + the constant short ISR execution time.
Also, thread scheduling of the ISR threads replaces the usual interrupt
priorities.
Looks like design #3 is a perfect RTOS design.
--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com |
|