From 7fe6d60bf08df975c395515074c85976d9e4e3fb Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 15 Jul 2022 09:16:04 +0200 Subject: score: Remove PRIORITY_PSEUDO_ISR thread priority The uniprocessor schedulers had some special case logic for the PRIORITY_PSEUDO_ISR priority. Tasks with a priority of PRIORITY_PSEUDO_ISR were allowed to preempt a not preemptible task. If other higher priority task are made ready while a PRIORITY_PSEUDO_ISR task preempts a not preemptible task, then the other tasks run before the not preemptible task. This made the RTEMS_NO_PREEMPT mode ineffective. Remove the PRIORITY_PSEUDO_ISR special case logic. This simplifies the uniprocessor schedulers. Move the uniprocessor-specific scheduler support to the new header file . Close #2365. --- cpukit/score/src/mpci.c | 2 +- cpukit/score/src/scheduleredfblock.c | 4 ++-- cpukit/score/src/scheduleredfchangepriority.c | 5 ++++- cpukit/score/src/scheduleredfschedule.c | 5 ++++- cpukit/score/src/scheduleredfunblock.c | 20 +------------------- cpukit/score/src/scheduleredfyield.c | 2 +- cpukit/score/src/schedulerpriorityblock.c | 4 ++-- cpukit/score/src/schedulerprioritychangepriority.c | 5 ++++- cpukit/score/src/schedulerpriorityschedule.c | 5 ++++- cpukit/score/src/schedulerpriorityunblock.c | 16 +--------------- cpukit/score/src/schedulerpriorityyield.c | 5 ++++- cpukit/score/src/schedulersimpleblock.c | 4 ++-- cpukit/score/src/schedulersimplechangepriority.c | 5 ++++- cpukit/score/src/schedulersimpleschedule.c | 5 ++++- cpukit/score/src/schedulersimpleunblock.c | 20 +------------------- cpukit/score/src/schedulersimpleyield.c | 5 ++++- 16 files changed, 43 insertions(+), 69 deletions(-) (limited to 'cpukit/score') diff --git a/cpukit/score/src/mpci.c b/cpukit/score/src/mpci.c index 3b525a2066..458031c794 100644 --- a/cpukit/score/src/mpci.c +++ b/cpukit/score/src/mpci.c @@ -162,7 +162,7 @@ static void _MPCI_Create_server( void ) memset( &config, 0, sizeof( config ) ); config.scheduler = &_Scheduler_Table[ 0 ]; config.name = _Objects_Build_name( 'M', 'P', 'C', 'I' ); - config.priority = PRIORITY_PSEUDO_ISR; + config.priority = PRIORITY_MINIMUM; config.is_fp = CPU_ALL_TASKS_ARE_FP; config.stack_size = _Stack_Minimum() + _MPCI_Configuration.extra_mpci_receive_server_stack diff --git a/cpukit/score/src/scheduleredfblock.c b/cpukit/score/src/scheduleredfblock.c index 56f7c9c021..cb7ab91450 100644 --- a/cpukit/score/src/scheduleredfblock.c +++ b/cpukit/score/src/scheduleredfblock.c @@ -47,11 +47,11 @@ void _Scheduler_EDF_Block( Scheduler_Node *node ) { - _Scheduler_Generic_block( + _Scheduler_uniprocessor_Block( scheduler, the_thread, node, _Scheduler_EDF_Extract_body, - _Scheduler_EDF_Schedule_body + _Scheduler_EDF_Get_highest_ready ); } diff --git a/cpukit/score/src/scheduleredfchangepriority.c b/cpukit/score/src/scheduleredfchangepriority.c index 26ce1c348f..de17ca0fad 100644 --- a/cpukit/score/src/scheduleredfchangepriority.c +++ b/cpukit/score/src/scheduleredfchangepriority.c @@ -71,5 +71,8 @@ void _Scheduler_EDF_Update_priority( _Scheduler_EDF_Extract( context, the_node ); _Scheduler_EDF_Enqueue( context, the_node, insert_priority ); - _Scheduler_EDF_Schedule_body( scheduler, the_thread, false ); + _Scheduler_uniprocessor_Schedule( + scheduler, + _Scheduler_EDF_Get_highest_ready + ); } diff --git a/cpukit/score/src/scheduleredfschedule.c b/cpukit/score/src/scheduleredfschedule.c index d0acea7a30..40c5ab2c06 100644 --- a/cpukit/score/src/scheduleredfschedule.c +++ b/cpukit/score/src/scheduleredfschedule.c @@ -46,5 +46,8 @@ void _Scheduler_EDF_Schedule( Thread_Control *the_thread ) { - _Scheduler_EDF_Schedule_body( scheduler, the_thread, false ); + _Scheduler_uniprocessor_Schedule( + scheduler, + _Scheduler_EDF_Get_highest_ready + ); } diff --git a/cpukit/score/src/scheduleredfunblock.c b/cpukit/score/src/scheduleredfunblock.c index d6604686e3..4638eedf71 100644 --- a/cpukit/score/src/scheduleredfunblock.c +++ b/cpukit/score/src/scheduleredfunblock.c @@ -62,23 +62,5 @@ void _Scheduler_EDF_Unblock( the_node->priority = priority; _Scheduler_EDF_Enqueue( context, the_node, insert_priority ); - - /* - * If the thread that was unblocked is more important than the heir, - * then we have a new heir. This may or may not result in a - * context switch. - * - * Normal case: - * If the current thread is preemptible, then we need to do - * a context switch. - * Pseudo-ISR case: - * Even if the thread isn't preemptible, if the new heir is - * a pseudo-ISR system task, we need to do a context switch. - */ - if ( priority < _Thread_Get_priority( _Thread_Heir ) ) { - _Scheduler_Update_heir( - the_thread, - priority == ( SCHEDULER_EDF_PRIO_MSB | PRIORITY_PSEUDO_ISR ) - ); - } + _Scheduler_uniprocessor_Unblock( scheduler, the_thread, priority ); } diff --git a/cpukit/score/src/scheduleredfyield.c b/cpukit/score/src/scheduleredfyield.c index d83e1d9268..d38bea705a 100644 --- a/cpukit/score/src/scheduleredfyield.c +++ b/cpukit/score/src/scheduleredfyield.c @@ -55,5 +55,5 @@ void _Scheduler_EDF_Yield( _Scheduler_EDF_Extract( context, the_node ); _Scheduler_EDF_Enqueue( context, the_node, the_node->priority ); - _Scheduler_EDF_Schedule_body( scheduler, the_thread, true ); + _Scheduler_uniprocessor_Yield( scheduler, _Scheduler_EDF_Get_highest_ready ); } diff --git a/cpukit/score/src/schedulerpriorityblock.c b/cpukit/score/src/schedulerpriorityblock.c index 53636940dc..ffc7a3ad86 100644 --- a/cpukit/score/src/schedulerpriorityblock.c +++ b/cpukit/score/src/schedulerpriorityblock.c @@ -49,11 +49,11 @@ void _Scheduler_priority_Block( Scheduler_Node *node ) { - _Scheduler_Generic_block( + _Scheduler_uniprocessor_Block( scheduler, the_thread, node, _Scheduler_priority_Extract_body, - _Scheduler_priority_Schedule_body + _Scheduler_priority_Get_highest_ready ); } diff --git a/cpukit/score/src/schedulerprioritychangepriority.c b/cpukit/score/src/schedulerprioritychangepriority.c index 8a059763de..3588a2ce42 100644 --- a/cpukit/score/src/schedulerprioritychangepriority.c +++ b/cpukit/score/src/schedulerprioritychangepriority.c @@ -96,5 +96,8 @@ void _Scheduler_priority_Update_priority( ); } - _Scheduler_priority_Schedule_body( scheduler, the_thread, false ); + _Scheduler_uniprocessor_Schedule( + scheduler, + _Scheduler_priority_Get_highest_ready + ); } diff --git a/cpukit/score/src/schedulerpriorityschedule.c b/cpukit/score/src/schedulerpriorityschedule.c index bde749f9bc..bb7cf87399 100644 --- a/cpukit/score/src/schedulerpriorityschedule.c +++ b/cpukit/score/src/schedulerpriorityschedule.c @@ -46,5 +46,8 @@ void _Scheduler_priority_Schedule( Thread_Control *the_thread ) { - _Scheduler_priority_Schedule_body( scheduler, the_thread, false ); + _Scheduler_uniprocessor_Schedule( + scheduler, + _Scheduler_priority_Get_highest_ready + ); } diff --git a/cpukit/score/src/schedulerpriorityunblock.c b/cpukit/score/src/schedulerpriorityunblock.c index 190c126908..f9b6cabff7 100644 --- a/cpukit/score/src/schedulerpriorityunblock.c +++ b/cpukit/score/src/schedulerpriorityunblock.c @@ -76,19 +76,5 @@ void _Scheduler_priority_Unblock ( /* TODO: flash critical section? */ - /* - * If the thread that was unblocked is more important than the heir, - * then we have a new heir. This may or may not result in a - * context switch. - * - * Normal case: - * If the current thread is preemptible, then we need to do - * a context switch. - * Pseudo-ISR case: - * Even if the thread isn't preemptible, if the new heir is - * a pseudo-ISR system task, we need to do a context switch. - */ - if ( priority < _Thread_Get_priority( _Thread_Heir ) ) { - _Scheduler_Update_heir( the_thread, priority == PRIORITY_PSEUDO_ISR ); - } + _Scheduler_uniprocessor_Unblock( scheduler, the_thread, priority ); } diff --git a/cpukit/score/src/schedulerpriorityyield.c b/cpukit/score/src/schedulerpriorityyield.c index 77fcecc418..adb443df94 100644 --- a/cpukit/score/src/schedulerpriorityyield.c +++ b/cpukit/score/src/schedulerpriorityyield.c @@ -59,5 +59,8 @@ void _Scheduler_priority_Yield( _Chain_Append_unprotected( ready_chain, &the_thread->Object.Node ); } - _Scheduler_priority_Schedule_body( scheduler, the_thread, true ); + _Scheduler_uniprocessor_Yield( + scheduler, + _Scheduler_priority_Get_highest_ready + ); } diff --git a/cpukit/score/src/schedulersimpleblock.c b/cpukit/score/src/schedulersimpleblock.c index a8229d409f..dfd18df3a2 100644 --- a/cpukit/score/src/schedulersimpleblock.c +++ b/cpukit/score/src/schedulersimpleblock.c @@ -47,11 +47,11 @@ void _Scheduler_simple_Block( Scheduler_Node *node ) { - _Scheduler_Generic_block( + _Scheduler_uniprocessor_Block( scheduler, the_thread, node, _Scheduler_simple_Extract, - _Scheduler_simple_Schedule_body + _Scheduler_simple_Get_highest_ready ); } diff --git a/cpukit/score/src/schedulersimplechangepriority.c b/cpukit/score/src/schedulersimplechangepriority.c index b4711dfd01..5c53c96fb3 100644 --- a/cpukit/score/src/schedulersimplechangepriority.c +++ b/cpukit/score/src/schedulersimplechangepriority.c @@ -60,5 +60,8 @@ void _Scheduler_simple_Update_priority( _Scheduler_simple_Extract( scheduler, the_thread, node ); _Scheduler_simple_Insert( &context->Ready, the_thread, new_priority ); - _Scheduler_simple_Schedule_body( scheduler, the_thread, false ); + _Scheduler_uniprocessor_Schedule( + scheduler, + _Scheduler_simple_Get_highest_ready + ); } diff --git a/cpukit/score/src/schedulersimpleschedule.c b/cpukit/score/src/schedulersimpleschedule.c index 4108fdaee8..83a3fed7fe 100644 --- a/cpukit/score/src/schedulersimpleschedule.c +++ b/cpukit/score/src/schedulersimpleschedule.c @@ -46,5 +46,8 @@ void _Scheduler_simple_Schedule( Thread_Control *the_thread ) { - _Scheduler_simple_Schedule_body( scheduler, the_thread, false ); + _Scheduler_uniprocessor_Schedule( + scheduler, + _Scheduler_simple_Get_highest_ready + ); } diff --git a/cpukit/score/src/schedulersimpleunblock.c b/cpukit/score/src/schedulersimpleunblock.c index 7791503d7a..436f20ac38 100644 --- a/cpukit/score/src/schedulersimpleunblock.c +++ b/cpukit/score/src/schedulersimpleunblock.c @@ -58,23 +58,5 @@ void _Scheduler_simple_Unblock( priority = _Thread_Get_priority( the_thread ); insert_priority = SCHEDULER_PRIORITY_APPEND( priority ); _Scheduler_simple_Insert( &context->Ready, the_thread, insert_priority ); - - /* - * If the thread that was unblocked is more important than the heir, - * then we have a new heir. This may or may not result in a - * context switch. - * - * Normal case: - * If the current thread is preemptible, then we need to do - * a context switch. - * Pseudo-ISR case: - * Even if the thread isn't preemptible, if the new heir is - * a pseudo-ISR system task, we need to do a context switch. - */ - if ( priority < _Thread_Get_priority( _Thread_Heir ) ) { - _Scheduler_Update_heir( - the_thread, - priority == PRIORITY_PSEUDO_ISR - ); - } + _Scheduler_uniprocessor_Unblock( scheduler, the_thread, priority ); } diff --git a/cpukit/score/src/schedulersimpleyield.c b/cpukit/score/src/schedulersimpleyield.c index c25cceb8a7..ed8dd5b4cc 100644 --- a/cpukit/score/src/schedulersimpleyield.c +++ b/cpukit/score/src/schedulersimpleyield.c @@ -58,5 +58,8 @@ void _Scheduler_simple_Yield( insert_priority = (unsigned int) _Thread_Get_priority( the_thread ); insert_priority = SCHEDULER_PRIORITY_APPEND( insert_priority ); _Scheduler_simple_Insert( &context->Ready, the_thread, insert_priority ); - _Scheduler_simple_Schedule_body( scheduler, the_thread, false ); + _Scheduler_uniprocessor_Yield( + scheduler, + _Scheduler_simple_Get_highest_ready + ); } -- cgit v1.2.3