File indexing completed on 2025-05-11 08:24:43
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 #ifdef HAVE_CONFIG_H
0029 #include "config.h"
0030 #endif
0031
0032 #include <rtems.h>
0033 #include <rtems/cpuuse.h>
0034
0035 #include "tmacros.h"
0036
0037 const char rtems_test_name[] = "SMPSCHEDEDF 1";
0038
0039 typedef struct {
0040 rtems_id task[2];
0041 } test_context;
0042
0043 static test_context test_instance;
0044
0045 static void t(test_context *ctx, rtems_interval p, long nanoseconds)
0046 {
0047 rtems_status_code sc;
0048 rtems_id period;
0049 rtems_name name;
0050
0051 sc = rtems_object_get_classic_name(rtems_task_self(), &name);
0052 rtems_test_assert(sc == RTEMS_SUCCESSFUL);
0053
0054 sc = rtems_rate_monotonic_create(name, &period);
0055 rtems_test_assert(sc == RTEMS_SUCCESSFUL);
0056
0057 while (true) {
0058 rtems_test_busy_cpu_usage(0, nanoseconds);
0059
0060 sc = rtems_rate_monotonic_period(period, p);
0061 rtems_test_assert(sc == RTEMS_SUCCESSFUL);
0062 }
0063 }
0064
0065 static void t1(rtems_task_argument arg)
0066 {
0067 test_context *ctx = (test_context *) arg;
0068
0069 t(ctx, 50, 25000000);
0070 }
0071
0072 static void t2(rtems_task_argument arg)
0073 {
0074 test_context *ctx = (test_context *) arg;
0075
0076 t(ctx, 75, 30000000);
0077 }
0078
0079 static void test(test_context *ctx)
0080 {
0081 rtems_status_code sc;
0082
0083 sc = rtems_task_create(
0084 rtems_build_name('T', '1', ' ', ' '),
0085 2,
0086 RTEMS_MINIMUM_STACK_SIZE,
0087 RTEMS_DEFAULT_MODES,
0088 RTEMS_DEFAULT_ATTRIBUTES,
0089 &ctx->task[0]
0090 );
0091 rtems_test_assert(sc == RTEMS_SUCCESSFUL);
0092
0093 sc = rtems_task_create(
0094 rtems_build_name('T', '2', ' ', ' '),
0095 2,
0096 RTEMS_MINIMUM_STACK_SIZE,
0097 RTEMS_DEFAULT_MODES,
0098 RTEMS_DEFAULT_ATTRIBUTES,
0099 &ctx->task[1]
0100 );
0101 rtems_test_assert(sc == RTEMS_SUCCESSFUL);
0102
0103 sc = rtems_task_wake_after(1);
0104 rtems_test_assert(sc == RTEMS_SUCCESSFUL);
0105
0106 sc = rtems_task_start(ctx->task[0], t1, (rtems_task_argument) ctx);
0107 rtems_test_assert(sc == RTEMS_SUCCESSFUL);
0108
0109 sc = rtems_task_start(ctx->task[1], t2, (rtems_task_argument) ctx);
0110 rtems_test_assert(sc == RTEMS_SUCCESSFUL);
0111
0112 rtems_cpu_usage_reset();
0113
0114 sc = rtems_task_wake_after(50 * 75);
0115 rtems_test_assert(sc == RTEMS_SUCCESSFUL);
0116
0117 sc = rtems_task_suspend(ctx->task[0]);
0118 rtems_test_assert(sc == RTEMS_SUCCESSFUL);
0119
0120 sc = rtems_task_suspend(ctx->task[1]);
0121 rtems_test_assert(sc == RTEMS_SUCCESSFUL);
0122
0123 rtems_cpu_usage_report_with_plugin(&rtems_test_printer);
0124 rtems_rate_monotonic_report_statistics_with_plugin(&rtems_test_printer);
0125 }
0126
0127 static void Init(rtems_task_argument arg)
0128 {
0129 test_context *ctx = &test_instance;
0130
0131 TEST_BEGIN();
0132
0133 test(ctx);
0134
0135 TEST_END();
0136 rtems_test_exit(0);
0137 }
0138
0139 #define CONFIGURE_MICROSECONDS_PER_TICK 1000
0140
0141 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
0142 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0143
0144 #define CONFIGURE_MAXIMUM_TASKS 3
0145 #define CONFIGURE_MAXIMUM_PERIODS 2
0146
0147 #define CONFIGURE_MAXIMUM_PROCESSORS 1
0148
0149 #define CONFIGURE_SCHEDULER_EDF_SMP
0150
0151 #include <rtems/scheduler.h>
0152
0153 RTEMS_SCHEDULER_EDF_SMP(a);
0154
0155 #define CONFIGURE_SCHEDULER_TABLE_ENTRIES \
0156 RTEMS_SCHEDULER_TABLE_EDF_SMP(a, rtems_build_name('E', 'D', 'F', ' '))
0157
0158 #define CONFIGURE_SCHEDULER_ASSIGNMENTS \
0159 RTEMS_SCHEDULER_ASSIGN(0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY)
0160
0161 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
0162
0163 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0164
0165 #define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
0166
0167 #define CONFIGURE_INIT
0168
0169 #include <rtems/confdefs.h>