All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Cc: xenomai-help <xenomai@xenomai.org>
Subject: Re: [Xenomai-help] pthread cancelation and scheduling magics
Date: Fri, 09 Jan 2009 14:38:45 +0100	[thread overview]
Message-ID: <49675365.6080007@domain.hid> (raw)
In-Reply-To: <49674C62.5090009@domain.hid>

Gilles Chanteperdrix wrote:
> Philippe Gerum wrote:
>> Gilles Chanteperdrix wrote:
>>> Wolfgang Grandegger wrote:
>>>> Wolfgang Grandegger wrote:
>>>>> Hi Gilles,
>>>>>
>>>>> Gilles Chanteperdrix wrote:
>>>>>> Wolfgang Grandegger wrote:
>>>>>>> I'm also puzzled why pthread_setschedparam() does make a mode switch
>>>>>>> to secondary mode (sometimes).
>>>>>> That is normal. The glibc caches threads priority value, so we have to
>>>>>> call __real_pthread_setschedparam to update them. This issue has been
>>>>>> solved differently on trunk, but unfortunately, we can not backport this
>>>>>> modification on v2.4.x branch.
>>>>> To get you right. With v2.4.x it is not possible with the POSIX skin to
>>>>> change the priority of a real-time thread in the primary mode without
>>>>> loosing determinism (because it will switch to secondary mode). What
>>>>> options do I have?
>>>> I gave Xenomai trunk a try and pthread_setschedparam() does not switch
>>>> to secondary mode any more on my PowerPC test system. Nice, I just get
>>>> an Oops in thread_delete from time to time. More on that issue later.
>>>> For my ARM i.mx31 system, a need a few patches to get the Xenomai src's
>>>> compiled:
>>>>
>>>> Index: include/asm-generic/bits/bind.h
>>>> ===================================================================
>>>> --- include/asm-generic/bits/bind.h	(revision 4450)
>>>> +++ include/asm-generic/bits/bind.h	(working copy)
>>>> @@ -72,7 +72,7 @@
>>>>  	err = XENOMAI_SYSCALL1(__xn_sys_current, &current);
>>>>  	if (err) {
>>>>  		fprintf(stderr, "Xenomai: error obtaining handle for current "
>>>> -			"thread: %s\n", strerror(err));
>>>> +			"thread: %s\n", strerror(-err));
>>>>  		exit(1);
>>>>  	}
>>>>  	__xeno_set_current(current);
>>>> Index: include/asm-arm/syscall.h
>>>> ===================================================================
>>>> --- include/asm-arm/syscall.h	(revision 4450)
>>>> +++ include/asm-arm/syscall.h	(working copy)
>>>> @@ -228,7 +228,7 @@
>>>>  	volatile unsigned long long *const tscp = __xn_tscinfo.u.fr.tsc;
>>>>  	volatile unsigned *const counterp = __xn_tscinfo.u.fr.counter;
>>>>          const unsigned mask = __xn_tscinfo.u.fr.mask;
>>>> -	register unsigned long long after, before;
>>>> +	register unsigned long long result;
>>>>          unsigned counter;
>>>>  
>>>>          __asm__ ("ldmia %1, %M0\n": "=r"(result): "r"(tscp), "m"(*tscp));
>>>>
>>>>
>>>> When I then start my application or cyclictest I get:
>>>>
>>>> -bash-3.2# ./cyclictest -n 
>>>> Xenomai: error obtaining handle for current thread: Operation not permitted
>>>>
>>>> As the latency program works fine, it seems to be a problem with the
>>>> POSIX skin. Any idea what it is?
>>> What version of gcc are you using ? When trying to get xenomai running
>>> on an ARM platform, I found out that gcc 4.3.1 and 4.3.2 have a bug on
>>> ARM which thrashes the parameters passed to  some xenomai syscalls.
>>>
>> A common issue happens when pthread_self() is inlined in the syscall arg list.
>> Early gcc 4.x for powerpc has this problem; never tried with newer releases, but
>> rather made sure to use a temporary variable to pass this value to the syscall.
> 
> The issue on arm is a similar issue: the problem comes from the
> "mode_buf" parameter now passed to pthread_create which clobbers the
> register r0, normally used to pass the syscall number.
> 
> I am still trying to figure out if it is a bug in Xenomai's syscall
> inline assembly, or a bug in gcc or binutils. And even if it is a bug in
> the toolchain, I am afraid we will have to find a workaround in the
> syscall inline assmbley anyway.
> 

