From c597fb166e05d315ce5da29c0a43a09992772dad Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 9 Nov 2017 16:21:37 +0100 Subject: 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 --- .../include/rtems/score/schedulersimpleimpl.h | 52 ++++------------------ 1 file changed, 9 insertions(+), 43 deletions(-) (limited to 'cpukit/score/include/rtems/score/schedulersimpleimpl.h') diff --git a/cpukit/score/include/rtems/score/schedulersimpleimpl.h b/cpukit/score/include/rtems/score/schedulersimpleimpl.h index ec74cdc586..3891839281 100644 --- a/cpukit/score/include/rtems/score/schedulersimpleimpl.h +++ b/cpukit/score/include/rtems/score/schedulersimpleimpl.h @@ -38,65 +38,31 @@ RTEMS_INLINE_ROUTINE Scheduler_simple_Context * return (Scheduler_simple_Context *) _Scheduler_Get_context( scheduler ); } -RTEMS_INLINE_ROUTINE bool _Scheduler_simple_Insert_priority_lifo_order( +RTEMS_INLINE_ROUTINE bool _Scheduler_simple_Priority_less_equal( const void *to_insert, const Chain_Node *next ) { - const Priority_Control *priority_to_insert; - const Thread_Control *thread_next; + const unsigned int *priority_to_insert; + const Thread_Control *thread_next; - priority_to_insert = (const Priority_Control *) to_insert; + priority_to_insert = (const unsigned int *) to_insert; thread_next = (const Thread_Control *) next; return *priority_to_insert <= _Thread_Get_priority( thread_next ); } -RTEMS_INLINE_ROUTINE bool _Scheduler_simple_Insert_priority_fifo_order( - const void *to_insert, - const Chain_Node *next -) -{ - const Priority_Control *priority_to_insert; - const Thread_Control *thread_next; - - priority_to_insert = (const Priority_Control *) to_insert; - thread_next = (const Thread_Control *) next; - - return *priority_to_insert < _Thread_Get_priority( thread_next ); -} - -RTEMS_INLINE_ROUTINE void _Scheduler_simple_Insert_priority_lifo( - Chain_Control *chain, - Thread_Control *to_insert -) -{ - Priority_Control priority_to_insert; - - priority_to_insert = _Thread_Get_priority( to_insert ); - - _Chain_Insert_ordered_unprotected( - chain, - &to_insert->Object.Node, - &priority_to_insert, - _Scheduler_simple_Insert_priority_lifo_order - ); -} - -RTEMS_INLINE_ROUTINE void _Scheduler_simple_Insert_priority_fifo( +RTEMS_INLINE_ROUTINE void _Scheduler_simple_Insert( Chain_Control *chain, - Thread_Control *to_insert + Thread_Control *to_insert, + unsigned int insert_priority ) { - Priority_Control priority_to_insert; - - priority_to_insert = _Thread_Get_priority( to_insert ); - _Chain_Insert_ordered_unprotected( chain, &to_insert->Object.Node, - &priority_to_insert, - _Scheduler_simple_Insert_priority_fifo_order + &insert_priority, + _Scheduler_simple_Priority_less_equal ); } -- cgit v1.2.3