Re: CONFIG_PREEMPT_RT in real-world applications
roger.larsson_at_norran.net
Date: 11/04/05
- Previous message: cyber: "linker ld script"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: cyber: "linker ld script"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|