All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] Hanging
@ 2011-08-24 10:51 suresh reddy
  2011-08-24 12:13 ` Gilles Chanteperdrix
  0 siblings, 1 reply; 9+ messages in thread
From: suresh reddy @ 2011-08-24 10:51 UTC (permalink / raw)
  To: Xenomai help


[-- Attachment #1.1: Type: text/plain, Size: 597 bytes --]

Dear all,

Iam trying to communicate two process using message . In one process i
called a dummy function (doing nothing except printing something for 2000
times) .

Iam trying to calculate the time elapsed for this process to process
communication .

1. The program working fine if i print or execute something for once  like
rt_printf("xenomai"); But if i used

for (i=0; i<2000; i++)

{

rt_printf("xenomai");

}

if i used like this the execution stops after printing for some 100 times or
so on my Pandaboard.  Please find the attached program.


Thanks
Suresh balijepalli
Rosenehim,Baveria.

[-- Attachment #1.2: Type: text/html, Size: 885 bytes --]

[-- Attachment #2: inter1.c --]
[-- Type: text/x-csrc, Size: 3366 bytes --]

#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <sys/mman.h>
#include <stdlib.h>
 
#include <native/task.h>
#include <native/timer.h>
#include <native/sem.h>
#include <native/mutex.h>
#include <native/queue.h>
 
#include  <rtdk.h>
 
#define NTASKS 2
 
#define QUEUE_SIZE 255
#define MAX_MESSAGE_LENGTH 40
 
RT_TASK task_struct[NTASKS];
 
#define QUEUE_SIZE 255
RT_QUEUE myqueue;
RT_QUEUE myqueue1;
double timed_delay = 0;

 int processing(void)
 {
     int k=0;/*k=0,i=3000;
     char * buffer;
     char a='a' ;
 dummy operation*/
rt_printf("xenomai");

return k;
}

void taskOne(void *arg)
{
    int retval,retval1,t1;
    char message[] = "Message from taskOne";
    char msgBuf1[MAX_MESSAGE_LENGTH];
    RTIME start_tsc = rt_timer_tsc();
    rt_printf("starting tics: %.3f\n",
    rt_timer_tsc2ns(start_tsc)*1e-6);
    /* send message */
    
    retval = rt_queue_write(&myqueue,message,sizeof(message),Q_NORMAL);
 
    if (retval < 0 ) {
       rt_printf("Sending error\n");
    } else {
       rt_printf("taskOne sent message to mailbox\n");
    } 

/* receive message */

retval1 =rt_queue_read(&myqueue1,msgBuf1,sizeof(msgBuf1),TM_INFINITE);
    if (retval1 < 0 ) {
          rt_printf("Receiving error\n");
    } else {
        rt_printf("task1 received message: %s\n",msgBuf1);
        rt_printf("with length %d\n",retval1);
    }
t1=processing();
    rt_printf("%d",t1);
RTIME tsc=rt_timer_tsc();
rt_printf("end tics: %.3f\n",
rt_timer_tsc2ns(tsc)*1e-6);
/*rt_printf("end tics: %.3f\n",
rt_timer_tsc2ns(tsc)*1e-6);
rt_printf(" time taken: %.3f\n",
rt_timer_ns2tsc(0.55)*1e-6);*/
timed_delay = rt_timer_tsc2ns(tsc-start_tsc)*1e-9;	
rt_printf(" %.3f ms\n",
 timed_delay * 1e3);	
}
 
void taskTwo(void *arg)
{
    
     int retval,retval1;
     char msgBuf[MAX_MESSAGE_LENGTH];
     char message1[] = "Message from tasktwo";
     

/* receive message */
    retval = rt_queue_read(&myqueue,msgBuf,sizeof(msgBuf),TM_INFINITE);
    if (retval < 0 ) {
          rt_printf("Receiving error\n");
    } else {
        rt_printf("taskTwo received message: %s\n",msgBuf);
        rt_printf("with length %d\n",retval);
    } 
/* send message */
    retval1 = rt_queue_write(&myqueue1,message1,sizeof(message1),Q_NORMAL);

    if (retval1 < 0 ) {
       rt_printf("Sending error\n");
    } else {
       rt_printf("tasktwo sent message to mailbox\n");
       }

     
}
 
//startup code
void startup()
{
  int i,t1;
  char  str[10] ;
 
  void (*task_func[NTASKS]) (void *arg);
  task_func[0]=taskOne;
  task_func[1]=taskTwo;
 
  rt_queue_create(&myqueue,"myqueue",QUEUE_SIZE,10,Q_FIFO);
  rt_queue_create(&myqueue1,"myqueue1",QUEUE_SIZE,10,Q_FIFO); 
  rt_timer_set_mode(0);// set timer to tick in nanoseconds and not in jiffies
  for(i=0; i < NTASKS; i++) {
    rt_printf("start task  : %d\n",i);
    sprintf(str,"task%d",i);
    rt_task_create(&task_struct[i], str, 0, 50, 0);
    rt_task_start(&task_struct[i], task_func[i], &i);
    
  }
}
 
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();
}

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

* Re: [Xenomai-help] Hanging
  2011-08-24 10:51 [Xenomai-help] Hanging suresh reddy
@ 2011-08-24 12:13 ` Gilles Chanteperdrix
  2011-08-24 12:35   ` suresh reddy
  0 siblings, 1 reply; 9+ messages in thread
From: Gilles Chanteperdrix @ 2011-08-24 12:13 UTC (permalink / raw)
  To: suresh reddy; +Cc: Xenomai help

On 08/24/2011 12:51 PM, suresh reddy wrote:
> Dear all,
> 
> Iam trying to communicate two process using message . In one process i
> called a dummy function (doing nothing except printing something for 2000
> times) .
> 
> Iam trying to calculate the time elapsed for this process to process
> communication .
> 
> 1. The program working fine if i print or execute something for once  like
> rt_printf("xenomai"); But if i used
> 
> for (i=0; i<2000; i++)
> 
> {
> 
> rt_printf("xenomai");
> 
> }
> 
> if i used like this the execution stops after printing for some 100 times or
> so on my Pandaboard.  Please find the attached program.

Are you sure you are not simply filling rt_printf buffer and never
leaving primary mode?

-- 
					    Gilles.


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

* Re: [Xenomai-help] Hanging
  2011-08-24 12:13 ` Gilles Chanteperdrix
