All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai] imx6q xenomai  ipipe-3.0-imx6q
@ 2014-03-26 11:36 嵌入式工程师
  2014-03-26 11:50 ` Gilles Chanteperdrix
  0 siblings, 1 reply; 35+ messages in thread
From: 嵌入式工程师 @ 2014-03-26 11:36 UTC (permalink / raw)
  To: Gilles Chanteperdrix, xenomai

I use imx6q xenomai  ipipe-3.0-imx6q  ,i don`t know if rt_pipe and rt_timer will affect the latency?because I use lots of rt_pipe command and when I send the rt_pipe command the latency will like blow
RTH|----lat min|----lat avg|----lat max|-overrun|---msw|---lat best|--lat worst
RTD|      1.567|      2.023|      5.199|       0|     0|      1.282|    326.962
RTD|      1.560|      2.050|      5.492|       0|     0|      1.282|    326.962
RTD|      1.522|      2.066|      5.984|       0|     0|      1.282|    326.962
RTD|      1.552|      2.056|      4.938|       0|     0|      1.282|    326.962
RTD|      1.572|      2.040|      5.021|       0|     0|      1.282|    326.962
RTD|      1.536|      2.047|      4.678|       0|     0|      1.282|    326.962
RTD|      1.599|      2.052|      5.442|       0|     0|      1.282|    326.962
RTD|      1.639|      2.080|      6.692|       0|     0|      1.282|    326.962
RTD|      1.533|      2.056|      6.869|       0|     0|      1.282|    326.962
RTD|      1.578|      2.036|      5.364|       0|     0|      1.282|    326.962
RTD|      1.583|      2.042|      5.222|       0|     0|      1.282|    326.962
RTD|      1.522|      2.052|      5.702|       0|     0|      1.282|    326.962
RTD|      1.542|      2.042|      5.272|       0|     0|      1.282|    326.962
RTD|      1.618|      2.049|      5.580|       0|     0|      1.282|    326.962
RTD|      1.555|      2.059|      6.398|       0|     0|      1.282|    326.962
RTD|      1.527|      2.054|      5.862|       0|     0|      1.282|    326.962
RTD|      1.564|      2.038|      5.951|       0|     0|      1.282|    326.962
RTD|      1.567|      2.053|      4.857|       0|     0|      1.282|    326.962
RTD|      1.597|      2.072|      5.433|       0|     0|      1.282|    326.962
RTD|      1.533|      2.057|      5.725|       0|     0|      1.282|    326.962
RTD|      1.634|      2.055|      5.566|       0|     0|      1.282|    326.962
RTT|  00:10:10  (in-kernel periodic task, 1000 us period, priority 99)
RTH|----lat min|----lat avg|----lat max|-overrun|---msw|---lat best|--lat worst
RTD|      1.523|      2.063|      4.874|       0|     0|      1.282|    326.962
RTD|      1.601|      2.036|      4.922|       0|     0|      1.282|    326.962
RTD|      1.573|      2.064|      5.237|       0|     0|      1.282|    326.962
RTD|      1.563|      2.040|      5.386|       0|     0|      1.282|    326.962

