Discussion:
Q: Threads and priority
(too old to reply)
Cédric Pillonel
2003-10-07 06:22:28 UTC
Permalink
If the scheduling policy is SCHED_RR priorities of thread can only be
changed by the superuser. If the policy is SCHED_OTHER ony the superuser can
raise the priority. Users without superuser priviledges can only lower the
priorities of threads.

I want to run my application as a normal user (not superuser) but I want to
raise the priority of one of my threads (real-time priority = SCHED_RR). Is
it possible?

Thank you.
Cédric Pillonel
Nils O. Selåsdal
2003-10-07 06:47:08 UTC
Permalink
Post by Cédric Pillonel
If the scheduling policy is SCHED_RR priorities of thread can only be
changed by the superuser. If the policy is SCHED_OTHER ony the superuser can
raise the priority. Users without superuser priviledges can only lower the
priorities of threads.
I want to run my application as a normal user (not superuser) but I want to
raise the priority of one of my threads (real-time priority = SCHED_RR). Is
it possible?
You'd have to start the program as root(e.g. setuid root) set the scheduler,
and drop privilegies with seteuid() and similar. Just note that the realtime
scheduler can bite you. One little error and your machine might appear
locked. I'd say you should rather use nice(2).
Mikko Rauhala
2003-10-07 06:57:04 UTC
Permalink
On Tue, 7 Oct 2003 08:22:28 +0200, Cédric Pillonel
Post by Cédric Pillonel
I want to run my application as a normal user (not superuser) but I want to
raise the priority of one of my threads (real-time priority = SCHED_RR). Is
it possible?
You need to do one of two things:

1) Make the program setuid root, have it set RR scheduling and immediately
drop root priviledges. Alternatively, make a suid root wrapper that starts
the actual program with normal user priviledges and gives it SCHED_RR from
outside.

2) Arrange for the program to have the CAP_SYS_NICE capability; no root
needed at runtime. In practice you could probably do this e.g. through
the use of a suid root wrapper executable ;P (I don't think there's
official filesystem support for capabilities yet; patches maybe, dunno.)
--
Mikko Rauhala - ***@iki.fi - <URL:http://www.iki.fi/mjr/>
Transhumanist - WTA member - <URL:http://www.transhumanism.org/>
Singularitarian - SIAI supporter - <URL:http://www.singinst.org/>
Continue reading on narkive:
Loading...