5 #include <native/intr.h>
7 #include <native/task.h>
12 #define KEYBOARD_IRQ 1
14 void key_handler(void *arg
)
17 int nr_interrupts_waiting
;
20 RT_TASK_INFO curtaskinfo
;
23 //rt_printf("%d\n",count++);
24 nr_interrupts_waiting
= rt_intr_wait(&keypress
,TM_INFINITE
);
25 if (nr_interrupts_waiting
>0)
27 // inquire current task
28 curtask
=rt_task_self();
29 rt_task_inquire(curtask
,&curtaskinfo
);
30 rt_printf("Current priority of handler task: %d \n", curtaskinfo
.cprio
);
35 void dummy_task(void *arg
) {
36 while(1) { rt_printf("Sleeping\n");
38 rt_printf("Spinning\n");
46 rt_intr_create(&keypress
, NULL
, KEYBOARD_IRQ
, I_PROPAGATE
);
48 rt_task_create(&key_isr
, NULL
,0,50,0);
49 rt_task_start(&key_isr
, &key_handler
, NULL
);
52 rt_task_create(&dummy
, NULL
,0,53,0);
53 rt_task_start(&dummy
, &dummy_task
, NULL
);
57 /* Avoids memory swapping for this program */
58 mlockall(MCL_CURRENT
|MCL_FUTURE
);
60 /* Perform auto-init of rt_print buffers if the task doesn't do so */
61 rt_print_auto_init(1);
64 int main(int argc
, char* argv
[])
66 printf("\nType CTRL-C to end this program\n\n" );
68 // code to set things to run xenomai
74 // wait for CTRL-c is typed to end the program