^ permalink raw reply	[flat|nested] 35+ messages in thread
* [Xenomai] imx6q xenomai ipipe-3.0-imx6q
@ 2014-04-01  2:35 嵌入式工程师
  2014-04-01 10:49 ` Gilles Chanteperdrix
  0 siblings, 1 reply; 35+ messages in thread
From: 嵌入式工程师 @ 2014-04-01  2:35 UTC (permalink / raw)
  To: Gilles Chanteperdrix, xenomai

Hello Gilles ,this is my test about xenomai ,this can also effect the my program  and the latency test
,thanks 。


== Sampling period: 1000 us
== Test mode: in-kernel periodic task
== All results in microseconds
warming up...
RTT|  00:00:01  (in-kernel periodic task, 1000 us period, priority 99)
RTH|----lat min|----lat avg|----lat max|-overrun|---msw|---lat best|--lat worst
RTD|      0.452|     17.221|  16637.492|      16|     0|      0.452|  16637.492
RTD|      0.431|     17.253|  16641.974|      32|     0|      0.431|  16641.974
RTD|      0.459|     17.233|  16639.224|      48|     0|      0.431|  16641.974
RTD|      0.439|     17.231|  16638.423|      64|     0|      0.431|  16641.974
RTD|      0.454|     17.232|  16638.489|      80|     0|      0.431|  16641.974
RTD|      0.453|     17.223|  16638.569|      96|     0|      0.431|  16641.974
RTD|      0.440|     17.227|  16638.612|     112|     0|      0.431|  16641.974
RTD|      0.458|     17.224|  16637.822|     128|     0|      0.431|  16641.974
RTD|      0.407|     17.269|  16639.417|     144|     0|      0.407|  16641.974
RTD|      0.432|     17.237|  16638.607|     160|     0|      0.407|  16641.974
RTD|      0.442|     17.278|  16638.695|     176|     0|      0.407|  16641.974
RTD|      0.437|     17.226|  16639.202|     192|     0|      0.407|  16641.974
RTD|      0.427|     17.232|  16637.467|     208|     0|      0.407|  16641.974
RTD|      0.454|     17.280|  16638.828|     224|     0|      0.407|  16641.974
RTD|      0.421|     17.241|  16637.866|     240|     0|      0.407|  16641.974
RTD|      0.398|     17.236|  16639.530|     256|     0|      0.398|  16641.974
RTD|      0.431|     17.252|  16637.032|     272|     0|      0.398|  16641.974
RTD|      0.446|     17.256|  16638.845|     288|     0|      0.398|  16641.974
RTD|      0.446|     17.253|  16638.981|     304|     0|      0.398|  16641.974
RTD|      0.433|     17.243|  16637.329|     320|     0|      0.398|  16641.974
^C---|-----------|-----------|-----------|--------|------|-------------------------
RTS|      0.398|     17.242|  16641.974|     320|     0|    00:00:21/00:00:21
-sh-2.05b# 




#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <sys/mman.h>


#include <native/task.h>
#include <native/timer.h>


RT_TASK demo_task;


/* NOTE: error handling omitted. */


void demo(void *arg)
{
        RTIME now, previous;


        /*
         * Arguments: &task (NULL=self),
         *            start time,
         *            period (here: 1 s)
         */
        rt_task_set_periodic(NULL, TM_NOW, 1000000000);
        previous = rt_timer_read();
long long i,j,k;
        while (1) {
                rt_task_wait_period(NULL);
                now = rt_timer_read();
 for(i=1;i<1000;i++)
for(j=1;j<i;j++)
k=i*j;
                /*
                 * NOTE: printf may have unexpected impact on the timing of
                 *       your program. It is used here in the critical loop
                 *       only for demonstration purposes.
                 */
                printf("Time since last turn: %ld.%06ld ms\n",
                       (long)(now - previous) / 1000000,
                       (long)(now - previous) % 1000000);
                       previous = now;
        }
}


void catch_signal(int sig)
{
}


int main(int argc, char* argv[])
{
        signal(SIGTERM, catch_signal);
        signal(SIGINT, catch_signal);


        /* Avoids memory swapping for this program */
        mlockall(MCL_CURRENT|MCL_FUTURE);


        /*
         * Arguments: &task,
         *            name,
         *            stack size (0=default),
         *            priority,
         *            mode (FPU, start suspended, ...)
         */
        rt_task_create(&demo_task, "trivial", 0, 99, 0);


        /*
         * Arguments: &task,
         *            task function,
         *            function argument
         */
        rt_task_start(&demo_task, &demo, NULL);


        pause();


        rt_task_delete(&demo_task);
}

^ permalink raw reply	[flat|nested] 35+ messages in thread
* [Xenomai] imx6q xenomai ipipe-3.0-imx6q
@ 2014-04-17  7:43 嵌入式工程师
  2014-04-17 11:42 ` Gilles Chanteperdrix
  0 siblings, 1 reply; 35+ messages in thread
From: 嵌入式工程师 @ 2014-04-17  7:43 UTC (permalink / raw)
  To: Gilles Chanteperdrix, xenomai, liu.h.f, huang.c.h

I use the  ipipe-3.0-imx6q and xenomai-2.6.3 ,my board is imx6q 800MHz . And I analog my actual application.  when I use share memery in different  rt_tasks and bind with different cpus . The latency in 1000us at beginning  it is about 14us  but  when i run more tasks it will reach 150us or higher .My tasks run more contents than the blow examples .  I do not know if some thing wrong with my task.


