Hello
I'm are using the xenomai-forge pSOS skin (Mercury).
My application is running on a P4040 (Freescale PPC with 4 cores).
Some code snippets are put in this mail but the complete testcode is
also attached.
I have a test task that just consumes the CPU:
int run_test = 1;
static void perform_work(u_long counter,u_long b,u_long c,u_long d)
{
int i;
while (run_test) {
for (i=0;i<100000;i++);
(*(unsigned long*)counter)++;
}
while (1) tm_wkafter(1000);
}
If I create 2 instances of this task with the T_SLICE option set:
t_create("WORK",10,0,0,0,&tid);
t_start(tid,T_TSLICE, perform_work, args);
I see that only 1 task is consuming CPU.
# taskset 1 ./roundrobin.exe &
# 0"000.543| [main] SCHED_RT priorities => [1 .. 99]
0"000.656| [main] SCHED_RT.99 reserved for IRQ emulation
0"000.692| [main] SCHED_RT.98 reserved for scheduler-lock emulation
0 -> 6602
1 -> 0
If I adapt the code so that I call in my init the threadobj_start_rr
function, I see that the load is equally distributed over the 2
threads:
# taskset 1 ./roundrobin.exe &
# 0"000.557| [main] SCHED_RT priorities => [1 .. 99]
0"000.672| [main] SCHED_RT.99 reserved for IRQ emulation
0"000.708| [main] SCHED_RT.98 reserved for scheduler-lock emulation
0 -> 3290
1 -> 3291
Here are the questions:
- why is the threadobj_start_rr function not called from the context
of the init of the psos layer.
- why is the roundrobin implemented in this way? If the tasks would be
mapped on the SCHED_RR instead of the SCHED_FF the Linux scheduler
would take care of this.
On the other hand, once the threadobj_start_rr function is called from
my init, and I create the tasks in T_NOTSLICE mode, the time-slicing
is still done.
Thanks.
---
Ronny
#include <stdio.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <psos/psos.h>
int run_test = 1;
static void perform_work(u_long counter,u_long b,u_long c,u_long d)
{
int i;
while (run_test) {
for (i=0;i<100000;i++);
(*(unsigned long*)counter)++;
}
while (1) tm_wkafter(1000);
}
static unsigned long counter[2];
static void test()
{
u_long tid,args[4] = {0,0,0,0};
int i;
for (i=0;i<2;i++) {
args[0] = (u_long)&(counter[i]);
t_create("WORK",10,0,0,0,&tid);
t_start(tid,T_TSLICE, perform_work, args);
}
tm_wkafter(10000);
run_test = 0;
for (i=0;i<2;i++) {
printf("%i -> %lu\n",i,counter[i]);
}
while (1) tm_wkafter(1000);
}
int main(int argc,char *argv[], char**envp)
{
u_long oldprio;
struct timespec quantum;
mlockall(MCL_CURRENT | MCL_FUTURE);
copperplate_init(argc,argv);
quantum.tv_sec = 0;
quantum.tv_nsec = 5 * 1000 * 1000; // use 5ms
threadobj_start_rr(&quantum);
t_setpri(0,50,&oldprio);
test();
return 0;
}
_______________________________________________
Xenomai-core mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-core