Re: CONFIG_PREEMPT_RT in real-world applications

roger.larsson_at_norran.net
Date: 11/04/05

  • Next message: SD: "Re: GUI Licencing issues"
    Date: 4 Nov 2005 01:36:40 +0200
    
    

    Sven Geggus wrote:

    > Hello embedded-linux folks,
    >
    > I am kind of confuded how a piece of realtime code would look like using
    > Ingo Molnars CONFIG_PREEMPT_RT patch.

    Several approaches are "identical" from a users perspective.
    Simpel rule: Highest priority process runs
    The point of the different approaches is to ensure that this is correct.

    Lets try an example, read from serial port (buffer in driver):
    A process runs (A) - like idle process, web server, ...
    - Interrupt arrives
    - Handled by irq-handler in driver, driver collects characters until some
      limit is reached / special character is read.
    - Irq handler now wakes up the process (B) waiting for this interrupt.
    But here comes the problem. What was the process A doing.
    1) Running in user space (the actual application code)
     No problem, when leaving from the interrupt it will be noticed that the
     current process should let another process run. A context switch will
     occur when leaving.
    2) Running in system space (walking through all page descriptors trying
     to find a page to swap out). This is worse since the process might be
    accessing shared structures - rules must be followed.
    a) Wait for process to leave kernel space.
    b) When doing stuff that can take time in the kernel - check if another
        higher priority stuff wants to run.
    c) Use multiprocessor spinlocks, do not allow process switches while
        in a critical section.
    d) Reduce critical sections by minimising spinlocks, do this by
        d1) Replacing them with semaphores
       d2) Add checks inside the spinlocks
    e) Don't bother with the kernel at all, let the RT processes be handled
       by their own micro OS that sees Linux as one of its processes.
       Usually trying to use the same API (Posix) but you will not be able
       to use all services of Linux.

    >
    > What would I need to make a process realtime. How would I be able to
    > generate a somewhat exact timing, e.g. for a control circuit. From the
    > perspective of a normal Linux system programming guy /dev/rtc comes
    > to mind.

    But an ordinary file could be the source, consider
     tail -f /var/log/something
    with a requirement that it should output "something" within two secons.

    >
    > For the realtime stuff, would it be enough to just use a negative
    > nice-level and a SCHED_FIFO policy?

    nice-level is only used in SCHED_OTHER (and that is never Real Time)

    >
    > Is there any kind of realtime programming Howto which I have not found
    > searching the web? Or is this just an exmple of another piece of fine but
    > undocumented work which is quite common in the Open-Source world?

    Look out for RT benchmarks, like http://www.gardena.net/benno/linux/audio
    (Old but still valid)

    /RogerL


  • Next message: SD: "Re: GUI Licencing issues"

    Relevant Pages

    • Re: RT patch acceptance
      ... > with user-mode execution as the only realtime service. ... time from irqs, and in turn it can't provide syscalls to avoid risking ... For preempt-RT to be equivalent to RTAI, the "rest of the kernel" will ...
      (Linux-Kernel)
    • Re: sched_ule performance on single CPU
      ... Using realtime priority means that the kernel is ... While both FreeBSD and MacOS X are general-purpose ... Core Audio is probably the biggest user of realtime ... design that was abstracted into the portable POSIX ...
      (freebsd-stable)
    • realtime - Had it again, Lost it again
      ... I have recompiled my 2.6.8 kernel numerous times in the last three days ... seeking a configuration allowing use of a USB dvdrw device. ... I believe there are at least three ways to install the realtime module: ...
      (Debian-User)
    • Re: [RFC][PATCH] Restricted hard realtime
      ... > CPU as the hard realtime CPU? ... Then any overly long kernel code paths execute on ...
      (Linux-Kernel)
    • Re: Attempted summary of "RT patch acceptance" thread
      ... >> writeup is that there are a lot of different things that a realtime app ... zero cost for mainstream maintainers. ... between RTAI-Fusion and the Linux kernel. ... dual-OS-administration load associated with RTAI-Fusion. ...
      (Linux-Kernel)