All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-core] trunk: xnsched_set_policy seems to set only cprio
@ 2009-01-28 16:20 Jan Kiszka
  2009-01-28 16:23 ` Gilles Chanteperdrix
  2009-01-28 17:05 ` Philippe Gerum
  0 siblings, 2 replies; 5+ messages in thread
From: Jan Kiszka @ 2009-01-28 16:20 UTC (permalink / raw)
  To: xenomai-core

Hi,

unfortunately I'm forced to switch to other bugs, but I found out a bit
more about the issue that pthread_getschedparam doesn't return the
correct policy&prio under trunk - at least when called from threads
created via pthread_create as SCHED_FIFO:

Such threads start with SCHED_OTHER, but then the propagation via
do_setsched_event and finally xnsched_set_policy only seems to affect
thread.cprio, not bprio. Will see if I can continue debugging this
later, but maybe /someone/ already knows what goes wrong...

Thanks,
Jan

-- 
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Xenomai-core] trunk: xnsched_set_policy seems to set only cprio
  2009-01-28 16:20 [Xenomai-core] trunk: xnsched_set_policy seems to set only cprio Jan Kiszka
@ 2009-01-28 16:23 ` Gilles Chanteperdrix
  2009-01-28 16:36   ` Jan Kiszka
  2009-01-28 17:05 ` Philippe Gerum
  1 sibling, 1 reply; 5+ messages in thread
From: Gilles Chanteperdrix @ 2009-01-28 16:23 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: xenomai-core

Jan Kiszka wrote:
> Hi,
> 
> unfortunately I'm forced to switch to other bugs, but I found out a bit
> more about the issue that pthread_getschedparam doesn't return the
> correct policy&prio under trunk - at least when called from threads
> created via pthread_create as SCHED_FIFO:
> 
> Such threads start with SCHED_OTHER, but then the propagation via
> do_setsched_event and finally xnsched_set_policy only seems to affect
> thread.cprio, not bprio. Will see if I can continue debugging this
> later, but maybe /someone/ already knows what goes wrong...

Yes, pthread_getschedparam returns the priority in the glibc cache. And
this one may not be in sync with the priority known by the kernel(s).
However, this is supposed to be fixed by calling
__real_pthread_setschedparam in various key places.

-- 
                                                 Gilles.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Xenomai-core] trunk: xnsched_set_policy seems to set only cprio
  2009-01-28 16:23 ` Gilles Chanteperdrix
@ 2009-01-28 16:36   ` Jan Kiszka
  0 siblings, 0 replies; 5+ messages in thread
From: Jan Kiszka @ 2009-01-28 16:36 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: xenomai-core

Gilles Chanteperdrix wrote:
> Jan Kiszka wrote:
>> Hi,
>>
>> unfortunately I'm forced to switch to other bugs, but I found out a bit
>> more about the issue that pthread_getschedparam doesn't return the
>> correct policy&prio under trunk - at least when called from threads
>> created via pthread_create as SCHED_FIFO:
>>
>> Such threads start with SCHED_OTHER, but then the propagation via
>> do_setsched_event and finally xnsched_set_policy only seems to affect
>> thread.cprio, not bprio. Will see if I can continue debugging this
>> later, but maybe /someone/ already knows what goes wrong...
> 
> Yes, pthread_getschedparam returns the priority in the glibc cache. And

__wrap_pthread_getschedparam calls into the kernel.

> this one may not be in sync with the priority known by the kernel(s).
> However, this is supposed to be fixed by calling
> __real_pthread_setschedparam in various key places.

This is already called - on thread creation. I'm not debugging
prio/policy adjustment during thread lifetime, already the initial
values passed to pthread_create are not properly reflected by
pthread_getschedparam because bprio is wrong (BTW, /proc/xenomai/sched
should probably better return both cprio and bprio, not just cprio).

Jan

-- 
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Xenomai-core] trunk: xnsched_set_policy seems to set only cprio
  2009-01-28 16:20 [Xenomai-core] trunk: xnsched_set_policy seems to set only cprio Jan Kiszka
  2009-01-28 16:23 ` Gilles Chanteperdrix
