Merge branch 'master' of git@github.com:dopefishh/des2015
[des2015.git] / natanael / ex02 / ex02.c
1 #include <stdio.h>
2 #include <signal.h>
3 #include <unistd.h>
4 #include <sys/mman.h>
5
6 #include <native/task.h>
7 #include <native/timer.h>
8
9 #include <rtdk.h>
10 RT_TASK demo_task;
11
12 void demo(void *arg)
13 {
14 RT_TASK *curtask;
15 RT_TASK_INFO curtaskinfo;
16
17 // inquire current task
18 curtask=rt_task_self();
19 rt_task_inquire(curtask,&curtaskinfo);
20
21 // print task name
22 rt_printf("Task name : %s \n", curtaskinfo.name);
23 }
24
25 int main(int argc, char* argv[])
26 {
27 char str[10] ;
28 int i;
29
30 // Perform auto-init of rt_print buffers if the task doesn't do so
31 rt_print_auto_init(1);
32
33 // Lock memory : avoid memory swapping for this program
34 mlockall(MCL_CURRENT|MCL_FUTURE);
35
36 rt_printf("start task\n");
37
38 for (i=0; i<5; i++)
39 {
40 /*
41 * Arguments: &task,
42 * name,
43 * stack size (0=default),
44 * priority,
45 * mode (FPU, start suspended, ...)
46 */
47 sprintf(str,"hello-%d",i);
48 rt_task_create(&demo_task, str, 0, 50, 0);
49 /*
50 * Arguments: &task,
51 * task function,
52 * function argument
53 */
54 rt_task_start(&demo_task, &demo, 0);
55 }
56
57 }