diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-08-30 18:12:13 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-09-01 21:23:16 +0200 |
commit | 25b0fddad9b3dad27eca0228fb4d7ba45ec459df (patch) | |
tree | 77e7a2c7eb25e9d73730b741d18144be3a81bcac /cpukit/score/src/threadqflush.c | |
parent | score: Remove _Thread_queue_Unblock_critical() (diff) | |
download | rtems-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 '')
-rw-r--r-- | cpukit/score/src/threadqflush.c | 22 |
1 files changed, 13 insertions, 9 deletions
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 ); |