How to elevate thread priority

234 views
Skip to first unread message

Алексей Сафошин

unread,
Jun 26, 2015, 2:57:51 AM6/26/15
to andro...@googlegroups.com
Hello.

Does anybody know it is posible to set real time priority for a thread in C.

pthread_setschedparam returns EPERM.

I've got a rooted android device (ODROID-XU3), and I got root in java before executing pthread_setschedparam. But it didn't help.

Two days of searching in the internet didn't help me.
I will be very greatful if anybody helps me.
Thank.

Glenn Kasten

unread,
Jun 26, 2015, 11:00:39 AM6/26/15
to andro...@googlegroups.com, vesyo...@gmail.com
Thank you for your question regarding general-purpose use of fixed priority
(aka realtime) scheduling,  I'm aware of the need for this feature.
It has many useful applications, including my own area of low latency audio.

Fixed priority can lead to "tragedy of the commons" problems ...
the more we allow use of realtime, the less useful it becomes,
unless we strictly manage the resource system-wide.

According to the rate monotonic scheduling algorithm (RMS), 
which is a standard way to assign fixed priorities,
priorities should be assigned based upon period. 
In addition, tasks should be periodic in order to be given realtime priorities,
and realtime task worst-case workloads should be known and (significantly) less than their period.
See https://source.android.com/devices/audio/latency_contrib.html#rms
and the article it references http://en.wikipedia.org/wiki/Rate-monotonic_scheduling

We are tracking the problem of assigning
realtime priorities appropriately across the whole system.
Until then, we're not allowing general use of fixed priority scheduling.

Doug

unread,
Jun 26, 2015, 2:23:01 PM6/26/15
to andro...@googlegroups.com
I don't know about native pthread, but in Java I have used this to schedule a thread a proper audio priority, and I know that it works.


Doug


On Thursday, June 25, 2015 at 11:57:51 PM UTC-7, Алексей Сафошин wrote:

Glenn Kasten

unread,
Jun 26, 2015, 2:27:50 PM6/26/15
to andro...@googlegroups.com, beaf...@gmail.com
That is the correct API for requesting the "nice" level for the CFS scheduler.
Again, we're not allowing general use of fixed priority (aka realtime)
scheduling in Android for the reasons mentioned earlier.

Алексей Сафошин

unread,
Jun 28, 2015, 12:19:09 PM6/28/15
to andro...@googlegroups.com
Thanks you, Glenn.

It's very sad. I hoped it's possible.

I design app, that worked with custom cameras. And the app skips the frames, especially when os does something.

Is the nice value the single available tool?
Reply all
Reply to author
Forward
0 new messages