diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-06-09 21:30:40 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-06-22 14:37:11 +0200 |
commit | 99fc1d1d1b44e70a0bed4c94a514bd3f3b5df64f (patch) | |
tree | 3d290aed9fb42872d1ec6457025eb66a7303dec5 /cpukit/score/src/scheduleredfreleasejob.c | |
parent | score: Modify release job scheduler operation (diff) | |
download | rtems-99fc1d1d1b44e70a0bed4c94a514bd3f3b5df64f.tar.bz2 |
score: Rework EDF scheduler
Use inline red-black tree insert. Do not use shifting priorities since
this is not supported by the thread queues. Due to the 32-bit
Priority_Control this currently limits the uptime to 49days with a 1ms
clock tick.
Update #2173.
Diffstat (limited to 'cpukit/score/src/scheduleredfreleasejob.c')
-rw-r--r-- | cpukit/score/src/scheduleredfreleasejob.c | 52 |
1 files changed, 34 insertions, 18 deletions
diff --git a/cpukit/score/src/scheduleredfreleasejob.c b/cpukit/score/src/scheduleredfreleasejob.c index b7c83a55ad..b35fb9d80e 100644 --- a/cpukit/score/src/scheduleredfreleasejob.c +++ b/cpukit/score/src/scheduleredfreleasejob.c @@ -18,29 +18,45 @@ #include "config.h" #endif -#include <rtems/score/scheduleredf.h> -#include <rtems/score/threadimpl.h> -#include <rtems/score/watchdogimpl.h> +#include <rtems/score/scheduleredfimpl.h> -void _Scheduler_EDF_Release_job( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - uint64_t deadline +static bool _Scheduler_EDF_Priority_filter( + Thread_Control *the_thread, + Priority_Control *new_priority_p, + void *arg ) { - Priority_Control new_priority; - Priority_Control unused; + Scheduler_EDF_Node *node; + Priority_Control current_priority; + Priority_Control new_priority; - (void) scheduler; + node = _Scheduler_EDF_Thread_get_node( the_thread ); - if (deadline) { - /* Initializing or shifting deadline. */ - new_priority = (uint32_t) deadline & ~SCHEDULER_EDF_PRIO_MSB; - } - else { - /* Switch back to background priority. */ - new_priority = the_thread->Start.initial_priority; + current_priority = the_thread->current_priority; + new_priority = *new_priority_p; + + if ( new_priority == 0 ) { + new_priority = node->background_priority; } - _Thread_Set_priority( the_thread, new_priority, &unused, true ); + node->current_priority = new_priority; + the_thread->real_priority = new_priority; + + return _Thread_Priority_less_than( current_priority, new_priority ) + || !_Thread_Owns_resources( the_thread ); +} + +void _Scheduler_EDF_Release_job( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + uint64_t deadline +) +{ + _Thread_Change_priority( + the_thread, + (Priority_Control) deadline, + NULL, + _Scheduler_EDF_Priority_filter, + true + ); } |