All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] Xenomai 2.5.6 and Round Robin
@ 2011-11-08 21:06 Olivier Reynet
  2011-11-09  0:12 ` Gilles Chanteperdrix
  0 siblings, 1 reply; 5+ messages in thread
From: Olivier Reynet @ 2011-11-08 21:06 UTC (permalink / raw)
  To: xenomai

Hi,
Is it possible to set RR mode with the following functions ??
rt_task_set_mode(0,T_RRB ,NULL);
rt_task_slice(task_descr,quantum)
I have tried with Xenomai 2.5.6, but compiler says that T_RBB is not known.
Have you got any clue ?
Olivier






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

* Re: [Xenomai-help] Xenomai 2.5.6 and Round Robin
  2011-11-08 21:06 [Xenomai-help] Xenomai 2.5.6 and Round Robin Olivier Reynet
@ 2011-11-09  0:12 ` Gilles Chanteperdrix
  2011-11-09 10:27   ` Olivier Reynet
  0 siblings, 1 reply; 5+ messages in thread
From: Gilles Chanteperdrix @ 2011-11-09  0:12 UTC (permalink / raw)
  To: olivier.reynet; +Cc: xenomai

On 11/08/2011 10:06 PM, Olivier Reynet wrote:
> Hi,
> Is it possible to set RR mode with the following functions ??
> rt_task_set_mode(0,T_RRB ,NULL);
> rt_task_slice(task_descr,quantum)
> I have tried with Xenomai 2.5.6, but compiler says that T_RBB is not known.
> Have you got any clue ?

See rt_task_set_mode documentation:
http://www.xenomai.org/documentation/xenomai-2.5/html/api/group__task.html#g915e7edfb0aaddb643794d7abc7093bf

no T_RRB bit.

See also ksrc/skins/native/API.CHANGES in xenomai sources.

-- 
                                                                Gilles.


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

* Re: [Xenomai-help] Xenomai 2.5.6 and Round Robin
  2011-11-09  0:12 ` Gilles Chanteperdrix
@ 2011-11-09 10:27   ` Olivier Reynet
  2011-11-09 11:02     ` Gilles Chanteperdrix
  0 siblings, 1 reply; 5+ messages in thread
From: Olivier Reynet @ 2011-11-09 10:27 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: xenomai

OK, I understand that it is rt_task_slice that must be used.
The problem is that i dont see any RR effect during execution.
The code is simple and inspired by this no more suitable but useful code 
: http://www.cs.ru.nl/lab/xenomai/exercises/ex06/ex06a.c .

4 non periodic tasks are set. They are calling rt_timer_spin(SPINTIME) 
to do nothing during EXECTIME.
1. They are set with priority 60.
2. Then the RR quantum is set to 3*SPINTIME.
I would like to see the task 0 preempted but it is not.  It looks like 
FIFO scheduling without RR.

Here below is the code and the output follows :

#include<stdio.h>
#include<signal.h>
#include<unistd.h>
#include<sys/mman.h>
#include<native/task.h>
#include<native/timer.h>
#include<native/sem.h>
#include<rtdk.h>
#include<sys/io.h>

#define NTASKS 4
RT_TASK demo_task[NTASKS];
RT_SEM mysync;

#define EXECTIME   2e7   // execution time in ns ==>  20 ms
#define SPINTIME   1e6   // spin time in ns ==>  1 ms

void demo(void *arg)
{
     RTIME runtime;
     runtime = 0;
     rt_sem_p(&mysync,TM_INFINITE);
     // inquire current task
     RT_TASK *curtask;
     RT_TASK_INFO curtaskinfo;
     curtask=NULL;
     rt_task_inquire(curtask,&curtaskinfo);
     while(curtaskinfo.exectime<  EXECTIME) {
       rt_timer_spin(SPINTIME);  // spin cpu doing nothing
       rt_task_inquire(curtask,&curtaskinfo);
       rt_printf("Running %s priority[%d]  at : %d ms\n",curtaskinfo.name,curtaskinfo.cprio,curtaskinfo.exectime/1000000);
     }
     rt_printf("End of %s\n",curtaskinfo.name);
}

