All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Kisdaroczi <kisda@domain.hid>
To: charles.clerdan@domain.hid
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] question about priorities
Date: Wed, 08 Sep 2010 16:16:25 +0200	[thread overview]
Message-ID: <4C879AB9.6000907@domain.hid> (raw)
In-Reply-To: <AANLkTi=J9DJvEE274+rDiYBrqQSt7kNRZ3oW9+KPW7ra@domain.hid>

[-- Attachment #1: Type: text/plain, Size: 2685 bytes --]

Hi Charles,

On 08.09.2010 13:45, Charles Clerdan wrote:
> Hi,
>
>
> I have a technical question about priorities under Xenomai.
>
> According to my research, Xenomai use priority levels from 0 to 99. 99
> is the highest effective priority and 0 the lowest.
> But Linux uses levels from 0 to 139. For current task it uses levels
> 100 to 139 where 100 is highest priority than 139, and for "real time"
> threads 0 to 99 where 0 is highest than 99.s
> So when a task jumps in secondary modes is there a conversion of its
> own priority (100 - primary_mode_priority) or does she keep the same
> number.
> When two tasks with two different priorities are in secondary modes,
> is there a priority inversion between them or a crossed convertion of
> the priorities?

caution: I may be wrong, corrections welcome.

If you use the command 'ps -Ac' it will show you priorities from 0-139.
139 is best.

The low prio range 0-39 is for tasks scheduled with the default
SCHED_OTHER scheduling policy. Linux uses CFS (completely fair
scheduler) today for SCHED_OTHER. The priority of these task can be
changed using the command 'renice'. 'renice 19 <pid>' sets the priority
to 0. 'renice -20 <pid>' sets it to 39. 'renice 0 <pid>' to 19 (default).

The priority range displayed as 40-139 is for linux "real-time" taks.
These are tasks handled with the SCHED_FIFO or SCHED_RR policy. To
change the scheduling policy of a process, you can use the 'chrt'
command. The real priority range of SCHED_FIFO or SCHED_RR is 0-99 (99
is best), but if you want to take the scheduling policy into account
like 'ps -Ac' does, a offset of 40 is added for these tasks, so 40-139
is displayed. If you have a SCHED_FIFO task with the lowest prio 0 and
you do a hard loop (bad idea) the SCHED_OTHER tasks don't get cputime
anymore.

Xenomai realtime tasks are SCHED_FIFO or SCHED_RR and have the same
priority range (0-99) as the linux "real-time" tasks. A xenomai
SCHED_FIFO task with prio 99 in secondary mode is handled equally as a
normal linux task with SCHED_FIFO and prio 99 by the linux kernel (prio
displayed as 139 with 'ps -Ac'). But a xenomai task with the lowest
priority 0 in secondary mode has still better prio than all the
SCHED_OTHER linux tasks. Xenomai tasks keep/have the same priority under
the realtime and the linux scheduler.

So the task scheduling priority is something like:
1. xenomai task in primary mode handled by the realtime scheduler
2. xenomai task in secondary mode or linux "real-time" task, both
handled by the linux scheduler, they compete
3. linux SCHED_OTHER tasks handled by the linux scheduler

Regards Stefan



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

  parent reply	other threads:[~2010-09-08 14:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-08 11:45 [Xenomai-help] question about priorities Charles Clerdan
2010-09-08 11:57 ` Gilles Chanteperdrix
2010-09-08 14:16 ` Stefan Kisdaroczi [this message]
2010-09-08 14:18 ` Philippe Gerum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C879AB9.6000907@domain.hid \
    --to=kisda@domain.hid \
    --cc=charles.clerdan@domain.hid \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.