summaryrefslogtreecommitdiffstats
path: root/cpukit/score/include/rtems/score/mrspimpl.h
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-05-05 13:05:54 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2015-05-19 12:00:47 +0200
commit900d337f960cb7cc53f5c93c29a503e5ced2c31f (patch)
tree1d1f49724e5cfcef1974d5dc4251486b0fddd2ef /cpukit/score/include/rtems/score/mrspimpl.h
parentscore: Fine grained locking for mutexes (diff)
downloadrtems-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/mrspimpl.h')
-rw-r--r--cpukit/score/include/rtems/score/mrspimpl.h36
1 files changed, 20 insertions, 16 deletions
diff --git a/cpukit/score/include/rtems/score/mrspimpl.h b/cpukit/score/include/rtems/score/mrspimpl.h
index 07f78ce7e9..05aee42a22 100644
--- a/cpukit/score/include/rtems/score/mrspimpl.h
+++ b/cpukit/score/include/rtems/score/mrspimpl.h
@@ -36,13 +36,18 @@ extern "C" {
* @{
*/
-RTEMS_INLINE_ROUTINE void _MRSP_Elevate_priority(
- MRSP_Control *mrsp,
- Thread_Control *new_owner,
- Priority_Control ceiling_priority
+RTEMS_INLINE_ROUTINE bool _MRSP_Restore_priority_filter(
+ Thread_Control *thread,
+ Priority_Control *new_priority,
+ void *arg
)
{
- _Thread_Change_priority( new_owner, ceiling_priority, false );
+ *new_priority = _Thread_Priority_highest(
+ thread->real_priority,
+ *new_priority
+ );
+
+ return *new_priority != thread->current_priority;
}
RTEMS_INLINE_ROUTINE void _MRSP_Restore_priority(
@@ -55,13 +60,13 @@ RTEMS_INLINE_ROUTINE void _MRSP_Restore_priority(
* or priority inheritance semaphores.
*/
if ( thread->resource_count == 0 ) {
- Priority_Control new_priority = _Scheduler_Highest_priority_of_two(
- _Scheduler_Get( thread ),
+ _Thread_Change_priority(
+ thread,
initial_priority,
- thread->real_priority
+ NULL,
+ _MRSP_Restore_priority_filter,
+ true
);
-
- _Thread_Change_priority( thread, new_priority, true );
}
}
@@ -75,7 +80,7 @@ RTEMS_INLINE_ROUTINE void _MRSP_Claim_ownership(
_Resource_Node_add_resource( &new_owner->Resource_node, &mrsp->Resource );
_Resource_Set_owner( &mrsp->Resource, &new_owner->Resource_node );
mrsp->initial_priority_of_owner = initial_priority;
- _MRSP_Elevate_priority( mrsp, new_owner, ceiling_priority );
+ _Thread_Raise_priority( new_owner, ceiling_priority );
_Scheduler_Thread_change_help_state( new_owner, SCHEDULER_HELP_ACTIVE_OWNER );
}
@@ -177,7 +182,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Wait_for_ownership(
_Scheduler_Thread_change_help_state( executing, SCHEDULER_HELP_ACTIVE_RIVAL );
rival.status = MRSP_WAIT_FOR_OWNERSHIP;
- _MRSP_Elevate_priority( mrsp, executing, ceiling_priority );
+ _Thread_Raise_priority( executing, ceiling_priority );
_ISR_Disable( level );
@@ -235,10 +240,9 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Obtain(
Priority_Control initial_priority = executing->current_priority;
Priority_Control ceiling_priority =
_MRSP_Get_ceiling_priority( mrsp, scheduler_index );
- bool priority_ok = !_Scheduler_Is_priority_higher_than(
- scheduler,
- initial_priority,
- ceiling_priority
+ bool priority_ok = !_Thread_Priority_less_than(
+ ceiling_priority,
+ initial_priority
);
Resource_Node *owner;