Wed, 12 Jan 2000 Aleksandar Bakic wrote:
> David Olofson <[EMAIL PROTECTED]> writes:
> 
> [...]
> > API functions from RT context is unsafe, as RT context can preempt Linux even if
> > Linux has disabled the interrupts, and hence break spinlock protection and
> > similar stuff. (That is, Linux uses a layer that lets RTL get in between Linux
> > and the IRQ hardware.)
> [...]
> 
> Is there any "trick" to prevent breaking Linux kernel protocols? I've
> had that kind of problems (corrupted data structures in kernel,
> calling scheduler from within an interrupt and similar) :(

You could do some dirty digging around to find out what you need to avoid
colliding with and 1) check that from your RT process before you mess with it,
or 2) hack those parts of the kernel to be RT safe. I guess both hacks can be
more complicated than they may sound...

The first method basically means "if the kernel is there, hands off for now!".
The second method means that ALL RT treads get increased scheduling jitter, as
the kernel has to simply disable all IRQs - including RTL - when touching the
critical structures. (You may use RTL spinlocks, just as in drivers that use RT
threads or IRQ handlers.)

There is a third, easy solution; trigger a bottom half interrupt handler from
the RT thread, and have the bottom half do the job in non-RT context. This
means increased latency, but if you have to communicate with the non-RT world,
you'll hit that problem sooner or later anyway. It's probably not the fastest
solution, and may actually affect the wake up latency for SCHED_FIFO threads
(soft RT in user space.) But any other way probably requires changing code
and/or structures that are closely related to, and frequently used by the
standard Linux scheduler. That is, forcing the scheduler to switch to the
SCHED_FIFO thread as soon as the non-RTL system is not in kernel mode, without
having to wait for the bottom half to be called.

NOTE: I don't know if bypassing the bottom halves really makes a significant
difference in recent kernels! But I'd like to know, as it gets really
interesting when combining RTL and the lowlatency patch. (Anyone who studied the
scheduler more carefully than I did...?)


//David


 ·A·U·D·I·A·L·I·T·Y·   P r o f e s s i o n a l   L i n u x   A u d i o
· ··---------------------------+-----------------------------------·· ·
  ·Rock Solid  ·Low Latency    | - David Olofson -     ·Audio hacker
  ·Plug-Ins    ·Open Source    :                       ·Linux advocate
www.angelfire.com/or/audiality · [EMAIL PROTECTED]  ·Singer/composer
--- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
----
For more information on Real-Time Linux see:
http://www.rtlinux.org/~rtlinux/

Reply via email to