diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-05-05 13:05:54 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-05-19 12:00:47 +0200 |
commit | 900d337f960cb7cc53f5c93c29a503e5ced2c31f (patch) | |
tree | 1d1f49724e5cfcef1974d5dc4251486b0fddd2ef /cpukit/score/include/rtems/score/thread.h | |
parent | score: Fine grained locking for mutexes (diff) | |
download | rtems-900d337f960cb7cc53f5c93c29a503e5ced2c31f.tar.bz2 |
score: Rework _Thread_Change_priority()
Move the writes to Thread_Control::current_priority and
Thread_Control::real_priority into _Thread_Change_priority() under the
protection of the thread lock. Add a filter function to
_Thread_Change_priority() to enable specialized variants.
Avoid race conditions during a thread priority restore with the new
Thread_Control::priority_restore_hint for an important average case
optimizations used by priority inheritance mutexes.
Update #2273.
Diffstat (limited to 'cpukit/score/include/rtems/score/thread.h')
-rw-r--r-- | cpukit/score/include/rtems/score/thread.h | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h index b6662e49af..39fcb1707f 100644 --- a/cpukit/score/include/rtems/score/thread.h +++ b/cpukit/score/include/rtems/score/thread.h @@ -366,9 +366,21 @@ typedef struct { Objects_Control Object; /** This field is the current execution state of this proxy. */ States_Control current_state; - /** This field is the current priority state of this proxy. */ + + /** + * @brief This field is the current priority state of this thread. + * + * Writes to this field are only allowed in _Thread_Initialize() or via + * _Thread_Change_priority(). + */ Priority_Control current_priority; - /** This field is the base priority of this proxy. */ + + /** + * @brief This field is the base priority of this thread. + * + * Writes to this field are only allowed in _Thread_Initialize() or via + * _Thread_Change_priority(). + */ Priority_Control real_priority; /** @@ -379,6 +391,17 @@ typedef struct { */ uint32_t priority_generation; + /** + * @brief Hints if a priority restore is necessary once the resource count + * changes from one to zero. + * + * This is an optimization to speed up the mutex surrender sequence in case + * no attempt to change the priority was made during the mutex ownership. On + * SMP configurations atomic fences must synchronize writes to + * Thread_Control::priority_restore_hint and Thread_Control::resource_count. + */ + bool priority_restore_hint; + /** This field is the number of mutexes currently held by this proxy. */ uint32_t resource_count; @@ -653,9 +676,21 @@ struct Thread_Control_struct { Objects_Control Object; /** This field is the current execution state of this thread. */ States_Control current_state; - /** This field is the current priority state of this thread. */ + + /** + * @brief This field is the current priority state of this thread. + * + * Writes to this field are only allowed in _Thread_Initialize() or via + * _Thread_Change_priority(). + */ Priority_Control current_priority; - /** This field is the base priority of this thread. */ + + /** + * @brief This field is the base priority of this thread. + * + * Writes to this field are only allowed in _Thread_Initialize() or via + * _Thread_Change_priority(). + */ Priority_Control real_priority; /** @@ -666,6 +701,17 @@ struct Thread_Control_struct { */ uint32_t priority_generation; + /** + * @brief Hints if a priority restore is necessary once the resource count + * changes from one to zero. + * + * This is an optimization to speed up the mutex surrender sequence in case + * no attempt to change the priority was made during the mutex ownership. On + * SMP configurations atomic fences must synchronize writes to + * Thread_Control::priority_restore_hint and Thread_Control::resource_count. + */ + bool priority_restore_hint; + /** This field is the number of mutexes currently held by this thread. */ uint32_t resource_count; /** This field is the blocking information for this thread. */ |