SCHED_FIFO on Raspberry?

Ask questions about Arch Linux ARM. Please search before making a new topic.

SCHED_FIFO on Raspberry?

Postby bstegmaier » Sun Jan 11, 2015 3:37 pm

I wrote a small C++ application for a Raspberry PI, which creates a pseudo IRQ handler for a GPIO input using a worker thread doing a poll() on GPIO edge change.
This is working fine so far, but with default priorities I have a too high latency from signal change on GPIO to return of the poll() in the worker thread.
So, I tried to set the worker-thread to SCHED_FIFO using pthread_setschedparam().
This works perfect when compiling/running my application on my x86 Arch Linux machine (without the actual GPIO of course, but apart from that the same worker thread code - especially all the thread creation stuff is exactly the same). It even works using my non-root user account.
Running it on the Raspberry I always get an error EPERM on pthread_setschedparam(), even if running it as root.
I also tried to use chrt on the Raspberry to set the whole application to SCHED_FIFO, but this also fails with "operation not permitted".

I think the problem is that on the Raspberry I get
$this->bbcode_second_pass_code('', '
[root@raspberry ~]# cat /sys/fs/cgroup/cpu/cpu.rt_runtime_us
950000
[root@raspberry ~]# cat /sys/fs/cgroup/cpu/user.slice/cpu.rt_runtime_us
0
')
As far as I understood the last value of zero prevents using SCHED_FIFO and gives this EPERM error (when I run my application from console it gets put somewhere below this user.slice hierarchy).

On my x86 machine I don't have this ".../user.slice/..." folder, but only the first ".../cpu/..." with the same values for "cpu.rt_runtime_us" like on the Raspberry. Maybe that's why it works there...

I compared kernel configs (with repsect to cgroups) and systemd version and they seem to be the same on both.
Maybe there are some subtle differences... I couldn't find them up to now.

I also found some suggestions here:
http://www.freedesktop.org/wiki/Software/systemd/MyServiceCantGetRealtime/
But, the mentioned "DefaultControllers" parameter doesn't seem to exist in recent versions of systemd. At least, adding it to system.conf (and/or user.conf) as proposed doesn't change anything for me.
Apart from that it states that:
$this->bbcode_second_pass_quote('', '
')Note that this all only applies to services. By default, user applications run in the root cgroup of the "cpu" hierarchy, which avoids these problems for normal user applications.

Seems to be true for my x86 machine, but this doesn't seem to be the case for the Raspberry.
When I start my application from console it will appear under something like
$this->bbcode_second_pass_code('', '
/sys/fs/cgroup/cpu/user.slice/user-0.slice/session-c3.scope/tasks
')

Any ideas what's the problem and how to get this working on the Raspberry?
bstegmaier
 
Posts: 1
Joined: Sun Jan 11, 2015 2:48 pm

Return to User Questions

Who is online

Users browsing this forum: Google [Bot] and 7 guests