SCHED_WEAK vs linux regular threads
jan.kiszka at siemens.com
Thu Aug 1 13:25:40 CEST 2019
On 01.08.19 11:53, Julien Blanc via Xenomai wrote:
> I'm a bit puzzled about how SCHED_WEAK behaves vs linux regular
> Suppose a kernel built without CONFIG_XENO_OPT_SCHED_WEAK (so, only 0
> is a valid value for sched_priority, which should be the same as
> Let’s say i have four threads :
> * thread 1, RT, with SCHED_FIFO policy and a sched_param value of 90
> * thread 2, RT, with SCHED_WEAK policy and a sched_param value of 0
> * thread 3, RT, with SCHED_WEAK policy and a sched_param value of 0
Should 2 and 3 have the same parameters in your scenario?
> * thread 4, non-RT, with SCHED_RR policy and a sched_param value of 30
> Now, what happens regarding the scheduling ?
> * thread 1 always run first as long as it does not leave the primary
> * thread 2 and 3 enters the primary domain only during xenomai xthread-
> only calls ? And leaves it just after.
> * if thread 2 and 4 competes for the CPU (while thread 2 is in the
> secondary domain), who is given CPU ?
4, due to SCHED_RR vs. SCHED_WEAK with prio 0 -> Linux SCHED_NORMAL.
> * how does thread 2 and 3 competes (while in secondary mode) against
> linux kernel (while in secondary mode) ? And other programs ? (ie, can
> a SCHED_WEAK process eating all cpu hang the whole linux system, like
> with standard RT threads).
SCHED_WEAK maps to SCHED_NORMAL/OTHER with prio = 0. With prio > 0, it is mapped
on SCHED_FIFO Linux-wise.
> * is there a way to prioritize thread 2 and thread 3 (while in the
> secondary domain) ? (for example by adjusting a posix only priority).
> Or is it the whole reason behind CONFIG_XENO_OPT_SCHED_WEAK ?
You can assign non-zero prios to thread 2 and 3, ordering it this way, but then
also while both are in primary mode. For "weak" ordering, you could also leave
their prio at 0 and play with their nice level. That would be a Linux-only "prio".
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
More information about the Xenomai