diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-09-01 18:13:54 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-09-01 18:13:54 +0000 |
commit | ac9d2ecc46ea40b6da0ccaeeabd16e8c19ff47e0 (patch) | |
tree | 4f87d546461e9cc7cfd18ccc187073161fb333b7 | |
parent | 2011-09-01 Sebastian Huber <sebastian.huber@embedded-brains.de> (diff) | |
download | rtems-ac9d2ecc46ea40b6da0ccaeeabd16e8c19ff47e0.tar.bz2 |
2011-09-01 Petr Benes <benesp16@fel.cvut.cz>
PR 1895/cpukit
* rtems/src/ratemoncancel.c, rtems/src/ratemondelete.c,
rtems/src/ratemonperiod.c, sapi/include/confdefs.h,
score/Makefile.am, score/include/rtems/score/scheduler.h,
score/include/rtems/score/schedulerpriority.h,
score/include/rtems/score/schedulersimple.h,
score/include/rtems/score/schedulersimplesmp.h,
score/inline/rtems/score/scheduler.inl,
score/inline/rtems/score/schedulerpriority.inl,
score/src/coremutexseize.c: Add priority_compare and release_job
hooks interfaces to scheduler interface.
* score/src/schedulerpriorityprioritycompare.c,
score/src/schedulerpriorityreleasejob.c: New files.
-rw-r--r-- | cpukit/ChangeLog | 16 | ||||
-rw-r--r-- | cpukit/rtems/src/ratemoncancel.c | 1 | ||||
-rw-r--r-- | cpukit/rtems/src/ratemondelete.c | 1 | ||||
-rw-r--r-- | cpukit/rtems/src/ratemonperiod.c | 7 | ||||
-rw-r--r-- | cpukit/sapi/include/confdefs.h | 3 | ||||
-rw-r--r-- | cpukit/score/Makefile.am | 2 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/scheduler.h | 24 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/schedulerpriority.h | 50 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/schedulersimple.h | 26 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/schedulersimplesmp.h | 27 | ||||
-rw-r--r-- | cpukit/score/inline/rtems/score/scheduler.inl | 26 | ||||
-rw-r--r-- | cpukit/score/inline/rtems/score/schedulerpriority.inl | 17 | ||||
-rw-r--r-- | cpukit/score/src/coremutexseize.c | 4 | ||||
-rw-r--r-- | cpukit/score/src/schedulerpriorityprioritycompare.c | 27 | ||||
-rw-r--r-- | cpukit/score/src/schedulerpriorityreleasejob.c | 27 |
15 files changed, 219 insertions, 39 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index 72fcd93bcc..2665f81dc4 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,19 @@ +2011-09-01 Petr Benes <benesp16@fel.cvut.cz> + + PR 1895/cpukit + * rtems/src/ratemoncancel.c, rtems/src/ratemondelete.c, + rtems/src/ratemonperiod.c, sapi/include/confdefs.h, + score/Makefile.am, score/include/rtems/score/scheduler.h, + score/include/rtems/score/schedulerpriority.h, + score/include/rtems/score/schedulersimple.h, + score/include/rtems/score/schedulersimplesmp.h, + score/inline/rtems/score/scheduler.inl, + score/inline/rtems/score/schedulerpriority.inl, + score/src/coremutexseize.c: Add priority_compare and release_job + hooks interfaces to scheduler interface. + * score/src/schedulerpriorityprioritycompare.c, + score/src/schedulerpriorityreleasejob.c: New files. + 2011-08-29 Joel Sherrill <joel.sherrilL@OARcorp.com> * rtems/include/rtems/rtems/tasks.h: Formatting. diff --git a/cpukit/rtems/src/ratemoncancel.c b/cpukit/rtems/src/ratemoncancel.c index 0b75d53fd7..ec6d450e85 100644 --- a/cpukit/rtems/src/ratemoncancel.c +++ b/cpukit/rtems/src/ratemoncancel.c @@ -53,6 +53,7 @@ rtems_status_code rtems_rate_monotonic_cancel( } (void) _Watchdog_Remove( &the_period->Timer ); the_period->state = RATE_MONOTONIC_INACTIVE; + _Scheduler_Release_job(the_period->owner, 0); _Thread_Enable_dispatch(); return RTEMS_SUCCESSFUL; diff --git a/cpukit/rtems/src/ratemondelete.c b/cpukit/rtems/src/ratemondelete.c index 7349e5ed51..1ce298a497 100644 --- a/cpukit/rtems/src/ratemondelete.c +++ b/cpukit/rtems/src/ratemondelete.c @@ -51,6 +51,7 @@ rtems_status_code rtems_rate_monotonic_delete( (void) _Watchdog_Remove( &the_period->Timer ); the_period->state = RATE_MONOTONIC_INACTIVE; _Rate_monotonic_Free( the_period ); + _Scheduler_Release_job(the_period->owner, 0); _Thread_Enable_dispatch(); return RTEMS_SUCCESSFUL; diff --git a/cpukit/rtems/src/ratemonperiod.c b/cpukit/rtems/src/ratemonperiod.c index 1c18344955..4af3f90b5b 100644 --- a/cpukit/rtems/src/ratemonperiod.c +++ b/cpukit/rtems/src/ratemonperiod.c @@ -143,6 +143,8 @@ void _Rate_monotonic_Initiate_statistics( _Timespec_Add_to( &the_period->cpu_usage_period_initiated, &ran ); } #endif + + _Scheduler_Release_job(the_period->owner, the_period->next_length); } void _Rate_monotonic_Update_statistics( @@ -282,6 +284,8 @@ rtems_status_code rtems_rate_monotonic_period( if ( the_period->state == RATE_MONOTONIC_INACTIVE ) { _ISR_Enable( level ); + the_period->next_length = length; + /* * Baseline statistics information for the beginning of a period. */ @@ -295,8 +299,6 @@ rtems_status_code rtems_rate_monotonic_period( NULL ); - the_period->next_length = length; - _Watchdog_Insert_ticks( &the_period->Timer, length ); _Thread_Enable_dispatch(); return RTEMS_SUCCESSFUL; @@ -353,6 +355,7 @@ rtems_status_code rtems_rate_monotonic_period( the_period->next_length = length; _Watchdog_Insert_ticks( &the_period->Timer, length ); + _Scheduler_Release_job(the_period->owner, the_period->next_length); _Thread_Enable_dispatch(); return RTEMS_TIMEOUT; } diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h index 6aa6406ac9..a342bab46d 100644 --- a/cpukit/sapi/include/confdefs.h +++ b/cpukit/sapi/include/confdefs.h @@ -661,6 +661,9 @@ rtems_fs_init_functions_t rtems_fs_init_helper = #if defined(CONFIGURE_SCHEDULER_USER) #define CONFIGURE_SCHEDULER_ENTRY_POINTS \ CONFIGURE_SCHEDULER_USER_ENTRY_POINTS + + #define CONFIGURE_SCHEDULER_MEMORY_FOR_SCHEDULER \ + CONFIGURE_SCHEDULER_USER_MEMORY_FOR_SCHEDULER #endif /* diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am index aac7fce29b..20d8ead7b9 100644 --- a/cpukit/score/Makefile.am +++ b/cpukit/score/Makefile.am @@ -203,6 +203,8 @@ libscore_a_SOURCES += src/schedulerpriority.c \ src/schedulerpriorityenqueuefirst.c \ src/schedulerpriorityextract.c \ src/schedulerpriorityfree.c \ + src/schedulerpriorityprioritycompare.c \ + src/schedulerpriorityreleasejob.c \ src/schedulerpriorityschedule.c \ src/schedulerpriorityunblock.c \ src/schedulerpriorityupdate.c \ diff --git a/cpukit/score/include/rtems/score/scheduler.h b/cpukit/score/include/rtems/score/scheduler.h index 26ccdc9a6a..f899391128 100644 --- a/cpukit/score/include/rtems/score/scheduler.h +++ b/cpukit/score/include/rtems/score/scheduler.h @@ -77,8 +77,18 @@ typedef struct { /** extract a thread from the ready set */ void ( *extract )(Thread_Control *); + /** + * Compares two priorities (returns >0 for higher priority, 0 for equal + * and <0 for lower priority). + */ + int ( *priority_compare )(Priority_Control, Priority_Control); + + /** This routine is called upon release of a new job. */ + void ( *release_job ) (Thread_Control *, uint32_t); + /** perform scheduler update actions required at each clock tick */ void ( *tick )(void); + } Scheduler_Operations; /** @@ -107,6 +117,20 @@ typedef struct { extern Scheduler_Control _Scheduler; /** + * Macro testing whether @a p1 has lower priority than @a p2 + * in the intuitive sense of priority. + */ +#define _Scheduler_Is_priority_lower_than( _p1, _p2 ) \ + (_Scheduler_Priority_compare(_p1,_p2) < 0) + +/** + * Macro testing whether @a p1 has higher priority than @a p2 + * in the intuitive sense of priority. + */ +#define _Scheduler_Is_priority_higher_than( _p1, _p2 ) \ + (_Scheduler_Priority_compare(_p1,_p2) > 0) + +/** * This routine initializes the scheduler to the policy chosen by the user * through confdefs, or to the priority scheduler with ready chains by * default. diff --git a/cpukit/score/include/rtems/score/schedulerpriority.h b/cpukit/score/include/rtems/score/schedulerpriority.h index 2f164b7635..eaea71bd17 100644 --- a/cpukit/score/include/rtems/score/schedulerpriority.h +++ b/cpukit/score/include/rtems/score/schedulerpriority.h @@ -38,18 +38,20 @@ extern "C" { */ #define SCHEDULER_PRIORITY_ENTRY_POINTS \ { \ - _Scheduler_priority_Initialize, /* initialize entry point */ \ - _Scheduler_priority_Schedule, /* schedule entry point */ \ - _Scheduler_priority_Yield, /* yield entry point */ \ - _Scheduler_priority_Block, /* block entry point */ \ - _Scheduler_priority_Unblock, /* unblock entry point */ \ - _Scheduler_priority_Allocate, /* allocate entry point */ \ - _Scheduler_priority_Free, /* free entry point */ \ - _Scheduler_priority_Update, /* update entry point */ \ - _Scheduler_priority_Enqueue, /* enqueue entry point */ \ - _Scheduler_priority_Enqueue_first, /* enqueue_first entry point */ \ - _Scheduler_priority_Extract, /* extract entry point */ \ - _Scheduler_priority_Tick /* tick entry point */ \ + _Scheduler_priority_Initialize, /* initialize entry point */ \ + _Scheduler_priority_Schedule, /* schedule entry point */ \ + _Scheduler_priority_Yield, /* yield entry point */ \ + _Scheduler_priority_Block, /* block entry point */ \ + _Scheduler_priority_Unblock, /* unblock entry point */ \ + _Scheduler_priority_Allocate, /* allocate entry point */ \ + _Scheduler_priority_Free, /* free entry point */ \ + _Scheduler_priority_Update, /* update entry point */ \ + _Scheduler_priority_Enqueue, /* enqueue entry point */ \ + _Scheduler_priority_Enqueue_first, /* enqueue_first entry point */ \ + _Scheduler_priority_Extract, /* extract entry point */ \ + _Scheduler_priority_Priority_compare, /* compares two priorities */ \ + _Scheduler_priority_Release_job, /* new period of task */ \ + _Scheduler_priority_Tick /* tick entry point */ \ } /** @@ -172,6 +174,30 @@ void _Scheduler_priority_Extract( ); /** + * @brief Scheduler priority Priority compare + * + * This routine compares two priorities. + */ +int _Scheduler_priority_Priority_compare( + Priority_Control p1, + Priority_Control p2 +); + +/** + * @brief Scheduler priority Release job + * + * This routine is called when a new job of task is released. + * + * @param[in] the_thread is the owner of the job. + * @param[in] deadline of the new job from now. If equal to 0, + * the job was cancelled or deleted. + */ +void _Scheduler_priority_Release_job ( + Thread_Control *the_thread, + uint32_t deadline +); + +/** * @brief Deterministic Priority Scheduler Tick Method * * This routine is invoked as part of processing each clock tick. diff --git a/cpukit/score/include/rtems/score/schedulersimple.h b/cpukit/score/include/rtems/score/schedulersimple.h index 902349adfb..5f8dbf3f17 100644 --- a/cpukit/score/include/rtems/score/schedulersimple.h +++ b/cpukit/score/include/rtems/score/schedulersimple.h @@ -35,18 +35,20 @@ extern "C" { */ #define SCHEDULER_SIMPLE_ENTRY_POINTS \ { \ - _Scheduler_simple_Initialize, /* initialize entry point */ \ - _Scheduler_simple_Schedule, /* schedule entry point */ \ - _Scheduler_simple_Yield, /* yield entry point */ \ - _Scheduler_simple_Block, /* block entry point */ \ - _Scheduler_simple_Unblock, /* unblock entry point */ \ - _Scheduler_simple_Allocate, /* allocate entry point */ \ - _Scheduler_simple_Free, /* free entry point */ \ - _Scheduler_simple_Update, /* update entry point */ \ - _Scheduler_simple_Enqueue, /* enqueue entry point */ \ - _Scheduler_simple_Enqueue_first, /* enqueue_first entry point */ \ - _Scheduler_simple_Extract, /* extract entry point */ \ - _Scheduler_priority_Tick /* tick entry point */ \ + _Scheduler_simple_Initialize, /* initialize entry point */ \ + _Scheduler_simple_Schedule, /* schedule entry point */ \ + _Scheduler_simple_Yield, /* yield entry point */ \ + _Scheduler_simple_Block, /* block entry point */ \ + _Scheduler_simple_Unblock, /* unblock entry point */ \ + _Scheduler_simple_Allocate, /* allocate entry point */ \ + _Scheduler_simple_Free, /* free entry point */ \ + _Scheduler_simple_Update, /* update entry point */ \ + _Scheduler_simple_Enqueue, /* enqueue entry point */ \ + _Scheduler_simple_Enqueue_first, /* enqueue_first entry point */ \ + _Scheduler_simple_Extract, /* extract entry point */ \ + _Scheduler_priority_Priority_compare, /* compares two priorities */ \ + _Scheduler_priority_Release_job, /* new period of task */ \ + _Scheduler_priority_Tick /* tick entry point */ \ } /** diff --git a/cpukit/score/include/rtems/score/schedulersimplesmp.h b/cpukit/score/include/rtems/score/schedulersimplesmp.h index ad6074a637..6672ac51a0 100644 --- a/cpukit/score/include/rtems/score/schedulersimplesmp.h +++ b/cpukit/score/include/rtems/score/schedulersimplesmp.h @@ -40,24 +40,27 @@ extern "C" { #include <rtems/score/scheduler.h> #include <rtems/score/schedulersimple.h> +#include <rtems/score/schedulerpriority.h> /** * Entry points for Scheduler Simple SMP */ #define SCHEDULER_SIMPLE_SMP_ENTRY_POINTS \ { \ - _Scheduler_simple_Initialize, /* initialize entry point */ \ - _Scheduler_simple_smp_Schedule, /* schedule entry point */ \ - _Scheduler_simple_Yield, /* yield entry point */ \ - _Scheduler_simple_smp_Block, /* block entry point */ \ - _Scheduler_simple_smp_Unblock, /* unblock entry point */ \ - _Scheduler_simple_Allocate, /* allocate entry point */ \ - _Scheduler_simple_Free, /* free entry point */ \ - _Scheduler_simple_Update, /* update entry point */ \ - _Scheduler_simple_Enqueue, /* enqueue entry point */ \ - _Scheduler_simple_Enqueue_first, /* enqueue_first entry point */ \ - _Scheduler_simple_Extract, /* extract entry point */ \ - _Scheduler_simple_smp_Tick /* tick entry point */ \ + _Scheduler_simple_Initialize, /* initialize entry point */ \ + _Scheduler_simple_smp_Schedule, /* schedule entry point */ \ + _Scheduler_simple_Yield, /* yield entry point */ \ + _Scheduler_simple_smp_Block, /* block entry point */ \ + _Scheduler_simple_smp_Unblock, /* unblock entry point */ \ + _Scheduler_simple_Allocate, /* allocate entry point */ \ + _Scheduler_simple_Free, /* free entry point */ \ + _Scheduler_simple_Update, /* update entry point */ \ + _Scheduler_simple_Enqueue, /* enqueue entry point */ \ + _Scheduler_simple_Enqueue_first, /* enqueue_first entry point */ \ + _Scheduler_simple_Extract, /* extract entry point */ \ + _Scheduler_priority_Priority_compare, /* compares two priorities */ \ + _Scheduler_priority_Release_job, /* new period of task */ \ + _Scheduler_simple_smp_Tick /* tick entry point */ \ } /** diff --git a/cpukit/score/inline/rtems/score/scheduler.inl b/cpukit/score/inline/rtems/score/scheduler.inl index cc0a79614a..0a60928565 100644 --- a/cpukit/score/inline/rtems/score/scheduler.inl +++ b/cpukit/score/inline/rtems/score/scheduler.inl @@ -159,6 +159,32 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Extract( _Scheduler.Operations.extract( the_thread ); } +/** + * @brief Scheduler Priority compare + * + * This routine compares two priorities. + */ +RTEMS_INLINE_ROUTINE int _Scheduler_Priority_compare( + Priority_Control p1, + Priority_Control p2 +) +{ + return _Scheduler.Operations.priority_compare(p1, p2); +} + +/** + * @brief Scheduler Release job + * + * This routine is called when a new period of task is issued. + */ +RTEMS_INLINE_ROUTINE void _Scheduler_Release_job( + Thread_Control *the_thread, + uint32_t length +) +{ + _Scheduler.Operations.release_job(the_thread, length); +} + /** @brief Scheduler Method Invoked at Each Clock Tick * * This method is invoked at each clock tick to allow the scheduler diff --git a/cpukit/score/inline/rtems/score/schedulerpriority.inl b/cpukit/score/inline/rtems/score/schedulerpriority.inl index ab5f117334..9b418fc7ae 100644 --- a/cpukit/score/inline/rtems/score/schedulerpriority.inl +++ b/cpukit/score/inline/rtems/score/schedulerpriority.inl @@ -185,6 +185,23 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Schedule_body(void) ); } +/** + * @brief Scheduler priority Priority compare body + * + * This routine implements priority comparison for priority-based + * scheduling. + * + * @return >0 for higher priority, 0 for equal and <0 for lower priority. + */ +RTEMS_INLINE_ROUTINE int _Scheduler_priority_Priority_compare_body( + Priority_Control p1, + Priority_Control p2 +) +{ + /* High priority in priority scheduler is represented by low numbers. */ + return ( p2 - p1 ); +} + /**@}*/ #endif diff --git a/cpukit/score/src/coremutexseize.c b/cpukit/score/src/coremutexseize.c index 78b7dcab2c..1ac60f934b 100644 --- a/cpukit/score/src/coremutexseize.c +++ b/cpukit/score/src/coremutexseize.c @@ -60,7 +60,9 @@ void _CORE_mutex_Seize_interrupt_blocking( executing = _Thread_Executing; if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) ) { - if ( the_mutex->holder->current_priority > executing->current_priority ) { + if ( _Scheduler_Is_priority_higher_than( + executing->current_priority, + the_mutex->holder->current_priority)) { _Thread_Change_priority( the_mutex->holder, executing->current_priority, diff --git a/cpukit/score/src/schedulerpriorityprioritycompare.c b/cpukit/score/src/schedulerpriorityprioritycompare.c new file mode 100644 index 0000000000..85edb80d19 --- /dev/null +++ b/cpukit/score/src/schedulerpriorityprioritycompare.c @@ -0,0 +1,27 @@ +/* + * COPYRIGHT (c) 2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems/system.h> +#include <rtems/config.h> +#include <rtems/score/chain.h> +#include <rtems/score/schedulerpriority.h> + +int _Scheduler_priority_Priority_compare( + Priority_Control p1, + Priority_Control p2 +) +{ + return _Scheduler_priority_Priority_compare_body( p1, p2 ); +} diff --git a/cpukit/score/src/schedulerpriorityreleasejob.c b/cpukit/score/src/schedulerpriorityreleasejob.c new file mode 100644 index 0000000000..2ef0cafb6c --- /dev/null +++ b/cpukit/score/src/schedulerpriorityreleasejob.c @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2011 Petr Benes. + * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems/system.h> +#include <rtems/config.h> +#include <rtems/score/scheduler.h> +#include <rtems/score/schedulerpriority.h> + +void _Scheduler_priority_Release_job( + Thread_Control *the_thread, + uint32_t deadline +) +{ + return; +} |