result:
1task: 0.000421 ms                                                              
pmax: 0.014372 ms                                                               
1task: 0.057951 ms                                                              
1max: 0.153273 ms   


the example test.  Thank you very much




















#include <linux/module.h> 
#include <linux/types.h>  
#include <linux/fs.h>  
#include <linux/types.h>  
#include <linux/kernel.h>  
#include <linux/init.h>  
#include <linux/platform_device.h>  
#include <linux/cdev.h>  
#include <linux/ioctl.h>  
#include <linux/gpio.h>  
#include <linux/mm.h>  
#include <linux/errno.h>  
#include <asm/uaccess.h>  
#include <linux/slab.h>  
#include <asm/io.h> 
#include <linux/sched.h>  
#include <linux/delay.h>
#include <linux/kthread.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <nucleus/module.h>
#include <linux/string.h> 
#include <native/timer.h>
#include <native/alarm.h>
#include <native/task.h>
#include <native/sem.h>
#include <native/intr.h>
#include <native/heap.h>
#include <native/pipe.h>


#define TASK_PRIO 99 /* Highest RT priority */
#define TASK_MODE 0 /* No flags */
#define TASK_STKSZ 0 /* Stack size (use default one) */
RTIME now, previous;
RTIME pnow, pprevious;
RT_TASK t1,t2,t3;
RT_SEM  semt1,semt2,semt3;
RT_HEAP heap_desc;
long * mem_spvm; 
void *block;




MODULE_LICENSE("GPL");




static unsigned char logo[6957]={0};


long long tmp=0;


void taskOne(void*arg)
{
rt_task_set_periodic(NULL,TM_NOW,1000000);//1000us
long i;
long max,pmax;
int j;
previous = rt_timer_read();
pprevious=rt_timer_read();
while(1)
{
rt_sem_v(&semt2);


pnow = rt_timer_read();
if(pmax<(long)(pnow - pprevious-tmp))
pmax=(long)(pnow - pprevious-tmp);
if(j<10000)
pmax=0;
if(i%20000==0){
printk("1task: %d.%06d ms\n",
     (int)(pnow - pprevious-tmp) / 1000000,
     (int)(pnow - previous-tmp) % 1000000);
printk("pmax: %ld.%06ld ms\n",(long)pmax/1000000,(long)pmax%1000000);// first I read a max delay it is littile aboot 10us
}
memset(mem_spvm,0,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,255,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,0,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,255,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,0,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,255,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,0,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,255,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,0,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,255,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,0,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,255,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
now = rt_timer_read();
if(max<(long)(now - previous-tmp))
max=(long)(now - previous-tmp);
if(j++<10000)
max=0;
if(i++%20000==0){
printk("1task: %d.%06d ms\n",
     (int)(now - previous-tmp) / 1000000,
     (int)(now - previous-tmp) % 1000000);
printk("1max: %ld.%06ld ms\n",(long)max/1000000,(long)max%1000000);//the max delay about 154 us
printk("spvm6: %d \n",(char)mem_spvm[6]);
printk("spvm1: %d  ",(char)mem_spvm[sizeof(logo)]);
}
tmp=tmp+1000000; 
rt_task_wait_period(NULL);
}
}


void taskTwo(void*arg)
{
int i=0;
long max=0;
while(1)
{
rt_sem_p(&semt2,TM_INFINITE);
now = rt_timer_read();
memset(mem_spvm,255,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo)); 
if(i++%20000==0){
printk("2spvm6: %d \n",(char)mem_spvm[6]);
printk("2spvm1: %d\n",(char)mem_spvm[sizeof(logo)]);
}
  
rt_sem_v(&semt3);
}
}


void taskThree(void*arg)
{


int i;
while(1)
{
rt_sem_p(&semt3,TM_INFINITE);
memset(mem_spvm,255,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo)); 
if(i++%20000==0){
printk("3spvm6: %d \n",(char)mem_spvm[6]);
printk("3spvm1: %d\n",(char)mem_spvm[sizeof(logo)]);
}
}
}




#define HEAP_SIZE (15*1024*1024)
                   
#define HEAP_MODE 0  /* Local heap. */


