[7adf4941] | 1 | /* |
---|
[cf56b18a] | 2 | * Copyright (c) 2017, 2018 embedded brains GmbH. All rights reserved. |
---|
[7adf4941] | 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 | |
---|
| 24 | const char rtems_test_name[] = "SMPSCHEDEDF 1"; |
---|
| 25 | |
---|
| 26 | typedef struct { |
---|
| 27 | rtems_id task[2]; |
---|
| 28 | } test_context; |
---|
| 29 | |
---|
| 30 | static test_context test_instance; |
---|
| 31 | |
---|
[cf56b18a] | 32 | static void t(test_context *ctx, rtems_interval p, long nanoseconds) |
---|
[7adf4941] | 33 | { |
---|
| 34 | rtems_status_code sc; |
---|
| 35 | rtems_id period; |
---|
| 36 | rtems_name name; |
---|
| 37 | |
---|
| 38 | sc = rtems_object_get_classic_name(rtems_task_self(), &name); |
---|
| 39 | rtems_test_assert(sc == RTEMS_SUCCESSFUL); |
---|
| 40 | |
---|
| 41 | sc = rtems_rate_monotonic_create(name, &period); |
---|
| 42 | rtems_test_assert(sc == RTEMS_SUCCESSFUL); |
---|
| 43 | |
---|
| 44 | while (true) { |
---|
[cf56b18a] | 45 | rtems_test_busy_cpu_usage(0, nanoseconds); |
---|
[7adf4941] | 46 | |
---|
| 47 | sc = rtems_rate_monotonic_period(period, p); |
---|
| 48 | rtems_test_assert(sc == RTEMS_SUCCESSFUL); |
---|
| 49 | } |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | static void t1(rtems_task_argument arg) |
---|
| 53 | { |
---|
| 54 | test_context *ctx = (test_context *) arg; |
---|
| 55 | |
---|
[cf56b18a] | 56 | t(ctx, 50, 25000000); |
---|
[7adf4941] | 57 | } |
---|
| 58 | |
---|
| 59 | static void t2(rtems_task_argument arg) |
---|
| 60 | { |
---|
| 61 | test_context *ctx = (test_context *) arg; |
---|
| 62 | |
---|
[cf56b18a] | 63 | t(ctx, 75, 30000000); |
---|
[7adf4941] | 64 | } |
---|
| 65 | |
---|
| 66 | static void test(test_context *ctx) |
---|
| 67 | { |
---|
| 68 | rtems_status_code sc; |
---|
| 69 | |
---|
| 70 | sc = rtems_task_create( |
---|
| 71 | rtems_build_name('T', '1', ' ', ' '), |
---|
| 72 | 2, |
---|
| 73 | RTEMS_MINIMUM_STACK_SIZE, |
---|
| 74 | RTEMS_DEFAULT_MODES, |
---|
| 75 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 76 | &ctx->task[0] |
---|
| 77 | ); |
---|
| 78 | rtems_test_assert(sc == RTEMS_SUCCESSFUL); |
---|
| 79 | |
---|
| 80 | sc = rtems_task_create( |
---|
| 81 | rtems_build_name('T', '2', ' ', ' '), |
---|
| 82 | 2, |
---|
| 83 | RTEMS_MINIMUM_STACK_SIZE, |
---|
| 84 | RTEMS_DEFAULT_MODES, |
---|
| 85 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 86 | &ctx->task[1] |
---|
| 87 | ); |
---|
| 88 | rtems_test_assert(sc == RTEMS_SUCCESSFUL); |
---|
| 89 | |
---|
| 90 | sc = rtems_task_wake_after(1); |
---|
| 91 | rtems_test_assert(sc == RTEMS_SUCCESSFUL); |
---|
| 92 | |
---|
| 93 | sc = rtems_task_start(ctx->task[0], t1, (rtems_task_argument) ctx); |
---|
| 94 | rtems_test_assert(sc == RTEMS_SUCCESSFUL); |
---|
| 95 | |
---|
| 96 | sc = rtems_task_start(ctx->task[1], t2, (rtems_task_argument) ctx); |
---|
| 97 | rtems_test_assert(sc == RTEMS_SUCCESSFUL); |
---|
| 98 | |
---|
| 99 | rtems_cpu_usage_reset(); |
---|
| 100 | |
---|
| 101 | sc = rtems_task_wake_after(50 * 75); |
---|
| 102 | rtems_test_assert(sc == RTEMS_SUCCESSFUL); |
---|
| 103 | |
---|
| 104 | sc = rtems_task_suspend(ctx->task[0]); |
---|
| 105 | rtems_test_assert(sc == RTEMS_SUCCESSFUL); |
---|
| 106 | |
---|
| 107 | sc = rtems_task_suspend(ctx->task[1]); |
---|
| 108 | rtems_test_assert(sc == RTEMS_SUCCESSFUL); |
---|
| 109 | |
---|
[73d892d8] | 110 | rtems_cpu_usage_report_with_plugin(&rtems_test_printer); |
---|
| 111 | rtems_rate_monotonic_report_statistics_with_plugin(&rtems_test_printer); |
---|
[7adf4941] | 112 | } |
---|
| 113 | |
---|
| 114 | static void Init(rtems_task_argument arg) |
---|
| 115 | { |
---|
| 116 | test_context *ctx = &test_instance; |
---|
| 117 | |
---|
| 118 | TEST_BEGIN(); |
---|
| 119 | |
---|
| 120 | test(ctx); |
---|
| 121 | |
---|
| 122 | TEST_END(); |
---|
| 123 | rtems_test_exit(0); |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | #define CONFIGURE_MICROSECONDS_PER_TICK 1000 |
---|
| 127 | |
---|
| 128 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
[c4b8b147] | 129 | #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER |
---|
[7adf4941] | 130 | |
---|
| 131 | #define CONFIGURE_MAXIMUM_TASKS 3 |
---|
| 132 | #define CONFIGURE_MAXIMUM_PERIODS 2 |
---|
| 133 | |
---|
[34487537] | 134 | #define CONFIGURE_MAXIMUM_PROCESSORS 1 |
---|
| 135 | |
---|
[7adf4941] | 136 | #define CONFIGURE_SCHEDULER_EDF_SMP |
---|
| 137 | |
---|
| 138 | #include <rtems/scheduler.h> |
---|
| 139 | |
---|
[6fadb7af] | 140 | RTEMS_SCHEDULER_EDF_SMP(a, CONFIGURE_MAXIMUM_PROCESSORS); |
---|
[7adf4941] | 141 | |
---|
[6fadb7af] | 142 | #define CONFIGURE_SCHEDULER_TABLE_ENTRIES \ |
---|
| 143 | RTEMS_SCHEDULER_TABLE_EDF_SMP(a, rtems_build_name('E', 'D', 'F', ' ')) |
---|
[7adf4941] | 144 | |
---|
[6fadb7af] | 145 | #define CONFIGURE_SCHEDULER_ASSIGNMENTS \ |
---|
[7adf4941] | 146 | RTEMS_SCHEDULER_ASSIGN(0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY) |
---|
| 147 | |
---|
| 148 | #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION |
---|
| 149 | |
---|
| 150 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
| 151 | |
---|
[07e1780] | 152 | #define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT |
---|
| 153 | |
---|
[7adf4941] | 154 | #define CONFIGURE_INIT |
---|
| 155 | |
---|
| 156 | #include <rtems/confdefs.h> |
---|