source: rtems/testsuites/smptests/smpschededf01/init.c @ c4b8b147

5
Last change on this file since c4b8b147 was c4b8b147, checked in by Sebastian Huber <sebastian.huber@…>, on 11/03/17 at 07:35:38

tests: Use simple console driver

Update #3170.
Update #3199.

  • Property mode set to 100644
File size: 3.7 KB
Line 
1/*
2 * Copyright (c) 2017 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Dornierstr. 4
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#ifdef HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems.h>
20#include <rtems/cpuuse.h>
21
22#include "tmacros.h"
23
24const char rtems_test_name[] = "SMPSCHEDEDF 1";
25
26typedef struct {
27  uint_fast32_t one_tick_busy;
28  rtems_id task[2];
29} test_context;
30
31static test_context test_instance;
32
33static void t(test_context *ctx, rtems_interval p, uint_fast32_t c)
34{
35  rtems_status_code sc;
36  rtems_id period;
37  rtems_name name;
38  uint_fast32_t busy;
39
40  sc = rtems_object_get_classic_name(rtems_task_self(), &name);
41  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
42
43  sc = rtems_rate_monotonic_create(name, &period);
44  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
45
46  busy = (c - 1) * ctx->one_tick_busy + (4 * ctx->one_tick_busy) / 5;
47
48  while (true) {
49    rtems_test_busy(busy);
50
51    sc = rtems_rate_monotonic_period(period, p);
52    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
53  }
54}
55
56static void t1(rtems_task_argument arg)
57{
58  test_context *ctx = (test_context *) arg;
59
60  t(ctx, 50, 25);
61}
62
63static void t2(rtems_task_argument arg)
64{
65  test_context *ctx = (test_context *) arg;
66
67  t(ctx, 75, 30);
68}
69
70static void test(test_context *ctx)
71{
72  rtems_status_code sc;
73
74  ctx->one_tick_busy = rtems_test_get_one_tick_busy_count();
75
76  sc = rtems_task_create(
77    rtems_build_name('T', '1', ' ', ' '),
78    2,
79    RTEMS_MINIMUM_STACK_SIZE,
80    RTEMS_DEFAULT_MODES,
81    RTEMS_DEFAULT_ATTRIBUTES,
82    &ctx->task[0]
83  );
84  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
85
86  sc = rtems_task_create(
87    rtems_build_name('T', '2', ' ', ' '),
88    2,
89    RTEMS_MINIMUM_STACK_SIZE,
90    RTEMS_DEFAULT_MODES,
91    RTEMS_DEFAULT_ATTRIBUTES,
92    &ctx->task[1]
93  );
94  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
95
96  sc = rtems_task_wake_after(1);
97  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
98
99  sc = rtems_task_start(ctx->task[0], t1, (rtems_task_argument) ctx);
100  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
101
102  sc = rtems_task_start(ctx->task[1], t2, (rtems_task_argument) ctx);
103  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
104
105  rtems_cpu_usage_reset();
106
107  sc = rtems_task_wake_after(50 * 75);
108  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
109
110  sc = rtems_task_suspend(ctx->task[0]);
111  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
112
113  sc = rtems_task_suspend(ctx->task[1]);
114  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
115
116  rtems_cpu_usage_report_with_plugin(&rtems_test_printer);
117  rtems_rate_monotonic_report_statistics_with_plugin(&rtems_test_printer);
118}
119
120static void Init(rtems_task_argument arg)
121{
122  test_context *ctx = &test_instance;
123
124  TEST_BEGIN();
125
126  test(ctx);
127
128  TEST_END();
129  rtems_test_exit(0);
130}
131
132#define CONFIGURE_MICROSECONDS_PER_TICK 1000
133
134#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
135#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
136
137#define CONFIGURE_MAXIMUM_TASKS 3
138#define CONFIGURE_MAXIMUM_PERIODS 2
139
140#define CONFIGURE_MAXIMUM_PROCESSORS 1
141
142#define CONFIGURE_SCHEDULER_EDF_SMP
143
144#include <rtems/scheduler.h>
145
146RTEMS_SCHEDULER_CONTEXT_EDF_SMP(a, CONFIGURE_MAXIMUM_PROCESSORS);
147
148#define CONFIGURE_SCHEDULER_CONTROLS \
149  RTEMS_SCHEDULER_CONTROL_EDF_SMP(a, rtems_build_name('E', 'D', 'F', ' '))
150
151#define CONFIGURE_SMP_SCHEDULER_ASSIGNMENTS \
152  RTEMS_SCHEDULER_ASSIGN(0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY)
153
154#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
155
156#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
157
158#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
159
160#define CONFIGURE_INIT
161
162#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.