diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-11-09 16:21:37 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-11-20 08:36:49 +0100 |
commit | c597fb166e05d315ce5da29c0a43a09992772dad (patch) | |
tree | 627d3f248020e0a292fe7dcb2505cf4d90957ae7 /cpukit/score/src/schedulerstrongapa.c | |
parent | bsps/powerpc: Fix PPC_EXC_CONFIG_USE_FIXED_HANDLER (diff) | |
download | rtems-c597fb166e05d315ce5da29c0a43a09992772dad.tar.bz2 |
score: Optimize scheduler priority updates
Thread priority changes may append or prepend the thread to its priority
group on the scheduler ready queue. Previously, a separate priority
value and a prepend-it flag in the scheduler node were used to propagate
a priority change to the scheduler.
Now, use an append-it bit in the priority control and reduce the plain
priority value to 63 bits.
This change leads to a significant code size reduction (about 25%) of
the SMP schedulers. The negligible increase of the standard priority
scheduler is due to some additional shift operations
(SCHEDULER_PRIORITY_MAP() and SCHEDULER_PRIORITY_UNMAP()).
Before:
text filename
136 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleblock.o
464 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimplechangepriority.o
24 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimple.o
108 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleschedule.o
292 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleunblock.o
264 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleyield.o
text filename
280 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityblock.o
488 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerprioritychangepriority.o
200 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriority.o
164 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityschedule.o
328 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityunblock.o
200 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityyield.o
text filename
24112 arm-rtems5/c/imx7/cpukit/score/src/libscore_a-scheduleredfsmp.o
text filename
37204 sparc-rtems5/c/gr740/cpukit/score/src/libscore_a-scheduleredfsmp.o
text filename
42236 powerpc-rtems5/c/qoriq_e6500_32/cpukit/score/src/libscore_a-scheduleredfsmp.o
After:
text filename
136 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleblock.o
272 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimplechangepriority.o
24 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimple.o
108 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleschedule.o
292 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleunblock.o
264 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleyield.o
text filename
280 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityblock.o
488 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerprioritychangepriority.o
208 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriority.o
164 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityschedule.o
332 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityunblock.o
200 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityyield.o
text filename
18860 arm-rtems5/c/imx7/cpukit/score/src/libscore_a-scheduleredfsmp.o
text filename
28520 sparc-rtems5/c/gr740/cpukit/score/src/libscore_a-scheduleredfsmp.o
text filename
32664 powerpc-rtems5/c/qoriq_e6500_32/cpukit/score/src/libscore_a-scheduleredfsmp.o
Diffstat (limited to '')
-rw-r--r-- | cpukit/score/src/schedulerstrongapa.c | 176 |
1 files changed, 55 insertions, 121 deletions
diff --git a/cpukit/score/src/schedulerstrongapa.c b/cpukit/score/src/schedulerstrongapa.c index 57ffb61367..19d4ebe348 100644 --- a/cpukit/score/src/schedulerstrongapa.c +++ b/cpukit/score/src/schedulerstrongapa.c @@ -66,7 +66,7 @@ static void _Scheduler_strong_APA_Move_from_ready_to_scheduled( { Scheduler_strong_APA_Context *self; Scheduler_strong_APA_Node *node; - Priority_Control priority; + Priority_Control insert_priority; self = _Scheduler_strong_APA_Get_self( context ); node = _Scheduler_strong_APA_Node_downcast( ready_to_scheduled ); @@ -76,47 +76,41 @@ static void _Scheduler_strong_APA_Move_from_ready_to_scheduled( &node->Ready_queue, &self->Bit_map ); - priority = node->Base.priority; + insert_priority = _Scheduler_SMP_Node_priority( &node->Base.Base ); + insert_priority = SCHEDULER_PRIORITY_APPEND( insert_priority ); _Chain_Insert_ordered_unprotected( &self->Base.Scheduled, &node->Base.Base.Node.Chain, - &priority, - _Scheduler_SMP_Insert_priority_fifo_order + &insert_priority, + _Scheduler_SMP_Priority_less_equal ); } -static void _Scheduler_strong_APA_Insert_ready_lifo( +static void _Scheduler_strong_APA_Insert_ready( Scheduler_Context *context, - Scheduler_Node *the_thread -) -{ - Scheduler_strong_APA_Context *self = - _Scheduler_strong_APA_Get_self( context ); - Scheduler_strong_APA_Node *node = - _Scheduler_strong_APA_Node_downcast( the_thread ); - - _Scheduler_priority_Ready_queue_enqueue( - &node->Base.Base.Node.Chain, - &node->Ready_queue, - &self->Bit_map - ); -} - -static void _Scheduler_strong_APA_Insert_ready_fifo( - Scheduler_Context *context, - Scheduler_Node *the_thread + Scheduler_Node *node_base, + Priority_Control insert_priority ) { - Scheduler_strong_APA_Context *self = - _Scheduler_strong_APA_Get_self( context ); - Scheduler_strong_APA_Node *node = - _Scheduler_strong_APA_Node_downcast( the_thread ); + Scheduler_strong_APA_Context *self; + Scheduler_strong_APA_Node *node; - _Scheduler_priority_Ready_queue_enqueue_first( - &node->Base.Base.Node.Chain, - &node->Ready_queue, - &self->Bit_map - ); + self = _Scheduler_strong_APA_Get_self( context ); + node = _Scheduler_strong_APA_Node_downcast( node_base ); + + if ( SCHEDULER_PRIORITY_IS_APPEND( insert_priority ) ) { + _Scheduler_priority_Ready_queue_enqueue( + &node->Base.Base.Node.Chain, + &node->Ready_queue, + &self->Bit_map + ); + } else { + _Scheduler_priority_Ready_queue_enqueue_first( + &node->Base.Base.Node.Chain, + &node->Ready_queue, + &self->Bit_map + ); + } } static void _Scheduler_strong_APA_Extract_from_ready( @@ -150,7 +144,7 @@ static void _Scheduler_strong_APA_Do_update( _Scheduler_SMP_Node_update_priority( &node->Base, new_priority ); _Scheduler_priority_Ready_queue_update( &node->Ready_queue, - new_priority, + SCHEDULER_PRIORITY_UNMAP( new_priority ), &self->Bit_map, &self->Ready[ 0 ] ); @@ -198,7 +192,7 @@ void _Scheduler_strong_APA_Node_initialize( self = _Scheduler_strong_APA_Get_self( context ); _Scheduler_priority_Ready_queue_update( &the_node->Ready_queue, - priority, + SCHEDULER_PRIORITY_UNMAP( priority ), &self->Bit_map, &self->Ready[ 0 ] ); @@ -247,103 +241,45 @@ void _Scheduler_strong_APA_Block( ); } -static bool _Scheduler_strong_APA_Enqueue_ordered( - Scheduler_Context *context, - Scheduler_Node *node, - Chain_Node_order order, - Scheduler_SMP_Insert insert_ready, - Scheduler_SMP_Insert insert_scheduled +static bool _Scheduler_strong_APA_Enqueue( + Scheduler_Context *context, + Scheduler_Node *node, + Priority_Control insert_priority ) { - return _Scheduler_SMP_Enqueue_ordered( + return _Scheduler_SMP_Enqueue( context, node, - order, - insert_ready, - insert_scheduled, + insert_priority, + _Scheduler_SMP_Priority_less_equal, + _Scheduler_strong_APA_Insert_ready, + _Scheduler_SMP_Insert_scheduled, _Scheduler_strong_APA_Move_from_scheduled_to_ready, _Scheduler_SMP_Get_lowest_scheduled, _Scheduler_SMP_Allocate_processor_exact ); } -static bool _Scheduler_strong_APA_Enqueue_lifo( - Scheduler_Context *context, - Scheduler_Node *node -) -{ - return _Scheduler_strong_APA_Enqueue_ordered( - context, - node, - _Scheduler_SMP_Insert_priority_lifo_order, - _Scheduler_strong_APA_Insert_ready_lifo, - _Scheduler_SMP_Insert_scheduled_lifo - ); -} - -static bool _Scheduler_strong_APA_Enqueue_fifo( +static bool _Scheduler_strong_APA_Enqueue_scheduled( Scheduler_Context *context, - Scheduler_Node *node -) -{ - return _Scheduler_strong_APA_Enqueue_ordered( - context, - node, - _Scheduler_SMP_Insert_priority_fifo_order, - _Scheduler_strong_APA_Insert_ready_fifo, - _Scheduler_SMP_Insert_scheduled_fifo - ); -} - -static bool _Scheduler_strong_APA_Enqueue_scheduled_ordered( - Scheduler_Context *context, - Scheduler_Node *node, - Chain_Node_order order, - Scheduler_SMP_Insert insert_ready, - Scheduler_SMP_Insert insert_scheduled + Scheduler_Node *node, + Priority_Control insert_priority ) { - return _Scheduler_SMP_Enqueue_scheduled_ordered( + return _Scheduler_SMP_Enqueue_scheduled( context, node, - order, + insert_priority, + _Scheduler_SMP_Priority_less_equal, _Scheduler_strong_APA_Extract_from_ready, _Scheduler_strong_APA_Get_highest_ready, - insert_ready, - insert_scheduled, + _Scheduler_strong_APA_Insert_ready, + _Scheduler_SMP_Insert_scheduled, _Scheduler_strong_APA_Move_from_ready_to_scheduled, _Scheduler_SMP_Allocate_processor_exact ); } -static bool _Scheduler_strong_APA_Enqueue_scheduled_lifo( - Scheduler_Context *context, - Scheduler_Node *node -) -{ - return _Scheduler_strong_APA_Enqueue_scheduled_ordered( - context, - node, - _Scheduler_SMP_Insert_priority_lifo_order, - _Scheduler_strong_APA_Insert_ready_lifo, - _Scheduler_SMP_Insert_scheduled_lifo - ); -} - -static bool _Scheduler_strong_APA_Enqueue_scheduled_fifo( - Scheduler_Context *context, - Scheduler_Node *node -) -{ - return _Scheduler_strong_APA_Enqueue_scheduled_ordered( - context, - node, - _Scheduler_SMP_Insert_priority_fifo_order, - _Scheduler_strong_APA_Insert_ready_fifo, - _Scheduler_SMP_Insert_scheduled_fifo - ); -} - void _Scheduler_strong_APA_Unblock( const Scheduler_Control *scheduler, Thread_Control *the_thread, @@ -357,7 +293,7 @@ void _Scheduler_strong_APA_Unblock( the_thread, node, _Scheduler_strong_APA_Do_update, - _Scheduler_strong_APA_Enqueue_fifo + _Scheduler_strong_APA_Enqueue ); } @@ -371,9 +307,9 @@ static bool _Scheduler_strong_APA_Do_ask_for_help( context, the_thread, node, - _Scheduler_SMP_Insert_priority_lifo_order, - _Scheduler_strong_APA_Insert_ready_lifo, - _Scheduler_SMP_Insert_scheduled_lifo, + _Scheduler_SMP_Priority_less_equal, + _Scheduler_strong_APA_Insert_ready, + _Scheduler_SMP_Insert_scheduled, _Scheduler_strong_APA_Move_from_scheduled_to_ready, _Scheduler_SMP_Get_lowest_scheduled, _Scheduler_SMP_Allocate_processor_lazy @@ -394,10 +330,8 @@ void _Scheduler_strong_APA_Update_priority( node, _Scheduler_strong_APA_Extract_from_ready, _Scheduler_strong_APA_Do_update, - _Scheduler_strong_APA_Enqueue_fifo, - _Scheduler_strong_APA_Enqueue_lifo, - _Scheduler_strong_APA_Enqueue_scheduled_fifo, - _Scheduler_strong_APA_Enqueue_scheduled_lifo, + _Scheduler_strong_APA_Enqueue, + _Scheduler_strong_APA_Enqueue_scheduled, _Scheduler_strong_APA_Do_ask_for_help ); } @@ -461,7 +395,7 @@ void _Scheduler_strong_APA_Add_processor( context, idle, _Scheduler_strong_APA_Has_ready, - _Scheduler_strong_APA_Enqueue_scheduled_fifo, + _Scheduler_strong_APA_Enqueue_scheduled, _Scheduler_SMP_Do_nothing_register_idle ); } @@ -477,7 +411,7 @@ Thread_Control *_Scheduler_strong_APA_Remove_processor( context, cpu, _Scheduler_strong_APA_Extract_from_ready, - _Scheduler_strong_APA_Enqueue_fifo + _Scheduler_strong_APA_Enqueue ); } @@ -494,7 +428,7 @@ void _Scheduler_strong_APA_Yield( the_thread, node, _Scheduler_strong_APA_Extract_from_ready, - _Scheduler_strong_APA_Enqueue_fifo, - _Scheduler_strong_APA_Enqueue_scheduled_fifo + _Scheduler_strong_APA_Enqueue, + _Scheduler_strong_APA_Enqueue_scheduled ); } |