source: rtems/testsuites/sptests/sp28/init.c @ f9078d1

4.104.114.84.95
Last change on this file since f9078d1 was f9078d1, checked in by Joel Sherrill <joel.sherrill@…>, on 11/12/99 at 13:22:31

Added comment block and removed include of deleted file.

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/*
2 *  $Id$
3 */
4
5#define TEST_INIT
6#include <tmacros.h>
7
8rtems_task Init(rtems_task_argument argument);
9
10#define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER
11#define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER
12#define CONFIGURE_MAXIMUM_USER_EXTENSIONS    2
13
14#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
15#define CONFIGURE_MICROSECONDS_PER_TICK       52429
16
17#define CONFIGURE_MICROSECONDS_INIT
18
19#include <confdefs.h>
20
21#include <bsp.h>
22#include <rtems/error.h>
23#include <stdio.h>
24
25volatile int taskvar;
26
27rtems_task
28subtask (rtems_task_argument arg)
29{
30        int localvar = arg;
31        int i;
32        rtems_status_code sc;
33
34        sc = rtems_task_variable_add (RTEMS_SELF, (void *) &taskvar);
35        if (sc != RTEMS_SUCCESSFUL) {
36                printf ("Can't add task variable: %s\n", rtems_status_text (sc));
37                rtems_task_suspend (RTEMS_SELF);
38        }
39        taskvar = localvar;
40        while (localvar < 1000) {
41                localvar++;
42                rtems_task_wake_after (0);
43                taskvar++;
44                rtems_task_wake_after (0);
45                if (taskvar != localvar) {
46                        printf ("Task:%d taskvar:%d localvar:%d\n", arg, taskvar, localvar);
47                        rtems_task_suspend (RTEMS_SELF);
48                }
49        }
50        sc = rtems_task_variable_delete (RTEMS_SELF, (void *) &taskvar);
51        if (sc != RTEMS_SUCCESSFUL) {
52                printf ("Can't delete task variable: %s\n", rtems_status_text (sc));
53                rtems_task_suspend (RTEMS_SELF);
54        }
55        for (i = 0 ; ; i++) {
56                taskvar = localvar = 100 * arg;
57                rtems_task_wake_after (0);
58                if (taskvar == localvar) {
59                        printf ("Task:%d taskvar:%d localvar:%d\n", arg, taskvar, localvar);
60                        rtems_task_suspend (RTEMS_SELF);
61                }
62                if ((arg == 3) && (i == 100)) {
63                        printf ("Task variables test succeeded.\n");
64                        exit (0);
65                }
66        }
67}
68
69void
70starttask (int arg)
71{
72        rtems_id tid;
73        rtems_status_code sc;
74
75        sc = rtems_task_create (rtems_build_name ('S', 'R', 'V', arg + 'A'),
76                100,
77                10000,
78                RTEMS_PREEMPT|RTEMS_NO_TIMESLICE|RTEMS_NO_ASR|RTEMS_INTERRUPT_LEVEL(0),
79                RTEMS_NO_FLOATING_POINT|RTEMS_LOCAL,
80                &tid);
81        if (sc != RTEMS_SUCCESSFUL) {
82                printf ("Can't create task: %s\n", rtems_status_text (sc));
83                rtems_task_suspend (RTEMS_SELF);
84        }
85        sc = rtems_task_start (tid, subtask, arg);
86        if (sc != RTEMS_SUCCESSFUL) {
87                printf ("Can't start task: %s\n", rtems_status_text (sc));
88                rtems_task_suspend (RTEMS_SELF);
89        }
90}
91
92rtems_task
93Init (rtems_task_argument ignored)
94{
95        starttask (1);
96        starttask (2);
97        starttask (3);
98        rtems_task_suspend (RTEMS_SELF);
99}
Note: See TracBrowser for help on using the repository browser.