source: rtems/testsuites/sptests/sp46/init.c @ 99de42c

5
Last change on this file since 99de42c was 51b3cbca, checked in by Sebastian Huber <sebastian.huber@…>, on 10/04/18 at 13:23:25

tests: Use rtems_task_exit()

Update #3533.

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2009.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.org/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <tmacros.h>
15#include <rtems/cpuuse.h>
16
17const char rtems_test_name[] = "SP 46";
18
19rtems_task Periodic_Task(
20  rtems_task_argument argument
21);
22rtems_task Init(
23  rtems_task_argument argument
24);
25
26volatile int partial_loop = 0;
27
28rtems_task Periodic_Task(
29  rtems_task_argument argument
30)
31{
32  rtems_status_code  status;
33  rtems_name         period_name = rtems_build_name('P','E','R','a');
34  rtems_id           period_id;
35  rtems_interval     start;
36  rtems_interval     end;
37
38  puts( "Periodic - Create Period" );
39  /* create period */
40  status = rtems_rate_monotonic_create( period_name, &period_id );
41  directive_failed(status, "rate_monotonic_create");
42
43  partial_loop = 0;
44  while (1) {
45    /* start period with initial value */
46    status = rtems_rate_monotonic_period( period_id, 25 );
47    directive_failed(status, "rate_monotonic_period");
48    partial_loop = 0;
49
50    start = rtems_clock_get_ticks_since_boot();
51    end   = start + 5;
52    while ( end <= rtems_clock_get_ticks_since_boot() )
53      ;
54
55    partial_loop = 1;
56
57    rtems_task_wake_after( 5 );
58  }
59
60  puts( "Periodic - Deleting self" );
61  rtems_task_exit();
62}
63
64rtems_task Init(
65  rtems_task_argument argument
66)
67{
68  rtems_status_code  status;
69  rtems_id           task_id;
70
71  TEST_BEGIN();
72
73  /*
74   * Initialize Tasks
75   */
76
77
78  puts( "INIT - rtems_task_create - creating task 1" );
79  status = rtems_task_create(
80    rtems_build_name( 'T', 'A', '1', ' ' ),
81    1,
82    RTEMS_MINIMUM_STACK_SIZE,
83    RTEMS_DEFAULT_MODES,
84    RTEMS_DEFAULT_ATTRIBUTES,
85    &task_id
86  );
87  directive_failed( status, "rtems_task_create of TA1" );
88
89  puts( "INIT - rtems_task_start - TA1 " );
90  status = rtems_task_start( task_id, Periodic_Task, 0 );
91  directive_failed( status, "rtems_task_start of TA1" );
92
93  while ( !partial_loop ) {
94    status = rtems_task_wake_after( 2 );
95    directive_failed( status, "rtems_task_wake_after" );
96  }
97
98  rtems_cpu_usage_reset();
99
100  status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
101  directive_failed( status, "rtems_task_wake_after" );
102
103  /*
104   *  Exit test
105   */
106  TEST_END();
107  rtems_test_exit( 0 );
108}
109
110#define CONFIGURE_INIT
111/* configuration information */
112
113#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
114#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
115
116/* Two Tasks: Init and Timer Server */
117#define CONFIGURE_MAXIMUM_TASKS           2
118#define CONFIGURE_MAXIMUM_PERIODS         1
119#define CONFIGURE_INIT_TASK_STACK_SIZE    (RTEMS_MINIMUM_STACK_SIZE * 2)
120#define CONFIGURE_INIT_TASK_PRIORITY      10
121#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_DEFAULT_MODES
122
123#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
124
125#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
126
127#define CONFIGURE_EXTRA_TASK_STACKS       (1 * RTEMS_MINIMUM_STACK_SIZE)
128
129#include <rtems/confdefs.h>
130
Note: See TracBrowser for help on using the repository browser.