diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-06-03 10:29:30 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-06-04 08:37:06 +0200 |
commit | 8e46738436b18d0f1a9424a95b678ab1596cb092 (patch) | |
tree | 252be226da9107952a87628fd4e5265df603c167 | |
parent | f6fc635943d85143529d7da6f5cdabf27a955d19 (diff) |
score: Replace _Scheduler_Allocate/Free()
Replace _Scheduler_Allocate() with _Scheduler_Node_initialize(). Remove
the return status and thus the node initialization must be always
successful.
Rename _Scheduler_Free() to _Scheduler_Node_destroy().
19 files changed, 99 insertions, 92 deletions
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am index 70760c57cd..feb757dfb1 100644 --- a/cpukit/score/Makefile.am +++ b/cpukit/score/Makefile.am @@ -204,7 +204,8 @@ libscore_a_SOURCES += src/log2table.c libscore_a_SOURCES += src/scheduler.c libscore_a_SOURCES += src/schedulergetaffinity.c libscore_a_SOURCES += src/schedulersetaffinity.c -libscore_a_SOURCES += src/schedulerdefaultallocatefree.c +libscore_a_SOURCES += src/schedulerdefaultnodedestroy.c +libscore_a_SOURCES += src/schedulerdefaultnodeinit.c libscore_a_SOURCES += src/schedulerdefaultreleasejob.c libscore_a_SOURCES += src/schedulerdefaultschedule.c libscore_a_SOURCES += src/schedulerdefaultstartidle.c @@ -231,7 +232,7 @@ libscore_a_SOURCES += src/schedulersimple.c \ ## SCHEDULEREDF_C_FILES libscore_a_SOURCES += src/scheduleredf.c \ - src/scheduleredfallocate.c \ + src/scheduleredfnodeinit.c \ src/scheduleredfblock.c \ src/scheduleredfchangepriority.c \ src/scheduleredfprioritycompare.c \ @@ -243,7 +244,7 @@ libscore_a_SOURCES += src/scheduleredf.c \ ## SCHEDULERCBS_C_FILES libscore_a_SOURCES += src/schedulercbs.c \ - src/schedulercbsallocate.c \ + src/schedulercbsnodeinit.c \ src/schedulercbsattachthread.c \ src/schedulercbscleanup.c \ src/schedulercbscreateserver.c \ diff --git a/cpukit/score/include/rtems/score/scheduler.h b/cpukit/score/include/rtems/score/scheduler.h index c4bd350859..7ca2133460 100644 --- a/cpukit/score/include/rtems/score/scheduler.h +++ b/cpukit/score/include/rtems/score/scheduler.h @@ -71,11 +71,11 @@ typedef struct { bool ); - /** @see _Scheduler_Allocate() */ - bool ( *allocate )( const Scheduler_Control *, Thread_Control * ); + /** @see _Scheduler_Node_initialize() */ + void ( *node_initialize )( const Scheduler_Control *, Thread_Control * ); - /** @see _Scheduler_Free() */ - void ( *free )( const Scheduler_Control *, Thread_Control * ); + /** @see _Scheduler_Node_destroy() */ + void ( *node_destroy )( const Scheduler_Control *, Thread_Control * ); /** @see _Scheduler_Update() */ void ( *update )( const Scheduler_Control *, Thread_Control * ); @@ -251,14 +251,12 @@ void _Scheduler_default_Schedule( ); /** - * @brief Returns true. + * @brief Does nothing. * * @param[in] scheduler Unused. * @param[in] the_thread Unused. - * - * @retval true Always. */ -bool _Scheduler_default_Allocate( +void _Scheduler_default_Node_initialize( const Scheduler_Control *scheduler, Thread_Control *the_thread ); @@ -269,7 +267,7 @@ bool _Scheduler_default_Allocate( * @param[in] scheduler Unused. * @param[in] the_thread Unused. */ -void _Scheduler_default_Free( +void _Scheduler_default_Node_destroy( const Scheduler_Control *scheduler, Thread_Control *the_thread ); diff --git a/cpukit/score/include/rtems/score/schedulercbs.h b/cpukit/score/include/rtems/score/schedulercbs.h index 46db8e5609..23e528da66 100644 --- a/cpukit/score/include/rtems/score/schedulercbs.h +++ b/cpukit/score/include/rtems/score/schedulercbs.h @@ -53,8 +53,8 @@ extern "C" { _Scheduler_EDF_Block, /* block entry point */ \ _Scheduler_CBS_Unblock, /* unblock entry point */ \ _Scheduler_EDF_Change_priority, /* change priority entry point */ \ - _Scheduler_CBS_Allocate, /* allocate entry point */ \ - _Scheduler_default_Free, /* free entry point */ \ + _Scheduler_CBS_Node_initialize, /* node initialize entry point */ \ + _Scheduler_default_Node_destroy, /* node destroy entry point */ \ _Scheduler_EDF_Update, /* update entry point */ \ _Scheduler_EDF_Priority_compare, /* compares two priorities */ \ _Scheduler_CBS_Release_job, /* new period of task */ \ @@ -335,14 +335,9 @@ void _Scheduler_CBS_Budget_callout( ); /** - * @brief Allocates CBS specific information of @a the_thread. - * - * This routine allocates CBS specific information of @a the_thread. - * - * @param[in] the_thread is the thread the scheduler is allocating - * management memory for. + * @brief Initializes a CBS specific scheduler node of @a the_thread. */ -bool _Scheduler_CBS_Allocate( +void _Scheduler_CBS_Node_initialize( const Scheduler_Control *scheduler, Thread_Control *the_thread ); diff --git a/cpukit/score/include/rtems/score/scheduleredf.h b/cpukit/score/include/rtems/score/scheduleredf.h index 301940c91d..a7ed88db39 100644 --- a/cpukit/score/include/rtems/score/scheduleredf.h +++ b/cpukit/score/include/rtems/score/scheduleredf.h @@ -46,8 +46,8 @@ extern "C" { _Scheduler_EDF_Block, /* block entry point */ \ _Scheduler_EDF_Unblock, /* unblock entry point */ \ _Scheduler_EDF_Change_priority, /* change priority entry point */ \ - _Scheduler_EDF_Allocate, /* allocate entry point */ \ - _Scheduler_default_Free, /* free entry point */ \ + _Scheduler_EDF_Node_initialize, /* node initialize entry point */ \ + _Scheduler_default_Node_destroy, /* node destroy entry point */ \ _Scheduler_EDF_Update, /* update entry point */ \ _Scheduler_EDF_Priority_compare, /* compares two priorities */ \ _Scheduler_EDF_Release_job, /* new period of task */ \ @@ -146,14 +146,9 @@ void _Scheduler_EDF_Schedule( ); /** - * @brief Allocates EDF specific information of @a the_thread. - * - * This routine allocates EDF specific information of @a the_thread. - * - * @param[in] the_thread is the thread the scheduler is allocating - * management memory for. + * @brief Initializes an EDF specific scheduler node of @a the_thread. */ -bool _Scheduler_EDF_Allocate( +void _Scheduler_EDF_Node_initialize( const Scheduler_Control *scheduler, Thread_Control *the_thread ); diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h b/cpukit/score/include/rtems/score/schedulerimpl.h index f1acf32d35..5e7c928686 100644 --- a/cpukit/score/include/rtems/score/schedulerimpl.h +++ b/cpukit/score/include/rtems/score/schedulerimpl.h @@ -173,29 +173,39 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Change_priority( } /** - * @brief Scheduler allocate. + * @brief Initializes a scheduler node. * - * This routine allocates @a the_thread->scheduler + * The scheduler node contains arbitrary data on function entry. The caller + * must ensure that _Scheduler_Node_destroy() will be called after a + * _Scheduler_Node_initialize() before the memory of the scheduler node is + * destroyed. + * + * @param[in] scheduler The scheduler instance. + * @param[in] the_thread The thread containing the scheduler node. */ -RTEMS_INLINE_ROUTINE bool _Scheduler_Allocate( +RTEMS_INLINE_ROUTINE void _Scheduler_Node_initialize( const Scheduler_Control *scheduler, Thread_Control *the_thread ) { - return ( *scheduler->Operations.allocate )( scheduler, the_thread ); + return ( *scheduler->Operations.node_initialize )( scheduler, the_thread ); } /** - * @brief Scheduler free. + * @brief Destroys a scheduler node. * - * This routine frees @a the_thread->scheduler + * The caller must ensure that _Scheduler_Node_destroy() will be called only + * after a corresponding _Scheduler_Node_initialize(). + * + * @param[in] scheduler The scheduler instance. + * @param[in] the_thread The thread containing the scheduler node. */ -RTEMS_INLINE_ROUTINE void _Scheduler_Free( +RTEMS_INLINE_ROUTINE void _Scheduler_Node_destroy( const Scheduler_Control *scheduler, Thread_Control *the_thread ) { - ( *scheduler->Operations.free )( scheduler, the_thread ); + ( *scheduler->Operations.node_destroy )( scheduler, the_thread ); } /** @@ -354,9 +364,9 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Set( if ( current_scheduler != scheduler ) { _Thread_Set_state( the_thread, STATES_MIGRATING ); - _Scheduler_Free( current_scheduler, the_thread ); + _Scheduler_Node_destroy( current_scheduler, the_thread ); the_thread->scheduler = scheduler; - _Scheduler_Allocate( scheduler, the_thread ); + _Scheduler_Node_initialize( scheduler, the_thread ); _Scheduler_Update( scheduler, the_thread ); _Thread_Clear_state( the_thread, STATES_MIGRATING ); } diff --git a/cpukit/score/include/rtems/score/schedulerpriority.h b/cpukit/score/include/rtems/score/schedulerpriority.h index b3c1466066..3f18f54c09 100644 --- a/cpukit/score/include/rtems/score/schedulerpriority.h +++ b/cpukit/score/include/rtems/score/schedulerpriority.h @@ -53,8 +53,8 @@ extern "C" { _Scheduler_priority_Block, /* block entry point */ \ _Scheduler_priority_Unblock, /* unblock entry point */ \ _Scheduler_priority_Change_priority, /* change priority entry point */ \ - _Scheduler_default_Allocate, /* allocate entry point */ \ - _Scheduler_default_Free, /* free entry point */ \ + _Scheduler_default_Node_initialize, /* node initialize entry point */ \ + _Scheduler_default_Node_destroy, /* node destroy entry point */ \ _Scheduler_priority_Update, /* update entry point */ \ _Scheduler_priority_Priority_compare, /* compares two priorities */ \ _Scheduler_default_Release_job, /* new period of task */ \ diff --git a/cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h b/cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h index 55271dcf0e..ab35704a5e 100644 --- a/cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h +++ b/cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h @@ -55,8 +55,8 @@ extern "C" { _Scheduler_priority_SMP_Block, \ _Scheduler_priority_SMP_Unblock, \ _Scheduler_priority_SMP_Change_priority, \ - _Scheduler_priority_affinity_SMP_Allocate, \ - _Scheduler_default_Free, \ + _Scheduler_priority_affinity_SMP_Node_initialize, \ + _Scheduler_default_Node_destroy, \ _Scheduler_priority_SMP_Update, \ _Scheduler_priority_Priority_compare, \ _Scheduler_default_Release_job, \ @@ -75,7 +75,7 @@ extern "C" { * @param[in] the_thread is the thread the scheduler is allocating * management memory for. */ -bool _Scheduler_priority_affinity_SMP_Allocate( +void _Scheduler_priority_affinity_SMP_Node_initialize( const Scheduler_Control *scheduler, Thread_Control *the_thread ); diff --git a/cpukit/score/include/rtems/score/schedulerprioritysmp.h b/cpukit/score/include/rtems/score/schedulerprioritysmp.h index 1030b9fac0..c17fcf4a05 100644 --- a/cpukit/score/include/rtems/score/schedulerprioritysmp.h +++ b/cpukit/score/include/rtems/score/schedulerprioritysmp.h @@ -84,8 +84,8 @@ typedef struct { _Scheduler_priority_SMP_Block, \ _Scheduler_priority_SMP_Unblock, \ _Scheduler_priority_SMP_Change_priority, \ - _Scheduler_priority_SMP_Allocate, \ - _Scheduler_default_Free, \ + _Scheduler_priority_SMP_Node_initialize, \ + _Scheduler_default_Node_destroy, \ _Scheduler_priority_SMP_Update, \ _Scheduler_priority_Priority_compare, \ _Scheduler_default_Release_job, \ @@ -97,7 +97,7 @@ typedef struct { void _Scheduler_priority_SMP_Initialize( const Scheduler_Control *scheduler ); -bool _Scheduler_priority_SMP_Allocate( +void _Scheduler_priority_SMP_Node_initialize( const Scheduler_Control *scheduler, Thread_Control *thread ); diff --git a/cpukit/score/include/rtems/score/schedulersimple.h b/cpukit/score/include/rtems/score/schedulersimple.h index 6b59a0ab9e..9fc2d31f15 100644 --- a/cpukit/score/include/rtems/score/schedulersimple.h +++ b/cpukit/score/include/rtems/score/schedulersimple.h @@ -43,8 +43,8 @@ extern "C" { _Scheduler_simple_Block, /* block entry point */ \ _Scheduler_simple_Unblock, /* unblock entry point */ \ _Scheduler_simple_Change_priority, /* change priority entry point */ \ - _Scheduler_default_Allocate, /* allocate entry point */ \ - _Scheduler_default_Free, /* free entry point */ \ + _Scheduler_default_Node_initialize, /* node initialize entry point */ \ + _Scheduler_default_Node_destroy, /* node destroy entry point */ \ _Scheduler_default_Update, /* update entry point */ \ _Scheduler_priority_Priority_compare, /* compares two priorities */ \ _Scheduler_default_Release_job, /* new period of task */ \ diff --git a/cpukit/score/include/rtems/score/schedulersimplesmp.h b/cpukit/score/include/rtems/score/schedulersimplesmp.h index 6c4d421ed7..6ab1dd2894 100644 --- a/cpukit/score/include/rtems/score/schedulersimplesmp.h +++ b/cpukit/score/include/rtems/score/schedulersimplesmp.h @@ -65,8 +65,8 @@ typedef struct { _Scheduler_simple_SMP_Block, \ _Scheduler_simple_SMP_Unblock, \ _Scheduler_simple_SMP_Change_priority, \ - _Scheduler_simple_SMP_Allocate, \ - _Scheduler_default_Free, \ + _Scheduler_simple_SMP_Node_initialize, \ + _Scheduler_default_Node_destroy, \ _Scheduler_default_Update, \ _Scheduler_priority_Priority_compare, \ _Scheduler_default_Release_job, \ @@ -78,7 +78,7 @@ typedef struct { void _Scheduler_simple_SMP_Initialize( const Scheduler_Control *scheduler ); -bool _Scheduler_simple_SMP_Allocate( +void _Scheduler_simple_SMP_Node_initialize( const Scheduler_Control *scheduler, Thread_Control *the_thread ); diff --git a/cpukit/score/src/schedulercbsallocate.c b/cpukit/score/src/schedulercbsnodeinit.c index 6a29088eb6..b76380fcad 100644 --- a/cpukit/score/src/schedulercbsallocate.c +++ b/cpukit/score/src/schedulercbsnodeinit.c @@ -20,9 +20,9 @@ #include <rtems/score/schedulercbsimpl.h> -bool _Scheduler_CBS_Allocate( +void _Scheduler_CBS_Node_initialize( const Scheduler_Control *scheduler, - Thread_Control *the_thread + Thread_Control *the_thread ) { Scheduler_CBS_Node *node = _Scheduler_CBS_Node_get( the_thread ); @@ -32,6 +32,4 @@ bool _Scheduler_CBS_Allocate( node->Base.thread = the_thread; node->Base.queue_state = SCHEDULER_EDF_QUEUE_STATE_NEVER_HAS_BEEN; node->cbs_server = NULL; - - return true; } diff --git a/cpukit/score/src/schedulerdefaultallocatefree.c b/cpukit/score/src/schedulerdefaultnodedestroy.c index c865385dfb..d1d84f366a 100644 --- a/cpukit/score/src/schedulerdefaultallocatefree.c +++ b/cpukit/score/src/schedulerdefaultnodedestroy.c @@ -1,7 +1,7 @@ /** * @file * - * @brief Scheduler Default Allocate and Release Operation + * @brief Scheduler Default Node Destruction Operation * * @ingroup ScoreScheduler */ @@ -21,22 +21,11 @@ #include <rtems/score/scheduler.h> -bool _Scheduler_default_Allocate( +void _Scheduler_default_Node_destroy( const Scheduler_Control *scheduler, Thread_Control *the_thread ) { - ( void ) scheduler; - ( void ) the_thread; - - return true; -} - -void _Scheduler_default_Free( - const Scheduler_Control *scheduler, - Thread_Control *the_thread -) -{ - ( void ) scheduler; - ( void ) the_thread; + (void) scheduler; + (void) the_thread; } diff --git a/cpukit/score/src/schedulerdefaultnodeinit.c b/cpukit/score/src/schedulerdefaultnodeinit.c new file mode 100644 index 0000000000..ab371bd7fe --- /dev/null +++ b/cpukit/score/src/schedulerdefaultnodeinit.c @@ -0,0 +1,31 @@ +/** + * @file + * + * @brief Scheduler Default Node Initialization Operation + * + * @ingroup ScoreScheduler + */ + +/* + * 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.org/license/LICENSE. + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems/score/scheduler.h> + +void _Scheduler_default_Node_initialize( + const Scheduler_Control *scheduler, + Thread_Control *the_thread +) +{ + (void) scheduler; + (void) the_thread; +} diff --git a/cpukit/score/src/scheduleredfallocate.c b/cpukit/score/src/scheduleredfnodeinit.c index f9aaa57b8a..031feb08f2 100644 --- a/cpukit/score/src/scheduleredfallocate.c +++ b/cpukit/score/src/scheduleredfnodeinit.c @@ -20,7 +20,7 @@ #include <rtems/score/scheduleredfimpl.h> -bool _Scheduler_EDF_Allocate( +void _Scheduler_EDF_Node_initialize( const Scheduler_Control *scheduler, Thread_Control *the_thread ) @@ -31,6 +31,4 @@ bool _Scheduler_EDF_Allocate( node->thread = the_thread; node->queue_state = SCHEDULER_EDF_QUEUE_STATE_NEVER_HAS_BEEN; - - return true; } diff --git a/cpukit/score/src/schedulerpriorityaffinitysmp.c b/cpukit/score/src/schedulerpriorityaffinitysmp.c index 0d9525d894..317d8ce32d 100644 --- a/cpukit/score/src/schedulerpriorityaffinitysmp.c +++ b/cpukit/score/src/schedulerpriorityaffinitysmp.c @@ -32,7 +32,7 @@ _Scheduler_priority_affinity_Node_get( Thread_Control *thread ) _Scheduler_Node_get( thread ); } -bool _Scheduler_priority_affinity_SMP_Allocate( +void _Scheduler_priority_affinity_SMP_Node_initialize( const Scheduler_Control *scheduler, Thread_Control *the_thread ) @@ -44,8 +44,6 @@ bool _Scheduler_priority_affinity_SMP_Allocate( node->Affinity = *_CPU_set_Default(); node->Affinity.set = &node->Affinity.preallocated; - - return true; } bool _Scheduler_priority_affinity_SMP_Get_affinity( diff --git a/cpukit/score/src/schedulerprioritysmp.c b/cpukit/score/src/schedulerprioritysmp.c index 56bb0ac91b..e0ed75c477 100644 --- a/cpukit/score/src/schedulerprioritysmp.c +++ b/cpukit/score/src/schedulerprioritysmp.c @@ -64,7 +64,7 @@ void _Scheduler_priority_SMP_Initialize( const Scheduler_Control *scheduler ) _Scheduler_priority_Ready_queue_initialize( &self->Ready[ 0 ] ); } -bool _Scheduler_priority_SMP_Allocate( +void _Scheduler_priority_SMP_Node_initialize( const Scheduler_Control *scheduler, Thread_Control *thread ) @@ -72,8 +72,6 @@ bool _Scheduler_priority_SMP_Allocate( Scheduler_SMP_Node *node = _Scheduler_SMP_Node_get( thread ); _Scheduler_SMP_Node_initialize( node ); - - return true; } static void _Scheduler_priority_SMP_Do_update( diff --git a/cpukit/score/src/schedulersimplesmp.c b/cpukit/score/src/schedulersimplesmp.c index d5d3908f30..029da67b7a 100644 --- a/cpukit/score/src/schedulersimplesmp.c +++ b/cpukit/score/src/schedulersimplesmp.c @@ -42,7 +42,7 @@ void _Scheduler_simple_SMP_Initialize( const Scheduler_Control *scheduler ) _Chain_Initialize_empty( &self->Ready ); } -bool _Scheduler_simple_SMP_Allocate( +void _Scheduler_simple_SMP_Node_initialize( const Scheduler_Control *scheduler, Thread_Control *the_thread ) @@ -50,8 +50,6 @@ bool _Scheduler_simple_SMP_Allocate( Scheduler_SMP_Node *node = _Scheduler_SMP_Node_get( the_thread ); _Scheduler_SMP_Node_initialize( node ); - - return true; } static void _Scheduler_simple_SMP_Do_update( diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c index 9c65d73586..2a79549848 100644 --- a/cpukit/score/src/threadinitialize.c +++ b/cpukit/score/src/threadinitialize.c @@ -52,7 +52,7 @@ bool _Thread_Initialize( #endif bool extension_status; size_t i; - bool scheduler_allocated = false; + bool scheduler_node_initialized = false; Per_CPU_Control *cpu = _Per_CPU_Get_by_index( 0 ); #if defined( RTEMS_SMP ) @@ -198,10 +198,8 @@ bool _Thread_Initialize( the_thread->real_priority = priority; the_thread->Start.initial_priority = priority; - scheduler_allocated = _Scheduler_Allocate( scheduler, the_thread ); - if ( !scheduler_allocated ) { - goto failed; - } + _Scheduler_Node_initialize( scheduler, the_thread ); + scheduler_node_initialized = true; _Thread_Set_priority( the_thread, priority ); @@ -246,8 +244,8 @@ bool _Thread_Initialize( failed: - if ( scheduler_allocated ) { - _Scheduler_Free( scheduler, the_thread ); + if ( scheduler_node_initialized ) { + _Scheduler_Node_destroy( scheduler, the_thread ); } _Workspace_Free( the_thread->Start.tls_area ); diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c index c65ef9a21b..92470e5e35 100644 --- a/cpukit/score/src/threadrestart.c +++ b/cpukit/score/src/threadrestart.c @@ -71,7 +71,7 @@ static void _Thread_Free( Thread_Control *the_thread ) /* * Free the per-thread scheduling information. */ - _Scheduler_Free( _Scheduler_Get( the_thread ), the_thread ); + _Scheduler_Node_destroy( _Scheduler_Get( the_thread ), the_thread ); /* * The thread might have been FP. So deal with that. |