//startup code
void startup()
{
   int i;
   char  str[10] ;
   RT_TASK_INFO ataskinfo;
   // semaphore to sync task startup on
   rt_sem_create(&mysync,"MySemaphore",0,S_FIFO);
   // starting tasks
   for(i=0;i<NTASKS;i++) {
     sprintf(str,"Task%d",i);
     int priority=60;
     rt_task_create(&demo_task[i], str, 0, priority, 0);
     rt_task_start(&demo_task[i],&demo, NULL);
     rt_task_inquire(&demo_task[i],&ataskinfo);
     rt_printf("Starting task  : %s with priority %d\n",ataskinfo.name,ataskinfo.cprio);
   }
   // set RR
   for(i=0;i<NTASKS;i++) {
     RTIME quantum=rt_timer_ns2tsc(3*SPINTIME);
     int err=rt_task_slice(&demo_task[i],quantum);
     rt_printf("error set  quantum ? %d\n",err);
     rt_task_inquire(&demo_task[i],&ataskinfo);
     rt_printf("Setting round robin policy to %s with quantum %i\n",ataskinfo.name,quantum);
   }
   rt_printf("wake up all tasks\n");
   rt_sem_broadcast(&mysync);
}

void init_xenomai() {
   /* Avoids memory swapping for this program */
   mlockall(MCL_CURRENT|MCL_FUTURE);
   /* Perform auto-init of rt_print buffers if the task doesn't do so */
   rt_print_auto_init(1);
}

int main(int argc, char* argv[])
{
   printf("\nType CTRL-C to end this program\n\n" );
   // code to set things to run xenomai
   init_xenomai();
   //startup code
   startup();
   pause();
   int i;
   for (i=0;i<NTASKS;i++)
     rt_task_join(&demo_task[i]);
   return 0;
}

And the ouput :

# ./xeno_sched

Type CTRL-C to end this program

Starting task  : Task0 with priority 60
Starting task  : Task1 with priority 60
Starting task  : Task2 with priority 60
Starting task  : Task3 with priority 60
error set  quantum ? 0
Setting round robin policy to Task0 with quantum 9875004
error set  quantum ? 0
Setting round robin policy to Task1 with quantum 9875004
error set  quantum ? 0
Setting round robin policy to Task2 with quantum 9875004
error set  quantum ? 0
Setting round robin policy to Task3 with quantum 9875004
wake up all tasks
Running Task0 priority[60]  at : 1 ms
Running Task0 priority[60]  at : 2 ms
Running Task0 priority[60]  at : 3 ms
Running Task0 priority[60]  at : 4 ms
Running Task0 priority[60]  at : 5 ms
Running Task0 priority[60]  at : 6 ms
Running Task0 priority[60]  at : 7 ms
Running Task0 priority[60]  at : 8 ms
Running Task0 priority[60]  at : 9 ms
Running Task0 priority[60]  at : 10 ms
Running Task0 priority[60]  at : 11 ms
Running Task0 priority[60]  at : 12 ms
Running Task0 priority[60]  at : 13 ms
Running Task0 priority[60]  at : 14 ms
Running Task0 priority[60]  at : 15 ms
Running Task0 priority[60]  at : 16 ms
Running Task0 priority[60]  at : 17 ms
Running Task0 priority[60]  at : 18 ms
Running Task0 priority[60]  at : 19 ms
Running Task0 priority[60]  at : 20 ms
End of Task0
Running Task1 priority[60]  at : 1 ms
Running Task1 priority[60]  at : 2 ms
Running Task1 priority[60]  at : 3 ms
Running Task1 priority[60]  at : 4 ms
Running Task1 priority[60]  at : 5 ms
Running Task1 priority[60]  at : 6 ms
Running Task1 priority[60]  at : 7 ms
Running Task1 priority[60]  at : 8 ms
Running Task1 priority[60]  at : 9 ms
Running Task1 priority[60]  at : 10 ms
Running Task1 priority[60]  at : 11 ms
Running Task1 priority[60]  at : 12 ms
Running Task1 priority[60]  at : 13 ms
Running Task1 priority[60]  at : 14 ms
Running Task1 priority[60]  at : 15 ms
Running Task1 priority[60]  at : 16 ms
Running Task1 priority[60]  at : 17 ms
Running Task1 priority[60]  at : 18 ms
Running Task1 priority[60]  at : 19 ms
Running Task1 priority[60]  at : 20 ms
End of Task1
Running Task2 priority[60]  at : 1 ms
Running Task2 priority[60]  at : 2 ms
Running Task2 priority[60]  at : 3 ms
Running Task2 priority[60]  at : 4 ms
Running Task2 priority[60]  at : 5 ms
Running Task2 priority[60]  at : 6 ms
Running Task2 priority[60]  at : 7 ms
Running Task2 priority[60]  at : 8 ms
Running Task2 priority[60]  at : 9 ms
Running Task2 priority[60]  at : 10 ms
Running Task2 priority[60]  at : 11 ms
Running Task2 priority[60]  at : 12 ms
Running Task2 priority[60]  at : 13 ms
Running Task2 priority[60]  at : 14 ms
Running Task2 priority[60]  at : 15 ms
Running Task2 priority[60]  at : 16 ms
Running Task2 priority[60]  at : 17 ms
Running Task2 priority[60]  at : 18 ms
Running Task2 priority[60]  at : 19 ms
Running Task2 priority[60]  at : 20 ms
End of Task2
Running Task3 priority[60]  at : 1 ms
Running Task3 priority[60]  at : 2 ms
Running Task3 priority[60]  at : 3 ms
Running Task3 priority[60]  at : 4 ms
Running Task3 priority[60]  at : 5 ms
Running Task3 priority[60]  at : 6 ms
Running Task3 priority[60]  at : 7 ms
Running Task3 priority[60]  at : 8 ms
Running Task3 priority[60]  at : 9 ms
Running Task3 priority[60]  at : 10 ms
Running Task3 priority[60]  at : 11 ms
Running Task3 priority[60]  at : 12 ms
Running Task3 priority[60]  at : 13 ms
Running Task3 priority[60]  at : 14 ms
Running Task3 priority[60]  at : 15 ms
Running Task3 priority[60]  at : 16 ms
Running Task3 priority[60]  at : 17 ms
Running Task3 priority[60]  at : 18 ms
Running Task3 priority[60]  at : 19 ms
Running Task3 priority[60]  at : 20 ms
End of Task3






