All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: Christophe Carton <christophe.carton@ixblue.com>, xenomai@xenomai.org
Subject: Re: [Xenomai] Round robin scheduling seem not working in a specific case...
Date: Tue, 04 Nov 2014 12:43:00 +0100	[thread overview]
Message-ID: <5458BBC4.9080802@xenomai.org> (raw)
In-Reply-To: <5458ABC7.2080201@ixblue.com>

On 11/04/2014 11:34 AM, Christophe Carton wrote:
> Hello,
> 
> I am currently working with Xenomai 2.6.4 with native skin and with a
> Linux kernel 3.14.17.
> The linux and the xenomai have been taken from the following Git
> repositories :
> * http://git.xenomai.org/xenomai-2.6.git - tag v2.6.4
> * http://git.xenomai.org/ipipe.git - tag ipipe-core-3.14.17-x86-4
> 
> I am encountering a problem to enable the Round Robin scheduler in a
> specific case :
> * Two tasks ("rr task 1" and "rr task 2") of priority 10 are launched by
> a task ("init task") of priority 90.
> * All 3 of them are configured with a RR scheduler via "rt_task_slice"
> API before they are started.
> In this case the FIFO scheduling seems to be applied (could be seen via
> rt_printf logs).
> 
> I have found a thread on the mailing list that gives an example
> demonstrating the good behavior of the RR scheduler.
> http://www.xenomai.org/pipermail/xenomai/2011-November/024897.html
> http://www.xenomai.org/pipermail/xenomai/2011-November/024899.html
> This example implies that the tasks are locked via a semaphore at
> startup and that this semaphore is unlocked by the main when all threads
> have been started.
> This is necessary in this case due to the fact that the main function is
> no an RT task.
> 
> This implementation (with the semaphore) applied to my test works. Why
> is the semaphore needed in my case?

init_task() is switched to non-rt mode by rt_task_create(), so that a
regular pthread is first created by the glibc, prior to extending it
with Xenomai capabilities. In 2.6.x, this operation leaves the caller
(i.e. init_task() in your case) in relaxed/secondary mode, which means
that it is assigned the lowest priority level in the Xenomai scheduler,
below the RR class.

Given that, in your code, no Xenomai syscall following the first
rt_task_create() have the requirement to switch the caller back to
primary/rt mode, including rt_task_start() which is issued for task_1.
Hence init_task() won't compete with task() which is assigned the
real-time RR priority you asked for on entry.

IOW, if you don't make the children wait on a barrier until the parent
has set the whole thing up, the first call to rt_task_start() will
unleash task_1, which will in turn start spinning immediately in its
work loop as init_task() is on a lower priority level, locking up CPU#1.

-- 
Philippe.


  parent reply	other threads:[~2014-11-04 11:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-04 10:34 [Xenomai] Round robin scheduling seem not working in a specific case Christophe Carton
2014-11-04 10:41 ` Gilles Chanteperdrix
2014-11-04 10:59   ` Christophe Carton
2014-11-04 11:43 ` Philippe Gerum [this message]
2014-11-04 11:46   ` Gilles Chanteperdrix
2014-11-04 13:22     ` Philippe Gerum
2014-11-04 13:49       ` Christophe Carton
2014-11-04 14:05         ` Philippe Gerum
2014-11-04 14:09           ` Christophe Carton
2014-11-05 11:25             ` Christophe Carton
2014-11-05 13:33               ` Philippe Gerum
2014-11-05 14:11                 ` Christophe Carton
2014-11-05 14:36                   ` Philippe Gerum
2014-11-05 14:36                     ` Gilles Chanteperdrix
2014-11-05 15:13                     ` Christophe Carton

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=5458BBC4.9080802@xenomai.org \
    --to=rpm@xenomai.org \
    --cc=christophe.carton@ixblue.com \
    --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.