@ 2009-01-28 17:05 ` Philippe Gerum
  2009-01-28 17:14   ` Gilles Chanteperdrix
  1 sibling, 1 reply; 5+ messages in thread
From: Philippe Gerum @ 2009-01-28 17:05 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: xenomai-core

Jan Kiszka wrote:
> Hi,
> 
> unfortunately I'm forced to switch to other bugs, but I found out a bit
> more about the issue that pthread_getschedparam doesn't return the
> correct policy&prio under trunk - at least when called from threads
> created via pthread_create as SCHED_FIFO:
> 
> Such threads start with SCHED_OTHER, but then the propagation via
> do_setsched_event and finally xnsched_set_policy only seems to affect
> thread.cprio, not bprio. Will see if I can continue debugging this
> later, but maybe /someone/ already knows what goes wrong...
> 

With the new scheduler infrastructure, ->bprio tends to be used solely as a
priority backup area when dealing with PIP; but at the same time, some skins
still consider it as an always up-to-date location where to find the nominal
priority of a thread, so this hunk should help in keeping things compatible with
2.4.x:

diff --git a/ksrc/nucleus/sched.c b/ksrc/nucleus/sched.c
index 8d50a6b..3b95fbb 100644
--- a/ksrc/nucleus/sched.c
+++ b/ksrc/nucleus/sched.c
@@ -395,6 +395,7 @@ int xnsched_set_policy(struct xnthread *thread,
 	thread->sched_class = sched_class;
 	thread->base_class = sched_class;
 	xnsched_setparam(thread, p);
+	thread->bprio = thread->cprio;

 	if (xnthread_test_state(thread, XNREADY))
 		xnsched_enqueue(thread);

> Thanks,
> Jan
> 


-- 
Philippe.


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Xenomai-core] trunk: xnsched_set_policy seems to set only cprio
  2009-01-28 17:05 ` Philippe Gerum
@ 2009-01-28 17:14   ` Gilles Chanteperdrix
  0 siblings, 0 replies; 5+ messages in thread
From: Gilles Chanteperdrix @ 2009-01-28 17:14 UTC (permalink / raw)
  To: rpm; +Cc: Jan Kiszka, xenomai-core

Philippe Gerum wrote:
> Jan Kiszka wrote:
>> Hi,
>>
>> unfortunately I'm forced to switch to other bugs, but I found out a bit
>> more about the issue that pthread_getschedparam doesn't return the
>> correct policy&prio under trunk - at least when called from threads
>> created via pthread_create as SCHED_FIFO:
>>
>> Such threads start with SCHED_OTHER, but then the propagation via
>> do_setsched_event and finally xnsched_set_policy only seems to affect
>> thread.cprio, not bprio. Will see if I can continue debugging this
>> later, but maybe /someone/ already knows what goes wrong...
>>
> 
> With the new scheduler infrastructure, ->bprio tends to be used solely as a
> priority backup area when dealing with PIP; but at the same time, some skins
> still consider it as an always up-to-date location where to find the nominal
> priority of a thread, so this hunk should help in keeping things compatible with
> 2.4.x:

Yes, the posix spec specifically ask that the priority as set by
pthread_setschedparam is returned, and not the boosted priority in case
of PIP.

-- 
                                                 Gilles.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-01-28 17:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-28 16:20 [Xenomai-core] trunk: xnsched_set_policy seems to set only cprio Jan Kiszka
2009-01-28 16:23 ` Gilles Chanteperdrix
2009-01-28 16:36   ` Jan Kiszka
2009-01-28 17:05 ` Philippe Gerum
2009-01-28 17:14   ` Gilles Chanteperdrix

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.