Yes.

-- 
Philippe.


  reply	other threads:[~2009-01-09 13:38 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-30 21:34 [Xenomai-help] pthread cancelation and scheduling magics Wolfgang Grandegger
2008-11-30 21:46 ` Gilles Chanteperdrix
2008-11-30 21:59 ` Gilles Chanteperdrix
2008-12-01 10:22   ` Gilles Chanteperdrix
2008-12-01 14:16     ` Wolfgang Grandegger
2008-12-01 14:15       ` Gilles Chanteperdrix
2008-12-01 15:10         ` Gilles Chanteperdrix
2008-12-02 15:59           ` Wolfgang Grandegger
2008-12-02 15:55             ` Gilles Chanteperdrix
2008-12-02 18:18               ` Wolfgang Grandegger
2008-12-02 18:35                 ` Gilles Chanteperdrix
2008-12-02 19:50                   ` Wolfgang Grandegger
2008-12-02 20:03                     ` Philippe Gerum
2008-12-07 16:05                   ` Wolfgang Grandegger
2008-12-10 11:16                     ` Wolfgang Grandegger
2008-12-11 15:26                       ` Jan Kiszka
2008-12-13 15:55                         ` Wolfgang Grandegger
2009-01-01 13:34                       ` Gilles Chanteperdrix
2009-01-01 17:07                         ` Philippe Gerum
2009-01-01 18:00                           ` Gilles Chanteperdrix
2009-01-09 13:08                           ` Gilles Chanteperdrix
2009-01-09 13:38                             ` Philippe Gerum [this message]
2009-01-01 17:10                         ` Wolfgang Grandegger
2009-01-01 18:11                           ` Gilles Chanteperdrix
2008-12-03 10:16                 ` Gilles Chanteperdrix
2008-12-03 11:19                   ` Wolfgang Grandegger
2008-12-03 13:30                     ` Gilles Chanteperdrix
2008-12-03 18:02                       ` Wolfgang Grandegger
2008-12-03 17:57                         ` Gilles Chanteperdrix
2008-12-03 18:37                           ` Wolfgang Grandegger
2008-12-03 18:32                             ` Gilles Chanteperdrix
2008-12-03 18:55                               ` Wolfgang Grandegger
2008-12-03 18:55                                 ` Gilles Chanteperdrix
2008-12-03 19:19                                   ` Wolfgang Grandegger
2008-12-03 19:19                                     ` Gilles Chanteperdrix
2008-12-03 20:02                                       ` Wolfgang Grandegger
2008-12-03 20:02                                         ` Gilles Chanteperdrix
2008-12-04 15:29                                           ` Wolfgang Grandegger
2008-12-04 15:38                                             ` Gilles Chanteperdrix
2008-12-04 15:42                                               ` Gilles Chanteperdrix
2008-12-04 16:31                                               ` Wolfgang Grandegger
2008-12-04 16:26                                                 ` Gilles Chanteperdrix
2008-12-04 16:49                                                   ` Wolfgang Grandegger
2008-12-04 17:02                                                     ` Gilles Chanteperdrix
2008-12-04 17:52                                                       ` Wolfgang Grandegger
2008-12-04 17:51                                                         ` Gilles Chanteperdrix
2008-12-05 14:58                                                       ` Wolfgang Grandegger
2008-12-03  8:04         ` Wolfgang Grandegger
2008-12-03 10:12           ` Gilles Chanteperdrix
2008-12-03 10:46             ` Wolfgang Grandegger
2008-12-03 10:40               ` Gilles Chanteperdrix
2008-12-03 11:16                 ` Wolfgang Grandegger
2008-12-03 11:11               ` Philippe Gerum
2008-12-03 11:22                 ` Wolfgang Grandegger
2008-12-01 13:31   ` Wolfgang Grandegger

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=49675365.6080007@domain.hid \
    --to=rpm@xenomai.org \
    --cc=gilles.chanteperdrix@xenomai.org \
    --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.