summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-06-22 17:09:56 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-07-27 10:55:30 +0200
commitf4d1f307926b6319e5d3b325dbe424901285dec1 (patch)
tree13e802a1cf18f2f588b3c61c686b49d4eb5b80f3
parentscore: Fix for RTEMS_DEBUG (diff)
downloadrtems-f4d1f307926b6319e5d3b325dbe424901285dec1.tar.bz2
score: Split _Thread_Change_priority()
Update #2412. Update #2556. Update #2765.
-rw-r--r--cpukit/score/include/rtems/score/threadimpl.h10
-rw-r--r--cpukit/score/src/threadchangepriority.c61
2 files changed, 62 insertions, 9 deletions
diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h
index ec82b917e9..5323e2c85b 100644
--- a/cpukit/score/include/rtems/score/threadimpl.h
+++ b/cpukit/score/include/rtems/score/threadimpl.h
@@ -460,6 +460,16 @@ typedef bool ( *Thread_Change_priority_filter )(
void *arg
);
+Thread_Control *_Thread_Apply_priority(
+ Thread_Control *the_thread,
+ Priority_Control new_priority,
+ void *arg,
+ Thread_Change_priority_filter filter,
+ bool prepend_it
+);
+
+void _Thread_Update_priority( Thread_Control *the_thread );
+
/**
* @brief Changes the priority of a thread if allowed by the filter function.
*
diff --git a/cpukit/score/src/threadchangepriority.c b/cpukit/score/src/threadchangepriority.c
index 7b22371326..d895ee6dbe 100644
--- a/cpukit/score/src/threadchangepriority.c
+++ b/cpukit/score/src/threadchangepriority.c
@@ -22,7 +22,7 @@
#include <rtems/score/threadimpl.h>
#include <rtems/score/schedulerimpl.h>
-void _Thread_Change_priority(
+static Thread_Control *_Thread_Apply_priority_locked(
Thread_Control *the_thread,
Priority_Control new_priority,
void *arg,
@@ -30,11 +30,6 @@ void _Thread_Change_priority(
bool prepend_it
)
{
- ISR_lock_Context lock_context;
- ISR_lock_Control *lock;
-
- lock = _Thread_Lock_acquire( the_thread, &lock_context );
-
/*
* For simplicity set the priority restore hint unconditionally since this is
* an average case optimization. Otherwise complicated atomic operations
@@ -62,17 +57,65 @@ void _Thread_Change_priority(
new_priority,
the_thread->Wait.queue
);
+ } else {
+ the_thread = NULL;
+ }
- _Thread_Lock_release( lock, &lock_context );
+ return the_thread;
+}
+
+Thread_Control *_Thread_Apply_priority(
+ Thread_Control *the_thread,
+ Priority_Control new_priority,
+ void *arg,
+ Thread_Change_priority_filter filter,
+ bool prepend_it
+)
+{
+ ISR_lock_Context lock_context;
+ ISR_lock_Control *lock;
+
+ lock = _Thread_Lock_acquire( the_thread, &lock_context );
+ the_thread = _Thread_Apply_priority_locked(
+ the_thread,
+ new_priority,
+ arg,
+ filter,
+ prepend_it
+ );
+ _Thread_Lock_release( lock, &lock_context );
+ return the_thread;
+}
+
+void _Thread_Update_priority( Thread_Control *the_thread )
+{
+ if ( the_thread != NULL ) {
+ ISR_lock_Context lock_context;
_Thread_State_acquire( the_thread, &lock_context );
_Scheduler_Update_priority( the_thread );
_Thread_State_release( the_thread, &lock_context );
- } else {
- _Thread_Lock_release( lock, &lock_context );
}
}
+void _Thread_Change_priority(
+ Thread_Control *the_thread,
+ Priority_Control new_priority,
+ void *arg,
+ Thread_Change_priority_filter filter,
+ bool prepend_it
+)
+{
+ the_thread = _Thread_Apply_priority(
+ the_thread,
+ new_priority,
+ arg,
+ filter,
+ prepend_it
+ );
+ _Thread_Update_priority( the_thread );
+}
+
static bool _Thread_Raise_priority_filter(
Thread_Control *the_thread,
Priority_Control *new_priority,