static int __init rtex_init(void){


int ret,err;




err =rt_heap_create(&heap_desc,"MyHeapName1",HEAP_SIZE,HEAP_MODE);
if (err)
printk("rt_heap_create wrong\n");
err = rt_heap_alloc(&heap_desc,1024*1024,TM_INFINITE,&block);
if (err)
printk("rt_heap_alloc wrong\n");
mem_spvm=(long*)block;
if(mem_spvm == NULL ) 
              printk("mem_spvm failed!\n"); 
        else 
              printk("mem_spvm successfully! \naddr = 0x%lx\n",(unsigned long)mem_spvm); 


 
rt_sem_create(&semt1,"",0,S_FIFO);
rt_sem_create(&semt2,"",0,S_FIFO);
rt_sem_create(&semt3,"",0,S_FIFO);


if(!rt_task_create(&t1, "task1", 4096, 99, T_FPU|T_CPU(0)))
rt_task_start(&t1, taskOne, NULL);
if(!rt_task_create(&t2, "task2", 4096, 85, T_FPU|T_CPU(1)))
rt_task_start(&t2, taskTwo, NULL);
if(!rt_task_create(&t3, "task3", 4096, 80, T_FPU|T_CPU(2)))
rt_task_start(&t3,taskThree, NULL);
       
     
  
 return ret; 


}


static void __exit rtex_exit(void)
{


rt_heap_free(&heap_desc,block);
rt_heap_delete(&heap_desc);
rt_task_delete(&t1);
rt_task_delete(&t2);
rt_task_delete(&t3);
printk("rtex_exit \n");
}
module_init(rtex_init);
module_exit(rtex_exit);

^ permalink raw reply	[flat|nested] 35+ messages in thread
* [Xenomai] imx6q xenomai ipipe-3.0-imx6q
@ 2014-04-17  7:58 嵌入式工程师
  0 siblings, 0 replies; 35+ messages in thread
From: 嵌入式工程师 @ 2014-04-17  7:58 UTC (permalink / raw)
  To: Gilles Chanteperdrix, xenomai, liu.h.f, huang.c.h

I use the  ipipe-3.0-imx6q and xenomai-2.6.3 ,my board is imx6q 800MHz . And I analog my actual application.  when I use share memery in different  rt_tasks and bind with different cpus . The latency in 1000us at beginning  it is about 14us  but  when i run more tasks it will reach 150us or higher .My tasks run more contents than the blow examples .  I do not know if some thing wrong with my task.  And if copy some large file about 30M to /tmp  the latency will more higher . cp larg.tar.bz2 /tmp       (/tmp is memery directory )
result:
1task: 0.000421 ms                                                              
pmax: 0.014372 ms                                                               
1task: 0.057951 ms                                                              
1max: 0.153273 ms   


the example test.  Thank you very much




















#include <linux/module.h> 
#include <linux/types.h>  
#include <linux/fs.h>  
#include <linux/types.h>  
#include <linux/kernel.h>  
#include <linux/init.h>  
#include <linux/platform_device.h>  
#include <linux/cdev.h>  
#include <linux/ioctl.h>  
#include <linux/gpio.h>  
#include <linux/mm.h>  
#include <linux/errno.h>  
#include <asm/uaccess.h>  
#include <linux/slab.h>  
#include <asm/io.h> 
#include <linux/sched.h>  
#include <linux/delay.h>
#include <linux/kthread.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <nucleus/module.h>
#include <linux/string.h> 
#include <native/timer.h>
#include <native/alarm.h>
#include <native/task.h>
#include <native/sem.h>
#include <native/intr.h>
#include <native/heap.h>
#include <native/pipe.h>


#define TASK_PRIO 99 /* Highest RT priority */
#define TASK_MODE 0 /* No flags */
#define TASK_STKSZ 0 /* Stack size (use default one) */
RTIME now, previous;
RTIME pnow, pprevious;
RT_TASK t1,t2,t3;
RT_SEM  semt1,semt2,semt3;
RT_HEAP heap_desc;
long * mem_spvm; 
void *block;




MODULE_LICENSE("GPL");




static unsigned char logo[6957]={0};


long long tmp=0;


