File indexing completed on 2025-05-11 08:24:48
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifdef HAVE_CONFIG_H
0010 #include "config.h"
0011 #endif
0012
0013 #include <rtems/cpuuse.h>
0014 #include <tmacros.h>
0015 #include <rtems/rtems/ratemonimpl.h>
0016 #include "test_support.h"
0017
0018 const char rtems_test_name[] = "SPRMSCHED 2";
0019
0020
0021 rtems_task Init( rtems_task_argument argument );
0022 static void modify_count( rtems_id id );
0023
0024 static void modify_count(
0025 rtems_id id
0026 )
0027 {
0028 Rate_monotonic_Control *the_period;
0029 ISR_lock_Context lock_context;
0030
0031 the_period = _Rate_monotonic_Get( id, &lock_context );
0032 _Rate_monotonic_Acquire_critical( the_period, &lock_context );
0033 the_period->postponed_jobs = UINT32_MAX;
0034 _Rate_monotonic_Release( the_period, &lock_context );
0035 }
0036
0037 rtems_task Init(
0038 rtems_task_argument argument
0039 )
0040 {
0041 rtems_id period_id;
0042 rtems_name period_name;
0043 rtems_rate_monotonic_period_status period_status;
0044 rtems_status_code status;
0045 int i;
0046
0047 period_name = rtems_build_name('P','E','R','1');
0048
0049 TEST_BEGIN();
0050
0051
0052 status = rtems_rate_monotonic_create(
0053 period_name,
0054 &period_id
0055 );
0056 directive_failed( status, "rate_monotonic_create" );
0057
0058
0059 puts( "Testing overflow condition" );
0060 rtems_test_spin_until_next_tick();
0061 status = rtems_rate_monotonic_period( period_id, 50 );
0062 directive_failed( status, "rate_monotonic_period above loop" );
0063
0064 puts( "Modify the count of postponed_job manually" );
0065 modify_count( period_id );
0066
0067
0068 status = rtems_rate_monotonic_get_status( period_id, &period_status );
0069 directive_failed( status, "rate_monotonic_get_status" );
0070 printf( "Init Postponed jobs = %"PRIu32", and expected %"PRIu32"\n", period_status.postponed_jobs_count, UINT32_MAX );
0071 rtems_test_assert( period_status.postponed_jobs_count == UINT32_MAX );
0072
0073 for ( i=1 ; i <= 2 ; i++ ) {
0074 status = rtems_task_wake_after( 100 );
0075 directive_failed( status, "rtems_task_wake_after(100)" );
0076 puts( "Task misses its deadline." );
0077
0078
0079 status = rtems_rate_monotonic_get_status( period_id, &period_status );
0080 directive_failed( status, "rate_monotonic_get_status" );
0081
0082
0083 printf( "Count = %"PRIu32", and expected %"PRIu32"\n", period_status.postponed_jobs_count, UINT32_MAX);
0084 rtems_test_assert( period_status.postponed_jobs_count == UINT32_MAX);
0085
0086 rtems_test_spin_until_next_tick();
0087 status = rtems_rate_monotonic_period( period_id, 50 );
0088 fatal_directive_status(
0089 status,
0090 RTEMS_TIMEOUT,
0091 "rtems_rate_monotonic_period 2-n"
0092 );
0093
0094
0095 }
0096
0097 TEST_END();
0098
0099 rtems_test_exit(0);
0100 }
0101
0102
0103
0104 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0105 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
0106
0107 #define CONFIGURE_MAXIMUM_TASKS 1
0108 #define CONFIGURE_MAXIMUM_PERIODS 1
0109
0110 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
0111
0112 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0113
0114
0115 #define CONFIGURE_INIT
0116
0117 #include <rtems/confdefs.h>
0118