Problem: I have native (C++) code within the apk.
Explicit setting scheduling/priority doesn’t have any effect.
Description: There is 3rd party code (objective C), where all threads
will be created with POSIX APIs, specifying for the scheduling SCHED_RR and the corresponding priority.
This seems to have no effect, since my apk has no root privileges.
It seems that in implementation of the related POSIX APIs (like pthread_setschedparam), kernel checks for the CAP_SYS_NICE capability for any unprivileged process.
capabilities(7) - Linux manual page (man7.org)
Facts:
Is there any way to overcome this issue?
@note Using JNI to attach the native thread - to create the Java thread, from which the
priority (CFS: niceness) will be set (Process.setThreadPriority) is working, but in Java world there is no way to set real-time scheduling
https://godbolt.org/z/x5W4WjdY9
Thanks in advance,
Damir
You can't set real-time scheduling in user space on non-rooted devices on Android.setThreadPriority() is setting only niceness, that should be mentioned in the documentation.that's all "by design". will let google folks speak but guess - security and safety being the reason, and so that the apps won't overuse this superpower.
Why would you need real-time scheduling for your thread?YuryOn Tuesday, December 27, 2022 at 9:36:49 PM UTC+1 damir.m...@gmail.com wrote:Problem: I have native (C++) code within the apk.
Explicit setting scheduling/priority doesn’t have any effect.
Description: There is 3rd party code (objective C), where all threads
will be created with POSIX APIs, specifying for the scheduling SCHED_RR and the corresponding priority.
This seems to have no effect, since my apk has no root privileges.
It seems that in implementation of the related POSIX APIs (like pthread_setschedparam), kernel checks for the CAP_SYS_NICE capability for any unprivileged process.
capabilities(7) - Linux manual page (man7.org)
Facts:
- SELinux currently running in permission mode
- The .apk is not root process, there is no init.rc, where this capability can be set – applied
Is there any way to overcome this issue?
@note Using JNI to attach the native thread - to create the Java thread, from which the
priority (CFS: niceness) will be set (Process.setThreadPriority) is working, but in Java world there is no way to set real-time scheduling
https://godbolt.org/z/x5W4WjdY9
Thanks in advance,
Damir
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/16bd9c83-56eb-4df7-998b-8a108b828f07n%40googlegroups.com.