init.c 1.21 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * Example initialization file - spawns 2 native FPU tasks
 *
 */
#define CONFIGURE_INIT
#define TASKS 2

#include "system.h"
#include <stdio.h>

rtems_task Init(rtems_task_argument argument)
{
    rtems_status_code status;
    rtems_name Task_name[TASKS]; /* task names */
    rtems_id Task_id[TASKS]; /* task ids */
    int i;

    for(i = 0; i < TASKS; i++)
    {
        // Initialize Task name
        Task_name[i] = rtems_build_name('T', 'T', "0" + i / 10, "0" + i % 10);

        // Create Task
        status = rtems_task_create(
            Task_name[i],
            (rtems_task_priority) 2,
            RTEMS_MINIMUM_STACK_SIZE,
            RTEMS_DEFAULT_MODES,
            RTEMS_FLOATING_POINT, // use RTEMS_DEFAULT_ATTRIBUTES for non-native FPU tasks
            &Task_id[i]);
	if (status != RTEMS_SUCCESSFUL) {
	    printf("Failed to rtems_task_create... status:%0x\n", status);
            rtems_task_delete(RTEMS_SELF);
	}

        // Start Task
        status = rtems_task_start(
            Task_id[i],
            Task_EntryPoint,
            i);
    }
    printf("Parent task sleeps for a second...\n");
    rtems_task_wake_after(100);
    printf("Parent task bids adieu...\n");
    rtems_task_delete(RTEMS_SELF);
}