source: rtems/testsuites/sptests/sp28/init.c @ 8f71a36

4.104.114.84.95
Last change on this file since 8f71a36 was e8064503, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/01/04 at 15:16:30
  • sp01/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp02/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp03/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp04/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp05/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp06/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp07/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp08/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp09/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp11/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp12/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp13/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp14/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp15/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp16/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp17/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp19/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp20/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp21/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp22/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp23/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp24/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp25/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp26/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp27/init.c: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp28/init.c: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp29/init.c: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp30/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp31/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp32/init.c: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • spfatal/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • spsize/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • Property mode set to 100644
File size: 3.0 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_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 <rtems/confdefs.h>
21
22#include <bsp.h>
23#include <rtems/error.h>
24#include <stdio.h>
25
26volatile void *taskvar;
27volatile int nRunning;
28volatile int nDeleted;
29
30rtems_task
31subtask (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
89void
90starttask (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
112rtems_task
113Init (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}
Note: See TracBrowser for help on using the repository browser.