void taskOne(void*arg)
{
rt_task_set_periodic(NULL,TM_NOW,1000000);//1000us
long i;
long max,pmax;
int j;
previous = rt_timer_read();
pprevious=rt_timer_read();
while(1)
{
rt_sem_v(&semt2);


pnow = rt_timer_read();
if(pmax<(long)(pnow - pprevious-tmp))
pmax=(long)(pnow - pprevious-tmp);
if(j<10000)
pmax=0;
if(i%20000==0){
printk("1task: %d.%06d ms\n",
     (int)(pnow - pprevious-tmp) / 1000000,
     (int)(pnow - previous-tmp) % 1000000);
printk("pmax: %ld.%06ld ms\n",(long)pmax/1000000,(long)pmax%1000000);// first I read a max delay it is littile aboot 10us
}
memset(mem_spvm,0,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,255,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,0,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,255,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,0,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,255,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,0,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,255,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,0,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,255,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,0,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,255,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
now = rt_timer_read();
if(max<(long)(now - previous-tmp))
max=(long)(now - previous-tmp);
if(j++<10000)
max=0;
if(i++%20000==0){
printk("1task: %d.%06d ms\n",
     (int)(now - previous-tmp) / 1000000,
     (int)(now - previous-tmp) % 1000000);
printk("1max: %ld.%06ld ms\n",(long)max/1000000,(long)max%1000000);//the max delay about 154 us
printk("spvm6: %d \n",(char)mem_spvm[6]);
printk("spvm1: %d  ",(char)mem_spvm[sizeof(logo)]);
}
tmp=tmp+1000000; 
rt_task_wait_period(NULL);
}
}


void taskTwo(void*arg)
{
int i=0;
long max=0;
while(1)
{
rt_sem_p(&semt2,TM_INFINITE);
now = rt_timer_read();
memset(mem_spvm,255,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo)); 
if(i++%20000==0){
printk("2spvm6: %d \n",(char)mem_spvm[6]);
printk("2spvm1: %d\n",(char)mem_spvm[sizeof(logo)]);
}
  
rt_sem_v(&semt3);
}
}


void taskThree(void*arg)
{


int i;
while(1)
{
rt_sem_p(&semt3,TM_INFINITE);
memset(mem_spvm,255,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo)); 
if(i++%20000==0){
printk("3spvm6: %d \n",(char)mem_spvm[6]);
printk("3spvm1: %d\n",(char)mem_spvm[sizeof(logo)]);
}
}
}




#define HEAP_SIZE (15*1024*1024)
                   
#define HEAP_MODE 0  /* Local heap. */


static int __init rtex_init(void){


int ret,err;




err =rt_heap_create(&heap_desc,"MyHeapName1",HEAP_SIZE,HEAP_MODE);
if (err)
printk("rt_heap_create wrong\n");
err = rt_heap_alloc(&heap_desc,1024*1024,TM_INFINITE,&block);
if (err)
printk("rt_heap_alloc wrong\n");
mem_spvm=(long*)block;
if(mem_spvm == NULL ) 
              printk("mem_spvm failed!\n"); 
        else 
              printk("mem_spvm successfully! \naddr = 0x%lx\n",(unsigned long)mem_spvm); 


 
rt_sem_create(&semt1,"",0,S_FIFO);
rt_sem_create(&semt2,"",0,S_FIFO);
rt_sem_create(&semt3,"",0,S_FIFO);


if(!rt_task_create(&t1, "task1", 4096, 99, T_FPU|T_CPU(0)))
rt_task_start(&t1, taskOne, NULL);
if(!rt_task_create(&t2, "task2", 4096, 85, T_FPU|T_CPU(1)))
rt_task_start(&t2, taskTwo, NULL);
if(!rt_task_create(&t3, "task3", 4096, 80, T_FPU|T_CPU(2)))
rt_task_start(&t3,taskThree, NULL);
       
     
  
 return ret; 


}


static void __exit rtex_exit(void)
{


rt_heap_free(&heap_desc,block);
rt_heap_delete(&heap_desc);
rt_task_delete(&t1);
rt_task_delete(&t2);
rt_task_delete(&t3);
printk("rtex_exit \n");
}
module_init(rtex_init);
module_exit(rtex_exit);



^ permalink raw reply	[flat|nested] 35+ messages in thread
* [Xenomai] imx6q xenomai ipipe-3.0-imx6q
@ 2014-04-17  8:13 嵌入式工程师
  0 siblings, 0 replies; 35+ messages in thread
