OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [tests/] [sptests/] [sp28/] [init.c] - Blame information for rev 609

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 *  $Id: init.c,v 1.2 2001-09-27 12:02:36 chris Exp $
3
 */
4
 
5
#define TEST_INIT
6
#include <tmacros.h>
7
 
8
rtems_task Init(rtems_task_argument argument);
9
 
10
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
11
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
12
#define CONFIGURE_MAXIMUM_USER_EXTENSIONS    2
13
 
14
#define CONFIGURE_MAXIMUM_TASKS              4
15
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
16
#define CONFIGURE_MICROSECONDS_PER_TICK       52429
17
 
18
#define CONFIGURE_MICROSECONDS_INIT
19
 
20
#include <confdefs.h>
21
 
22
#include <bsp.h>
23
#include <rtems/error.h>
24
#include <stdio.h>
25
 
26
volatile void *taskvar;
27
volatile int nRunning;
28
volatile int nDeleted;
29
 
30
rtems_task
31
subtask (rtems_task_argument arg)
32
{
33
        int localvar = arg;
34
        int i;
35
        rtems_status_code sc;
36
 
37
        nRunning++;
38
        while (nRunning != 3)
39
                rtems_task_wake_after (0);
40
        sc = rtems_task_variable_add (RTEMS_SELF, (void **)&taskvar, NULL);
41
        if (sc != RTEMS_SUCCESSFUL) {
42
                printf ("Can't add task variable: %s\n", rtems_status_text (sc));
43
                rtems_task_suspend (RTEMS_SELF);
44
        }
45
        taskvar = (void *)localvar;
46
        while (localvar < 1000) {
47
                localvar++;
48
                rtems_task_wake_after (0);
49
                taskvar = (void *)((int)taskvar + 1);
50
                rtems_task_wake_after (0);
51
                if ((int)taskvar != localvar) {
52
                        printf ("Task:%d taskvar:%d localvar:%d\n", arg, (int)taskvar, localvar);
53
                        rtems_task_suspend (RTEMS_SELF);
54
                }
55
        }
56
        sc = rtems_task_variable_delete (RTEMS_SELF, (void **)&taskvar);
57
        nDeleted++;
58
        if (sc != RTEMS_SUCCESSFUL) {
59
                printf ("Can't delete task variable: %s\n", rtems_status_text (sc));
60
                nRunning--;
61
                rtems_task_suspend (RTEMS_SELF);
62
        }
63
        if ((int)taskvar == localvar) {
64
                printf ("Task:%d deleted taskvar:%d localvar:%d\n", arg, (int)taskvar, localvar);
65
                nRunning--;
66
                rtems_task_suspend (RTEMS_SELF);
67
        }
68
        while (nDeleted != 3)
69
                rtems_task_wake_after (0);
70
        for (i = 0 ; i < 1000 ; i++) {
71
                taskvar = (void *)(localvar = 100 * arg);
72
                rtems_task_wake_after (0);
73
                if (nRunning <= 1)
74
                        break;
75
                if ((int)taskvar == localvar) {
76
                        printf ("Task:%d taskvar:%d localvar:%d\n", arg, (int)taskvar, localvar);
77
                        nRunning--;
78
                        rtems_task_suspend (RTEMS_SELF);
79
                }
80
        }
81
        nRunning--;
82
        while (nRunning)
83
                rtems_task_wake_after (0);
84
        printf ("Task variables test complete.\n");
85
        puts ("*** END OF TEST SP28 ***" );
86
        exit (0);
87
}
88
 
89
void
90
starttask (int arg)
91
{
92
        rtems_id tid;
93
        rtems_status_code sc;
94
 
95
        sc = rtems_task_create (rtems_build_name ('S', 'R', 'V', arg + 'A'),
96
                100,
97
                RTEMS_MINIMUM_STACK_SIZE,
98
                RTEMS_PREEMPT|RTEMS_NO_TIMESLICE|RTEMS_NO_ASR|RTEMS_INTERRUPT_LEVEL(0),
99
                RTEMS_NO_FLOATING_POINT|RTEMS_LOCAL,
100
                &tid);
101
        if (sc != RTEMS_SUCCESSFUL) {
102
                printf ("Can't create task: %s\n", rtems_status_text (sc));
103
                rtems_task_suspend (RTEMS_SELF);
104
        }
105
        sc = rtems_task_start (tid, subtask, arg);
106
        if (sc != RTEMS_SUCCESSFUL) {
107
                printf ("Can't start task: %s\n", rtems_status_text (sc));
108
                rtems_task_suspend (RTEMS_SELF);
109
        }
110
}
111
 
112
rtems_task
113
Init (rtems_task_argument ignored)
114
{
115
 
116
        puts ("*** START OF TEST SP28 ***" );
117
        puts ("Task variables test begins.  Any output between\n");
118
        puts ("this line and the `Task variables test complete' line indicates an error.\n");
119
        starttask (1);
120
        starttask (2);
121
        starttask (3);
122
        rtems_task_suspend (RTEMS_SELF);
123
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.