Hi folks,

i think there is a problem with the xenomai scheduler or the sched_yield() 
call, when using the POSIX skin (Xenomai 2.4.3, Linux 2.6.24.4, SMP, 
.config is attached).

I've attached a small program (blub.c, Makefile) to demonstrate this:

It starts 3 threads, which are synchronized at a pthread_barrier_t before 
they execute a finite loop. Each of them puts a number of specific 
characters into an array, to see in which order they are scheduled. Thread 
#3 calls sched_yield() after wake-up, which means it should never be the 
first of the 3 threads to run its loop. In my understanding of the barrier 
functions, it should run as the last thread, as all three should become 
ready at the same time. The output of the Linux version (no xenomai 
involved) is here:

-- Linux version --
1 ist hier [.].
Thread 1: prio = 30 policy=FIFO
2 ist hier [-].
Thread 2: prio = 30 policy=FIFO
3 ist hier [*].
Thread 3: prio = 30 policy=FIFO
[3] PTHREAD_BARRIER_SERIAL_THREAD ...
[3] Yiiiield!
[1] Loooos!
[3] Loooos!
[2] Loooos!
megabuf: 
....................................................................................................******************************************************************************************************************************************************************************************************************************************************************************************************************************************--------------------------------------------------

("Loooos!" is printed after returning from *barrier_wait(), just before 
the loop)
Most of the time, linux does it right, and executes thread #3 after the 
other two threads, but sometimes the behavious is like above. This is not 
correct, or am i missing something?



Now the Xenomai version:

-- Xenomai version --
1 ist hier [.].
Thread 1: prio = 30 policy=FIFO
2 ist hier [-].
Thread 2: prio = 30 policy=FIFO
3 ist hier [*].
Thread 3: prio = 30 policy=FIFO
[3] PTHREAD_BARRIER_SERIAL_THREAD ...
[3] Yiiiield!
[3] Loooos!
[2] Loooos!
[1] Loooos!
megabuf: 
******************************************************************************************************************************************************************************************************************************************************************************************************************************************--------------------------------------------------....................................................................................................

Thread #3 is scheduled first, even though it called sched_yield(). This is 
even more incorrect, since it seems to be always the case, even if i call 
sched_yield() multiple times (in this case, the plain linux version 
behaves correctly)

Any ideas what's wrong with this? Maybe it's even glibc's fault (i'm using 
version 2.4), as the posix-skin seems to use wrapper's to the 
glibc-functions? Is this a possibility?

Note: compile the program with "make" to get the xenomai-version, or "make 
XENO=0" to get the plain linux version.








Thomas Wiedemann

Entwicklungsingenieur / Funktionsentwicklung (EF-F33), Fahrzeug Elektronik

IAV GmbH 
Ingenieurgesellschaft Auto und Verkehr
Kauffahrtei 45
09120 Chemnitz
Germany

Telefon:   +49  (371) 2373-4045
Fax:          +49  (371) 2373-4112

Email: <mailto:[EMAIL PROTECTED]>
Internet: http://www.iav.de


IAV GmbH
Sitz/Registered Office: Berlin
Registergericht/Registration Court: Amtsgericht Charlottenburg
Registernummer/Company Registration Number: HRB 21 280
Geschäftsführer/Managing Directors: Kurt Blumenröder, Michael Schubert
 

Attachment: config.gz
Description: Binary data

Attachment: blub.c
Description: Binary data

Attachment: Makefile
Description: Binary data

thinky:~/posix-pthread-scheduler-test# make clean ; make ; ./blub
rm -f blub
gcc -Wall -g `/usr/xenomai/bin/xeno-config --posix-cflags`  -lm 
`/usr/xenomai/bin/xeno-config --posix-ldflags`  blub.c   -o blub
blub.c:44: warning: ‘psleep’ defined but not used
-- Xenomai version --
1 ist hier [.].
Thread 1: prio = 30 policy=FIFO
2 ist hier [-].
Thread 2: prio = 30 policy=FIFO
3 ist hier [*].
Thread 3: prio = 30 policy=FIFO
[3] PTHREAD_BARRIER_SERIAL_THREAD ...
[3] Yiiiield!
[3] Loooos!
[2] Loooos!
[1] Loooos!
megabuf: 
******************************************************************************************************************************************************************************************************************************************************************************************************************************************--------------------------------------------------....................................................................................................
thinky:~/posix-pthread-scheduler-test# make clean ; make XENO=0; ./blub
rm -f blub
gcc -Wall -g -D_GNU_SOURCE -D_REENTRANT  -lpthread -lrt -lm  blub.c   -o blub
blub.c: In function ‘start_thread’:
blub.c:150: warning: unused variable ‘tname’
blub.c: At top level:
blub.c:44: warning: ‘psleep’ defined but not used
-- Linux version --
1 ist hier [.].
Thread 1: prio = 30 policy=FIFO
2 ist hier [-].
Thread 2: prio = 30 policy=FIFO
3 ist hier [*].
Thread 3: prio = 30 policy=FIFO
[3] PTHREAD_BARRIER_SERIAL_THREAD ...
[3] Yiiiield!
[1] Loooos!
[3] Loooos!
[2] Loooos!
megabuf: 
....................................................................................................******************************************************************************************************************************************************************************************************************************************************************************************************************************************--------------------------------------------------

_______________________________________________
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core

Reply via email to