Le 09/11/2011 01:12, Gilles Chanteperdrix a écrit :
> See also ksrc/skins/native/API.CHANGES in xeny omai sources.



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

* Re: [Xenomai-help] Xenomai 2.5.6 and Round Robin
  2011-11-09 10:27   ` Olivier Reynet
@ 2011-11-09 11:02     ` Gilles Chanteperdrix
  2011-11-09 11:41       ` Olivier Reynet
  0 siblings, 1 reply; 5+ messages in thread
From: Gilles Chanteperdrix @ 2011-11-09 11:02 UTC (permalink / raw)
  To: Olivier Reynet; +Cc: xenomai

On 11/09/2011 11:27 AM, Olivier Reynet wrote:
>      RTIME quantum=rt_timer_ns2tsc(3*SPINTIME);
>      int err=rt_task_slice(&demo_task[i],quantum);

You are misunderstanding the time unit of rt_task_slice. Refer to
documentation.

-- 
					    Gilles.


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

* Re: [Xenomai-help] Xenomai 2.5.6 and Round Robin
  2011-11-09 11:02     ` Gilles Chanteperdrix
@ 2011-11-09 11:41       ` Olivier Reynet
  0 siblings, 0 replies; 5+ messages in thread
From: Olivier Reynet @ 2011-11-09 11:41 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: xenomai

[-- Attachment #1: Type: text/plain, Size: 379 bytes --]

ok, sorry for misunderstanding.

RTIME quantum=3;
is working.

/quantum/ 	The round-robin quantum for the task expressed in ticks (see 
note).

Howewer, there is no link to the mentioned note. It will help to understand the tick concept.

Best regards,
Olivier


Le 09/11/2011 12:02, Gilles Chanteperdrix a écrit :
> RTIME quantum=rt_timer_ns2tsc(3*SPINTIME);


[-- Attachment #2: Type: text/html, Size: 1947 bytes --]

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

end of thread, other threads:[~2011-11-09 11:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-08 21:06 [Xenomai-help] Xenomai 2.5.6 and Round Robin Olivier Reynet
2011-11-09  0:12 ` Gilles Chanteperdrix
2011-11-09 10:27   ` Olivier Reynet
2011-11-09 11:02     ` Gilles Chanteperdrix
2011-11-09 11:41       ` Olivier Reynet

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.