From: 嵌入式工程师 @ 2014-04-17  8:13 UTC (permalink / raw)
  To: Gilles Chanteperdrix, xenomai, liu.h.f, huang.c.h

I mean, when I run the more user-level program on memory operations,the latency from 154us to 391us

^ permalink raw reply	[flat|nested] 35+ messages in thread
* [Xenomai] imx6q xenomai ipipe-3.0-imx6q
@ 2014-04-18 10:28 嵌入式工程师
  2014-04-18 11:47 ` Gilles Chanteperdrix
  0 siblings, 1 reply; 35+ messages in thread
From: 嵌入式工程师 @ 2014-04-18 10:28 UTC (permalink / raw)
  To: Gilles Chanteperdrix, xenomai, liu.h.f, huang.c.h



I do the same on the imx53 with imx6 test, in the process of real-time task to run the same operation content, start the qt deform demo and copy large file  to memory, in 250 us the  latency on imx6 board began to accumulate, lost real-time, but latency  on the imx53   only value within 20 us. I do not run anyother rt task on my below test:


#include <linux/module.h> 
#include <linux/types.h>  
#include <linux/fs.h>  
#include <linux/types.h>  
#include <linux/kernel.h>  
#include <linux/init.h>  
#include <linux/platform_device.h>  
#include <linux/cdev.h>  
#include <linux/ioctl.h>  
#include <linux/gpio.h>  
#include <linux/mm.h>  
#include <linux/errno.h>  
#include <asm/uaccess.h>  
#include <linux/slab.h>  
#include <asm/io.h> 
#include <linux/sched.h>  
#include <linux/delay.h>
#include <linux/kthread.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <nucleus/module.h>
#include <linux/string.h> 
#include <native/timer.h>
#include <native/alarm.h>
#include <native/task.h>
#include <native/sem.h>
#include <native/intr.h>
#include <native/heap.h>
#include <rtdm/rtdm_driver.h>
#include <native/pipe.h>
#include <linux/spinlock.h>
#include <linux/io.h>
#include <linux/ipipe.h>
#include <nucleus/timer.h>
#define TASK_PRIO 99 /* Highest RT priority */
#define TASK_MODE 0 /* No flags */
#define TASK_STKSZ 0 /* Stack size (use default one) */
RTIME now, previous;
RTIME pnow, pprevious;
rtdm_task_t t1,t2,t3;
//RT_SEM  semt1,semt2,semt3,irq_sem;
rtdm_sem_t semt1,semt2,semt3;
RT_HEAP heap_desc;
long * mem_spvm; 
void *block;
//static xntimer_t rtimer;
static rtdm_timer_t rtimer;


static IPIPE_DEFINE_SPINLOCK(mem_lock);
#define CAT_IRQ          IMX_GPIO_NR(5, 0)
MODULE_LICENSE("GPL");
int irq = -1;
#define HEARTBEAT_PERIOD250000 /* 100 ms */
static rtdm_task_t heartbeat_task,heartbeat_task1,heartbeat_task2;


static unsigned char logo[1024*10]={0};


long long tmp=0;
int irq_taskOne(int irq, void *device_id)
{
//rt_task_set_periodic(NULL,TM_NOW,250000);
//rt_sem_v(&irq_sem);
return RT_INTR_HANDLED;
}
long i;
long max,pmax;
int j;


void taskOne(void*arg)
{
previous = rt_timer_read();
pprevious=rt_timer_read();


while(1)
{
//rt_sem_p(&irq_sem,TM_INFINITE);
unsigned long flags;
pnow = rt_timer_read();
if(pmax<(long)(pnow - pprevious-tmp))
pmax=(long)(pnow - pprevious-tmp);
if(j<10000)
pmax=0;
if(i%20000==0){
rtdm_printk ("1task: %d.%06d ms\n",
     (int)(pnow - pprevious-tmp) / 1000000,
     (int)(pnow - previous-tmp) % 1000000);
rtdm_printk ("pmax: %ld.%06ld ms\n",(long)pmax/1000000,(long)pmax%1000000);
}
//spin_lock_irqsave(&mem_lock, flags);
memset(mem_spvm,0,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,255,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,0,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,255,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,0,sizeof(logo));
/*memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,255,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,0,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,255,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,0,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,255,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,0,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));
memset(mem_spvm,255,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo));*/
//spin_unlock_irqrestore(&mem_lock, flags);
now = rt_timer_read();
if(max<(long)(now - previous-tmp))
max=(long)(now - previous-tmp);
if(j++<10000)
max=0;
if(i++%20000==0){
printk("1task: %d.%06d ms\n",
     (int)(now - previous-tmp) / 1000000,
     (int)(now - previous-tmp) % 1000000);
rtdm_printk ("1max: %ld.%06ld ms\n",(long)max/1000000,(long)max%1000000);
rtdm_printk ("spvm6: %d \n",(char)mem_spvm[6]);
rtdm_printk ("spvm1: %d  ",(char)mem_spvm[sizeof(logo)]);
}
tmp=tmp+250000; 
rtdm_sem_up(&semt1);
//rt_sem_v(&semt2);
//rt_task_wait_period(NULL);
rtdm_task_wait_period();
}
}


void taskTwo(void*arg)
{
int i=0;
long max=0;
while(1)
{
//rt_sem_p(&semt2,TM_INFINITE);
rtdm_sem_down(&semt1) ;
now = rt_timer_read();
memset(mem_spvm,255,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo)); 
if(i++%20000==0){
rtdm_printk ("2spvm6: %d \n",(char)mem_spvm[6]);
rtdm_printk ("2spvm1: %d\n",(char)mem_spvm[sizeof(logo)]);
}
  
rtdm_sem_up(&semt2);
}
}


void taskThree(void*arg)
{


int i;
while(1)
{
rtdm_sem_down(&semt2) ;
memset(mem_spvm,255,sizeof(logo));
memcpy(mem_spvm,logo,sizeof(logo)); 
if(i++%20000==0){
rtdm_printk ("3spvm6: %d \n",(char)mem_spvm[6]);
rtdm_printk ("3spvm1: %d\n",(char)mem_spvm[sizeof(logo)]);
}
}
}




#define HEAP_SIZE (15*1024*1024)
                   
#define HEAP_MODE 0  /* Local heap. */
RT_INTR intr_desc;
static int periode_us = 1000;
static int __init rtex_init(void){


int ret,err;
/*err = gpio_request(CAT_IRQ,NULL);
if(err < 0){
printk("gpio_request failure !\n");
return err;
}
err = gpio_direction_input(CAT_IRQ);
if(err < 0){
printk("gpio_direction_input failure !\n");
return err;
}
irq = gpio_to_irq(CAT_IRQ);
irq_set_irq_type(irq,IRQ_TYPE_EDGE_RISING);
err = rt_intr_create(&intr_desc,"MyIrq",irq,irq_taskOne,NULL,I_SHARED|I_EDGE);
if(err){
printk("rt_intr_create failure !\n");
return err;
}
printk("rt_intr_create  irq=%d\n",irq);
rt_intr_enable(&intr_desc);
printk("I have enable the irq\n");*/


/*err =rt_heap_create(&heap_desc,"MyHeapName1",HEAP_SIZE,HEAP_MODE);
if (err)
printk("rt_heap_create wrong\n");
err = rt_heap_alloc(&heap_desc,1024*1024,TM_INFINITE,&block);
if (err)
printk("rt_heap_alloc wrong\n");*/
block=(long*)rtdm_malloc(1024*11);
mem_spvm=(long*)block;
if(mem_spvm == NULL ) 
              printk("mem_spvm failed!\n"); 
        else 
              printk("mem_spvm successfully! \naddr = 0x%lx\n",(unsigned long)mem_spvm); 
 
/*rt_sem_create(&semt1,"",0,S_FIFO);
rt_sem_create(&semt2,"",0,S_FIFO);
rt_sem_create(&semt3,"",0,S_FIFO);
rt_sem_create(&irq_sem,"",0,S_FIFO);*/
rtdm_sem_init(&semt1,0) ;
rtdm_sem_init(&semt2,0) ;
rtdm_sem_init(&semt3,0) ;
/*if(!rt_task_create(&t1, "task1", 4096, 99, T_FPU|T_CPU(0)))
rt_task_start(&t1, taskOne, NULL);*/
/*if(!rt_task_create(&t2, "task2", 4096, 85, T_FPU|T_CPU(1)))
rt_task_start(&t2, taskTwo, NULL);
if(!rt_task_create(&t3, "task3", 4096, 80, T_FPU|T_CPU(2)))
rt_task_start(&t3,taskThree, NULL);*/
printk("mem_spv ! \naddr = 0x%lx\n",(unsigned long)mem_spvm);
        rtdm_task_init(&heartbeat_task, "heartbeat", taskOne, NULL,
     99, HEARTBEAT_PERIOD);


     rtdm_task_set_period(&heartbeat_task,250000) ;
rtdm_task_set_priority(&heartbeat_task,99);
rtdm_task_unblock(&heartbeat_task);
printk("mem_spvm successfully! \naddr = 0x%lx\n",(unsigned long)mem_spvm);
rtdm_task_init(&heartbeat_task2, "heartbeat1", taskThree, NULL,
     80, HEARTBEAT_PERIOD);
rtdm_task_init(&heartbeat_task1, "heartbeat1", taskTwo, NULL,
     85, HEARTBEAT_PERIOD);
//xnticks_t now;
//now = xntbase_get_jiffies(&nktbase);
/*if ((err = rtdm_timer_init(& rtimer, taskOne, "Oscillateur")) != 0) {
return err;
}
if ((err = rtdm_timer_start(& rtimer, periode_us*250, periode_us*250, RTDM_TIMERMODE_RELATIVE)) != 0) {
rtdm_timer_destroy(& rtimer);
return err;
}*/
/*xntbase_enabled_p(&nktbase);
xntimer_init(&rtimer, &nktbase, taskOne);


xntimer_set_priority(&rtimer, XNTIMER_HIPRIO);
xntimer_start(&rtimer, 250000UL, 250000UL, XN_RELATIVE);*/


 return ret; 


}


static void __exit rtex_exit(void)
{


//rt_heap_free(&heap_desc,block);
//rt_heap_delete(&heap_desc);
rtdm_free(block); 
rtdm_task_join_nrt(&heartbeat_task, 100);
//rt_task_delete(&t1);
rt_task_delete(&t2);
rt_task_delete(&t3);
printk("rtex_exit \n");
}
module_init(rtex_init);
module_exit(rtex_exit);


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

end of thread, other threads:[~2014-04-23 12:24 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-26 11:36 [Xenomai] imx6q xenomai ipipe-3.0-imx6q 嵌入式工程师
2014-03-26 11:50 ` Gilles Chanteperdrix
2014-03-26 13:31   ` 嵌入式工程师
2014-03-26 13:34     ` Gilles Chanteperdrix
2014-03-26 14:29       ` 嵌入式工程师
2014-03-26 23:09         ` Gilles Chanteperdrix
2014-03-27  1:41           ` 嵌入式工程师
2014-03-27  5:24           ` 嵌入式工程师
2014-03-27 12:27             ` Gilles Chanteperdrix
2014-03-28  5:02               ` 嵌入式工程师
2014-03-28 17:35                 ` Gilles Chanteperdrix
2014-03-29  5:54                   ` 嵌入式工程师
2014-03-28  8:19               ` 嵌入式工程师
2014-03-28 17:37                 ` Gilles Chanteperdrix
2014-03-28  9:08               ` 嵌入式工程师
2014-03-28 17:38                 ` Gilles Chanteperdrix
2014-03-29  6:21                   ` 嵌入式工程师
2014-03-29 13:51                     ` Gilles Chanteperdrix
2014-04-01  2:35 嵌入式工程师
2014-04-01 10:49 ` Gilles Chanteperdrix
2014-04-02  0:53   ` 嵌入式工程师
2014-04-02  7:28     ` Gilles Chanteperdrix
2014-04-03 10:25       ` 嵌入式工程师
2014-04-17  7:43 嵌入式工程师
2014-04-17 11:42 ` Gilles Chanteperdrix
2014-04-17  7:58 嵌入式工程师
2014-04-17  8:13 嵌入式工程师
2014-04-18 10:28 嵌入式工程师
2014-04-18 11:47 ` Gilles Chanteperdrix
2014-04-20  5:06   ` eric
2014-04-20  9:03     ` Gilles Chanteperdrix
2014-04-20  9:23       ` Gilles Chanteperdrix
2014-04-20 10:46         ` eric
2014-04-23  4:40           ` eric
2014-04-23 12:24             ` 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.