@ 2011-08-24 12:35   ` suresh reddy
  2011-08-24 12:59     ` Gilles Chanteperdrix
  0 siblings, 1 reply; 9+ messages in thread
From: suresh reddy @ 2011-08-24 12:35 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: Xenomai help


[-- Attachment #1.1: Type: text/plain, Size: 426 bytes --]

 Dear Giles,

Please find the attached file of used code . Iam sure that iam not leaving
primary mode but iam using rt_printf(" xenomai") in a for loop to print for
some 1000 times. Ok if i leave primary mode i might get some delay than
expected but what happens if we use rt_printf to print 1000 times . And
please let me know how run some background process with this program on
pandaboard with only minicom login.


Thanks

[-- Attachment #1.2: Type: text/html, Size: 553 bytes --]

[-- Attachment #2: inter1.c --]
[-- Type: text/x-csrc, Size: 3366 bytes --]

#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <sys/mman.h>
#include <stdlib.h>
 
#include <native/task.h>
#include <native/timer.h>
#include <native/sem.h>
#include <native/mutex.h>
#include <native/queue.h>
 
#include  <rtdk.h>
 
#define NTASKS 2
 
#define QUEUE_SIZE 255
#define MAX_MESSAGE_LENGTH 40
 
RT_TASK task_struct[NTASKS];
 
#define QUEUE_SIZE 255
RT_QUEUE myqueue;
RT_QUEUE myqueue1;
double timed_delay = 0;

 int processing(void)
 {
     int k=0;/*k=0,i=3000;
     char * buffer;
     char a='a' ;
 dummy operation*/
rt_printf("xenomai");

return k;
}

void taskOne(void *arg)
{
    int retval,retval1,t1;
    char message[] = "Message from taskOne";
    char msgBuf1[MAX_MESSAGE_LENGTH];
    RTIME start_tsc = rt_timer_tsc();
    rt_printf("starting tics: %.3f\n",
    rt_timer_tsc2ns(start_tsc)*1e-6);
    /* send message */
    
    retval = rt_queue_write(&myqueue,message,sizeof(message),Q_NORMAL);
 
    if (retval < 0 ) {
       rt_printf("Sending error\n");
    } else {
       rt_printf("taskOne sent message to mailbox\n");
    } 

/* receive message */

retval1 =rt_queue_read(&myqueue1,msgBuf1,sizeof(msgBuf1),TM_INFINITE);
    if (retval1 < 0 ) {
          rt_printf("Receiving error\n");
    } else {
        rt_printf("task1 received message: %s\n",msgBuf1);
        rt_printf("with length %d\n",retval1);
    }
t1=processing();
    rt_printf("%d",t1);
RTIME tsc=rt_timer_tsc();
rt_printf("end tics: %.3f\n",
rt_timer_tsc2ns(tsc)*1e-6);
/*rt_printf("end tics: %.3f\n",
rt_timer_tsc2ns(tsc)*1e-6);
rt_printf(" time taken: %.3f\n",
rt_timer_ns2tsc(0.55)*1e-6);*/
timed_delay = rt_timer_tsc2ns(tsc-start_tsc)*1e-9;	
rt_printf(" %.3f ms\n",
 timed_delay * 1e3);	
}
 
void taskTwo(void *arg)
{
    
     int retval,retval1;
     char msgBuf[MAX_MESSAGE_LENGTH];
     char message1[] = "Message from tasktwo";
     

/* receive message */
    retval = rt_queue_read(&myqueue,msgBuf,sizeof(msgBuf),TM_INFINITE);
    if (retval < 0 ) {
          rt_printf("Receiving error\n");
    } else {
        rt_printf("taskTwo received message: %s\n",msgBuf);
        rt_printf("with length %d\n",retval);
    } 
/* send message */
    retval1 = rt_queue_write(&myqueue1,message1,sizeof(message1),Q_NORMAL);

    if (retval1 < 0 ) {
       rt_printf("Sending error\n");
    } else {
       rt_printf("tasktwo sent message to mailbox\n");
       }

     
}
 
//startup code
void startup()
{
  int i,t1;
  char  str[10] ;
 
  void (*task_func[NTASKS]) (void *arg);
  task_func[0]=taskOne;
  task_func[1]=taskTwo;
 
  rt_queue_create(&myqueue,"myqueue",QUEUE_SIZE,10,Q_FIFO);
  rt_queue_create(&myqueue1,"myqueue1",QUEUE_SIZE,10,Q_FIFO); 
  rt_timer_set_mode(0);// set timer to tick in nanoseconds and not in jiffies
  for(i=0; i < NTASKS; i++) {
    rt_printf("start task  : %d\n",i);
    sprintf(str,"task%d",i);
    rt_task_create(&task_struct[i], str, 0, 50, 0);
    rt_task_start(&task_struct[i], task_func[i], &i);
    
  }
}
 
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();
}

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

* Re: [Xenomai-help] Hanging
  2011-08-24 12:35   ` suresh reddy
@ 2011-08-24 12:59     ` Gilles Chanteperdrix
  2011-08-24 14:12       ` suresh reddy
  0 siblings, 1 reply; 9+ messages in thread
From: Gilles Chanteperdrix @ 2011-08-24 12:59 UTC (permalink / raw)
  To: suresh reddy; +Cc: Xenomai help

On 08/24/2011 02:35 PM, suresh reddy wrote:
>  Dear Giles,
> 
> Please find the attached file of used code . Iam sure that iam not leaving
> primary mode but iam using rt_printf(" xenomai") in a for loop to print for
> some 1000 times.

So, please take the time to understand how rt_printf work, and you will
understand my answer.

-- 
					    Gilles.


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

* Re: [Xenomai-help] Hanging
  2011-08-24 12:59     ` Gilles Chanteperdrix
@ 2011-08-24 14:12       ` suresh reddy
  2011-08-24 16:28         ` Gilles Chanteperdrix
  0 siblings, 1 reply; 9+ messages in thread
From: suresh reddy @ 2011-08-24 14:12 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: Xenomai help

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

Thank you Giles.

yes .The rt_printf is single-writer/ single -reader.



On 24 August 2011 14:59, Gilles Chanteperdrix <
gilles.chanteperdrix@xenomai.org> wrote:

> On 08/24/2011 02:35 PM, suresh reddy wrote:
> >  Dear Giles,
> >
> > Please find the attached file of used code . Iam sure that iam not
> leaving
> > primary mode but iam using rt_printf(" xenomai") in a for loop to print
> for
> > some 1000 times.
>
> So, please take the time to understand how rt_printf work, and you will
> understand my answer.
>
> --
>                                             Gilles.
>



-- 

Suresh balijepalli
Rosenehim,Baveria.

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

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

* Re: [Xenomai-help] Hanging
  2011-08-24 14:12       ` suresh reddy
@ 2011-08-24 16:28         ` Gilles Chanteperdrix
  2011-08-25  9:25           ` suresh reddy
  0 siblings, 1 reply; 9+ messages in thread
From: Gilles Chanteperdrix @ 2011-08-24 16:28 UTC (permalink / raw)
  To: suresh reddy; +Cc: Xenomai help

On 08/24/2011 04:12 PM, suresh reddy wrote:
> Thank you Giles.
> 
> yes .The rt_printf is single-writer/ single -reader.

No, each thread has a buffer. But the point is that the thread which
empties the buffers and prints them run in secondary mode, so, it will
not run if there is always a real-time thread running, the buffer will
fill up, and nothing will be printed.

-- 
					    Gilles.


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

* Re: [Xenomai-help] Hanging
  2011-08-24 16:28         ` Gilles Chanteperdrix
@ 2011-08-25  9:25           ` suresh reddy
  2011-08-25 17:57             ` Gilles Chanteperdrix
  0 siblings, 1 reply; 9+ messages in thread
From: suresh reddy @ 2011-08-25  9:25 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: Xenomai help

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

Dear Giles,

1. taking timing results using rt_timer-tsc on pandaboard for a test program
using xenomai native services.

2. taking timing results using gettimeofday on pandaboard for same test
program using linuxthreads.


Can i compare these two timing results ?






On 24 August 2011 18:28, Gilles Chanteperdrix <
gilles.chanteperdrix@xenomai.org> wrote:

> On 08/24/2011 04:12 PM, suresh reddy wrote:
> > Thank you Giles.
> >
> > yes .The rt_printf is single-writer/ single -reader.
>
> No, each thread has a buffer. But the point is that the thread which
> empties the buffers and prints them run in secondary mode, so, it will
> not run if there is always a real-time thread running, the buffer will
> fill up, and nothing will be printed.
>
> --
>                                             Gilles.
>



-- 

Suresh balijepalli
Rosenehim,Baveria.

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

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

* Re: [Xenomai-help] Hanging
  2011-08-25  9:25           ` suresh reddy
@ 2011-08-25 17:57             ` Gilles Chanteperdrix
  2011-08-25 18:18               ` suresh reddy
  0 siblings, 1 reply; 9+ messages in thread
From: Gilles Chanteperdrix @ 2011-08-25 17:57 UTC (permalink / raw)
  To: suresh reddy; +Cc: Xenomai help

On 08/25/2011 11:25 AM, suresh reddy wrote:
> Dear Giles,

It is Gilles.

> 
> 1. taking timing results using rt_timer-tsc on pandaboard for a test program
> using xenomai native services.
> 
> 2. taking timing results using gettimeofday on pandaboard for same test
> program using linuxthreads.
> 
> 
> Can i compare these two timing results ?

your system is likely using nptl, not linuxthreads. And clock_gettime
instead of gettimeofday will give you precision down to the nanosecond,
like rt_timer_tsc2ns.

But yes, you can compare the results, if you bear in mind that real-time
is about worst case latencies, so results obtained by running tests for
a few seconds or minutes on an idle machine are meaningless.

Also note that since Xenomai has a posix api, you can have the exact
same code running with and without xenomai.

-- 
                                                                Gilles.


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

* Re: [Xenomai-help] Hanging
  2011-08-25 17:57             ` Gilles Chanteperdrix
@ 2011-08-25 18:18               ` suresh reddy
  0 siblings, 0 replies; 9+ messages in thread
From: suresh reddy @ 2011-08-25 18:18 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: Xenomai help

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

Dear Gilles,

Thanks for the reply . Yes , the real-time is about worst case latencies ,
iam running a script in background which will keep on downloading from
network and removing the downloaded .Just to keep machine working.



Thanks
Suresh




On 25 August 2011 19:57, Gilles Chanteperdrix <
gilles.chanteperdrix@xenomai.org> wrote:

> On 08/25/2011 11:25 AM, suresh reddy wrote:
> > Dear Giles,
>
> It is Gilles.
>
> >
> > 1. taking timing results using rt_timer-tsc on pandaboard for a test
> program
> > using xenomai native services.
> >
> > 2. taking timing results using gettimeofday on pandaboard for same test
> > program using linuxthreads.
> >
> >
> > Can i compare these two timing results ?
>
> your system is likely using nptl, not linuxthreads. And clock_gettime
> instead of gettimeofday will give you precision down to the nanosecond,
> like rt_timer_tsc2ns.
>
> But yes, you can compare the results, if you bear in mind that real-time
> is about worst case latencies, so results obtained by running tests for
> a few seconds or minutes on an idle machine are meaningless.
>
> Also note that since Xenomai has a posix api, you can have the exact
> same code running with and without xenomai.
>
> --
>                                                                 Gilles.
>



-- 

Suresh balijepalli
Rosenehim,Baveria.

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

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

end of thread, other threads:[~2011-08-25 18:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-24 10:51 [Xenomai-help] Hanging suresh reddy
2011-08-24 12:13 ` Gilles Chanteperdrix
2011-08-24 12:35   ` suresh reddy
2011-08-24 12:59     ` Gilles Chanteperdrix
2011-08-24 14:12       ` suresh reddy
2011-08-24 16:28         ` Gilles Chanteperdrix
2011-08-25  9:25           ` suresh reddy
2011-08-25 17:57             ` Gilles Chanteperdrix
2011-08-25 18:18               ` suresh reddy

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.