Thanks a lot.
I think the chrt command is the one I was missing.
I will try to set this up on a raspberry Pi 4b, with the current 6.12
kernel, and maybe later move it to a more robust device if necessary.
The major difficulty I have in my understanding, is sometimes the limit
between userspace and kernel :
I would believe pthread is for userspace and kthread for kernel ? And
the management of pthread would be done by sched fonctions, that of
kthread with chrt ?
And kthreads are seen as "tasks" with ps where pthread won't be seen,
only the main process ?
As for the interrupts priorities, the top-half will be 50, but I would
still be able to use a different priority for the bottom half if I use
threaded irqs ?
I don't think I will even need to manage priorities in the first system
since with only one encoder, the isolation and affinity should be plenty
enough, but I'd like to start in the correct direction if I want to try
more complex later.
Thanks for your help.
Mathieu
Le 09/10/2024 à 21:10, Alison Chaiken a écrit :
Le Chaudron Nautique <vanvan@xxxxxxxxxxxxxxxxxxxx> wrote:
after a lot of reading, I believe I'm still missing something concerning
"priority" level (or is it my understanding of the kernel ?).
Welcome to the PREEMPT_RT community. The best resource for getting started is
the RT wiki: https://wiki.linuxfoundation.org/realtime/start When
you post to ask questions, it's a good idea to mention which kernel
version and which architecture you're using.
I would like to set up the reading of an encoder (via GPIO) and the
triggering of an output with RT to be able to define the max speed.
Every thing else can be non-RT
If it write a kernel module (I used the site of embetronix for that) to
manage the GPIO interrupts and output, what is the "priority" of this
module (since interrupts are priority 50 I assume ? I believe we can't
change this value)
Interrupt threads are by default assigned the SCHED_FIFO priority 50
by the kernel. The thread(s) created by the module will run as
SCHED_OTHER unless you set SCHED_FIFO from userspace with "man 1
chrt." The priority can be manipulated with either "man 1 taskset"
or good old "nice." View the threads with, for example,
$ ps -elFy | grep "\["
If I use cpu isolation / interruts cpu affinity, is that equivalent to
dedicate a cpu to this module ? Or will it still sometimes be "busy"
with other cpus ?
If I am not mistaken, it is not possible to manage affinity between
kernel module and cpu, it is only for the treads or interrupt by masking ?
There are many complex and subtle approaches that you can try, but
odds are good since your use case sounds simple that some combination
of chrt and taskset will solve your problem. If not, read the RT wiki
carefully about other possibilities.
Thanks for your help.
Mathieu
Good luck,
Alison Chaiken
Aurora Innovation
--