psxtests/psx09: Change prio while at low prio

Update #5164.
This commit is contained in:
Sebastian Huber
2024-11-26 04:30:39 +01:00
committed by Chris Johns
parent 5eb938283d
commit 78e5e76572
2 changed files with 148 additions and 2 deletions

View File

@@ -112,6 +112,26 @@ void *POSIX_Init(
int ceiling_priority;
int high_priority;
int low_priority;
rtems_id scheduler_id;
rtems_task_priority rtems_priority;
rtems_status_code sc;
if (argument != NULL ) {
/* We end up here due to the rtems_task_restart() below */
ceiling_priority = sched_get_priority_max( SCHED_SPORADIC );
low_priority = ceiling_priority - 2;
rtems_test_assert( get_current_prio() == low_priority );
while ( get_current_prio() == low_priority ) {
/* Be busy until sched_ss_repl_period elapses */
}
rtems_test_assert( get_current_prio() == 2 );
TEST_END();
rtems_test_exit( 0 );
}
TEST_BEGIN();
@@ -248,8 +268,112 @@ void *POSIX_Init(
rtems_test_assert( !status );
rtems_test_assert( get_current_prio() == low_priority );
TEST_END();
rtems_test_exit( 0 );
status = pthread_mutex_destroy( &Mutex_id );
rtems_test_assert( status == 0 );
puts( "Init: Go into low priority and change scheduler parameters" );
while ( get_current_prio() == high_priority ) {
/* Be busy until sched_ss_init_budget elapses */
}
rtems_test_assert( get_current_prio() == low_priority );
schedparam.sched_priority = ceiling_priority;
status = pthread_setschedparam( pthread_self(), SCHED_SPORADIC, &schedparam );
rtems_test_assert( status == 0 );
rtems_test_assert( get_current_prio() == ceiling_priority );
puts( "Init: Go into low priority and set POSIX priority" );
schedparam.sched_priority = high_priority;
status = pthread_setschedparam( pthread_self(), SCHED_SPORADIC, &schedparam );
rtems_test_assert( status == 0 );
rtems_test_assert( get_current_prio() == high_priority );
while ( get_current_prio() == high_priority ) {
/* Be busy until sched_ss_init_budget elapses */
}
rtems_test_assert( get_current_prio() == low_priority );
status = pthread_setschedprio( pthread_self(), ceiling_priority );
rtems_test_assert( status == 0 );
rtems_test_assert( get_current_prio() == low_priority );
while ( get_current_prio() == low_priority ) {
/* Be busy until sched_ss_repl_period elapses */
}
rtems_test_assert( get_current_prio() == ceiling_priority );
puts( "Init: Go into low priority and set RTEMS priority" );
sc = rtems_task_get_scheduler( RTEMS_SELF, &scheduler_id );
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
sc = rtems_scheduler_map_priority_from_posix(
scheduler_id,
ceiling_priority,
&rtems_priority
);
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
schedparam.sched_priority = high_priority;
status = pthread_setschedparam( pthread_self(), SCHED_SPORADIC, &schedparam );
rtems_test_assert( status == 0 );
rtems_test_assert( get_current_prio() == high_priority );
while ( get_current_prio() == high_priority ) {
/* Be busy until sched_ss_init_budget elapses */
}
rtems_test_assert( get_current_prio() == low_priority );
sc = rtems_task_set_priority( RTEMS_SELF, rtems_priority, &rtems_priority );
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
rtems_test_assert( get_current_prio() == low_priority );
while ( get_current_prio() == low_priority ) {
/* Be busy until sched_ss_repl_period elapses */
}
rtems_test_assert( get_current_prio() == ceiling_priority );
puts( "Init: Go into low priority and set scheduler" );
sc = rtems_scheduler_ident_by_processor( 1, &scheduler_id );
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
schedparam.sched_priority = high_priority;
status = pthread_setschedparam( pthread_self(), SCHED_SPORADIC, &schedparam );
rtems_test_assert( status == 0 );
rtems_test_assert( get_current_prio() == high_priority );
while ( get_current_prio() == high_priority ) {
/* Be busy until sched_ss_init_budget elapses */
}
rtems_test_assert( get_current_prio() == low_priority );
sc = rtems_task_set_scheduler( RTEMS_SELF, scheduler_id, 1 );
rtems_test_assert( sc == RTEMS_RESOURCE_IN_USE );
rtems_test_assert( get_current_prio() == low_priority );
while ( get_current_prio() == low_priority ) {
/* Be busy until sched_ss_repl_period elapses */
}
rtems_test_assert( get_current_prio() == high_priority );
puts( "Init: Go into low priority and restart task" );
schedparam.sched_priority = high_priority;
status = pthread_setschedparam( pthread_self(), SCHED_SPORADIC, &schedparam );
rtems_test_assert( status == 0 );
rtems_test_assert( get_current_prio() == high_priority );
while ( get_current_prio() == high_priority ) {
/* Be busy until sched_ss_init_budget elapses */
}
rtems_test_assert( get_current_prio() == low_priority );
(void) rtems_task_restart( RTEMS_SELF, 1 );
return NULL; /* just so the compiler thinks we returned something */
}

View File

@@ -58,6 +58,28 @@ void *Task_2(
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#ifdef RTEMS_SMP
#define CONFIGURE_MAXIMUM_PROCESSORS 2
#define CONFIGURE_SCHEDULER_EDF_SMP
#include <rtems/scheduler.h>
RTEMS_SCHEDULER_EDF_SMP( a );
RTEMS_SCHEDULER_EDF_SMP( b );
#define CONFIGURE_SCHEDULER_TABLE_ENTRIES \
RTEMS_SCHEDULER_TABLE_EDF_SMP( a, rtems_build_name( 'M', 'A', 'I', 'N' ) ), \
RTEMS_SCHEDULER_TABLE_EDF_SMP( b, rtems_build_name( 'O', 'T', 'H', 'R' ) )
#define CONFIGURE_SCHEDULER_ASSIGNMENTS \
RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \
RTEMS_SCHEDULER_ASSIGN( 1, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL )
#endif /* RTEMS_SMP */
#include <rtems/confdefs.h>
/* global variables */