summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-08-30 18:12:13 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-09-01 21:23:16 +0200
commit25b0fddad9b3dad27eca0228fb4d7ba45ec459df (patch)
tree77e7a2c7eb25e9d73730b741d18144be3a81bcac /cpukit
parentscore: Remove _Thread_queue_Unblock_critical() (diff)
downloadrtems-25b0fddad9b3dad27eca0228fb4d7ba45ec459df.tar.bz2
score: Update priority only if necessary
In _Thread_queue_Flush_critical(), update the priority of the thread queue owner only if necessary. The scheduler update priority operation could be expensive.
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/include/rtems/score/threadqimpl.h4
-rw-r--r--cpukit/score/src/threadchangepriority.c2
-rw-r--r--cpukit/score/src/threadqflush.c22
3 files changed, 16 insertions, 12 deletions
diff --git a/cpukit/include/rtems/score/threadqimpl.h b/cpukit/include/rtems/score/threadqimpl.h
index f42c67cc47..33cdb3058d 100644
--- a/cpukit/include/rtems/score/threadqimpl.h
+++ b/cpukit/include/rtems/score/threadqimpl.h
@@ -366,8 +366,8 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Context_clear_priority_updates(
*
* @return The priority update count of @a queue_context.
*/
-RTEMS_INLINE_ROUTINE size_t _Thread_queue_Context_save_priority_updates(
- Thread_queue_Context *queue_context
+RTEMS_INLINE_ROUTINE size_t _Thread_queue_Context_get_priority_updates(
+ const Thread_queue_Context *queue_context
)
{
return queue_context->Priority.update_count;
diff --git a/cpukit/score/src/threadchangepriority.c b/cpukit/score/src/threadchangepriority.c
index ac2e9a6d0c..613d0cd7af 100644
--- a/cpukit/score/src/threadchangepriority.c
+++ b/cpukit/score/src/threadchangepriority.c
@@ -212,7 +212,7 @@ void _Thread_Priority_perform_actions(
*/
the_thread = start_of_path;
- update_count = _Thread_queue_Context_save_priority_updates( queue_context );
+ update_count = _Thread_queue_Context_get_priority_updates( queue_context );
while ( true ) {
Thread_queue_Queue *queue;
diff --git a/cpukit/score/src/threadqflush.c b/cpukit/score/src/threadqflush.c
index 357e3d696e..42b35a499b 100644
--- a/cpukit/score/src/threadqflush.c
+++ b/cpukit/score/src/threadqflush.c
@@ -71,15 +71,15 @@ size_t _Thread_queue_Flush_critical(
Thread_queue_Context *queue_context
)
{
- size_t flushed;
- Chain_Control unblock;
- Thread_Control *owner;
- Chain_Node *node;
- Chain_Node *tail;
+ size_t flushed;
+ size_t priority_updates;
+ Chain_Control unblock;
+ Chain_Node *node;
+ Chain_Node *tail;
flushed = 0;
+ priority_updates = 0;
_Chain_Initialize_empty( &unblock );
- owner = queue->owner;
while ( true ) {
Thread_queue_Heads *heads;
@@ -99,8 +99,7 @@ size_t _Thread_queue_Flush_critical(
/*
* We do not have enough space in the queue context to collect all priority
- * updates, so clear it each time. We unconditionally do the priority
- * update for the owner later if it exists.
+ * updates, so clear it each time and accumulate the priority updates.
*/
_Thread_queue_Context_clear_priority_updates( queue_context );
@@ -120,6 +119,8 @@ size_t _Thread_queue_Flush_critical(
);
}
+ priority_updates +=
+ _Thread_queue_Context_get_priority_updates( queue_context );
++flushed;
}
@@ -145,9 +146,12 @@ size_t _Thread_queue_Flush_critical(
node = next;
} while ( node != tail );
- if ( owner != NULL ) {
+ if ( priority_updates != 0 ) {
+ Thread_Control *owner;
ISR_lock_Context lock_context;
+ owner = queue->owner;
+ _Assert( owner != NULL );
_Thread_State_acquire( owner, &lock_context );
_Scheduler_Update_priority( owner );
_Thread_State_release( owner, &lock_context );