[rtems commit] score: Split _Thread_Change_priority()
Sebastian Huber
sebh at rtems.org
Wed Jul 27 08:56:10 UTC 2016
Module: rtems
Branch: master
Commit: f4d1f307926b6319e5d3b325dbe424901285dec1
Changeset: http://git.rtems.org/rtems/commit/?id=f4d1f307926b6319e5d3b325dbe424901285dec1
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Wed Jun 22 17:09:56 2016 +0200
score: Split _Thread_Change_priority()
Update #2412.
Update #2556.
Update #2765.
---
cpukit/score/include/rtems/score/threadimpl.h | 10 +++++
cpukit/score/src/threadchangepriority.c | 61 +++++++++++++++++++++++----
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 ec82b91..5323e2c 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 7b22371..d895ee6 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,
More information about the vc
mailing list