All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: roderik.wildenburg@domain.hid
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] How to use Xenomai libraries with "normal" (non Xenomai) linux processes ?
Date: Thu, 22 Jan 2009 13:42:12 +0000	[thread overview]
Message-ID: <497877B4.6060000@domain.hid> (raw)
In-Reply-To: <5D63919D95F87E4D9D34FF7748CE2C2A01776C87@domain.hid>

roderik.wildenburg@domain.hid wrote:
> Sorry for the delayed answer, but I am fighting with an other Xenomai
> problem too (PPC switchtest FPU problem, you probably heard about
> it).
> 
>>> I don´t understand this. Isn´t this a contradiction to your
>> answer in
>>> 2.) ? I thought sched_setscheduler does not work for Xenomai
>>> tasks and in our testcase we could see that scheduling policy
>>> isn´t set as expected (to SCHED_FIFO).
>> Currently the posix skin library does, in init.c: 
>> parm.sched_priority = 0; err =
>> __wrap_pthread_setschedparam(pthread_self(), SCHED_OTHER, &parm);
>> 
>> We could replace this with: err =
>> pthread_getschedparam(pthread_self(), &policy, &parm); if (err) ...
>>  err = __wrap_pthread_setschedparam(pthread_self(), policy, &parm);
>> 
>> 
>> But sched_setscheduler could be called after that, so this is racy.
>> 
> 
> Please correct me if I am wrong: In your replacement
> pthread_getschedparam would read scheduling parameters which should
> have been set with sched_setscheduler before(!) your replacement gets
> active. Is this possible at all ? Wouldn´t I have to call
> sched_setscheduler (in "sysup") before I fork? And if calling after
> the fork it realy would be racy. So this isn´t a very feasible
> solution, isn´t it? Changing the scheduling paramters of a running
> Xenoami task probably isn´t possible (probably there is nothing to
> recognize the change ?)?

You can also call sched_setscheduler after fork but before exec. In case
you want to do that, here is the (untested) patch, to let the xenomai
posix skin use this priority.

Index: src/skins/posix/init.c
===================================================================
--- src/skins/posix/init.c	(revision 4572)
+++ src/skins/posix/init.c	(working copy)
@@ -48,7 +48,7 @@ static __attribute__ ((constructor))
 void __init_posix_interface(void)
 {
 	struct sched_param parm;
-	int muxid, err;
+	int muxid, err, policy;

 	muxid =
 	    xeno_bind_skin(PSE51_SKIN_MAGIC, "POSIX", "xeno_posix");
@@ -74,9 +74,14 @@ void __init_posix_interface(void)
 		exit(EXIT_FAILURE);
 	}

-	parm.sched_priority = 0;
-	err = __wrap_pthread_setschedparam(pthread_self(), SCHED_OTHER,
-					   &parm);
+	err = __real_pthread_getschedparam(pthread_self(), &policy, &parm);
+	if (err) {
+		fprintf(stderr, "Xenomai Posix skin init: "
+			"pthread_getschedparam: %s\n", strerror(err));
+		exit(EXIT_FAILURE);
+	}
+
+	err = __wrap_pthread_setschedparam(pthread_self(), policy, &parm);
 	if (err) {
 		fprintf(stderr, "Xenomai Posix skin init: "
 			"pthread_setschedparam: %s\n", strerror(err));


-- 
                                                 Gilles.



  parent reply	other threads:[~2009-01-22 13:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4975EAF5.2000604@domain.hid>
2009-01-21  9:53 ` [Xenomai-help] How to use Xenomai libraries with "normal" (non Xenomai) linux processes ? roderik.wildenburg
2009-01-21 10:53   ` Gilles Chanteperdrix
2009-01-21 12:27     ` roderik.wildenburg
2009-01-21 13:05       ` Gilles Chanteperdrix
2009-01-21 13:36         ` Jan Kiszka
2009-01-22 12:22           ` roderik.wildenburg
2009-01-22 12:34             ` Jan Kiszka
2009-01-22 11:06         ` roderik.wildenburg
2009-01-22 13:14           ` Gilles Chanteperdrix
2009-01-22 14:25             ` roderik.wildenburg
2009-01-22 14:33               ` Gilles Chanteperdrix
2009-01-22 13:42           ` Gilles Chanteperdrix [this message]
2009-01-20 13:16 roderik.wildenburg
2009-01-20 13:20 ` Gilles Chanteperdrix

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=497877B4.6060000@domain.hid \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=roderik.wildenburg@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.