update ex11
[des2015.git] / mart / xenomai / ex03 / ex03a.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 #include <native/sem.h>
9
10 #include <rtdk.h>
11
12 #define ITER 10
13
14 static RT_TASK t1;
15 static RT_TASK t2;
16
17 int global = 0;
18
19 void taskOne(void *arg)
20 {
21 int i;
22 for (i=0; i < ITER; i++)
23 {
24 rt_printf("I am taskOne and global = %d................\n", ++global);
25 }
26 }
27
28 void taskTwo(void *arg)
29 {
30 int i;
31 for (i=0; i < ITER; i++)
32 {
33 rt_printf("I am taskTwo and global = %d----------------\n", --global);
34 }
35 }
36
37 int main(int argc, char* argv[])
38 {
39 /* Perform auto-init of rt_print buffers if the task doesn't do so */
40 rt_print_auto_init(1);
41
42 /* Avoids memory swapping for this program */
43 mlockall(MCL_CURRENT|MCL_FUTURE);
44
45 /* create the two tasks */
46 rt_task_create(&t1, "task1", 0, 1, 0);
47 rt_task_create(&t2, "task2", 0, 1, 0);
48
49 /* start the two tasks */
50 rt_task_start(&t1, &taskOne, 0);
51 rt_task_start(&t2, &taskTwo, 0);
52
53 return 0;
54 }