score: Remove scheduler parameter from most ops

Remove the scheduler parameter from most high level scheduler operations
like
  - _Scheduler_Block(),
  - _Scheduler_Unblock(),
  - _Scheduler_Change_priority(),
  - _Scheduler_Update_priority(),
  - _Scheduler_Release_job(), and
  - _Scheduler_Yield().

This simplifies the scheduler operations usage.
This commit is contained in:
Sebastian Huber
2014-06-23 09:13:00 +02:00
parent bd1431ab29
commit 92635cb36d
11 changed files with 60 additions and 84 deletions
+1 -5
View File
@@ -40,11 +40,7 @@ rtems_status_code rtems_rate_monotonic_cancel(
}
(void) _Watchdog_Remove( &the_period->Timer );
the_period->state = RATE_MONOTONIC_INACTIVE;
_Scheduler_Release_job(
_Scheduler_Get( the_period->owner ),
the_period->owner,
0
);
_Scheduler_Release_job( the_period->owner, 0 );
_Objects_Put( &the_period->Object );
return RTEMS_SUCCESSFUL;
+1 -5
View File
@@ -35,11 +35,7 @@ rtems_status_code rtems_rate_monotonic_delete(
switch ( location ) {
case OBJECTS_LOCAL:
_Scheduler_Release_job(
_Scheduler_Get( the_period->owner ),
the_period->owner,
0
);
_Scheduler_Release_job( the_period->owner, 0 );
_Objects_Close( &_Rate_monotonic_Information, &the_period->Object );
(void) _Watchdog_Remove( &the_period->Timer );
the_period->state = RATE_MONOTONIC_INACTIVE;
+2 -10
View File
@@ -144,11 +144,7 @@ void _Rate_monotonic_Initiate_statistics(
}
#endif
_Scheduler_Release_job(
_Scheduler_Get( the_period->owner ),
the_period->owner,
the_period->next_length
);
_Scheduler_Release_job( the_period->owner, the_period->next_length );
}
static void _Rate_monotonic_Update_statistics(
@@ -344,11 +340,7 @@ rtems_status_code rtems_rate_monotonic_period(
the_period->next_length = length;
_Watchdog_Insert_ticks( &the_period->Timer, length );
_Scheduler_Release_job(
_Scheduler_Get( the_period->owner ),
the_period->owner,
the_period->next_length
);
_Scheduler_Release_job( the_period->owner, the_period->next_length );
_Objects_Put( &the_period->Object );
return RTEMS_TIMEOUT;
}
@@ -42,6 +42,19 @@ extern "C" {
*/
void _Scheduler_Handler_initialization( void );
RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Get(
const Thread_Control *the_thread
)
{
#if defined(RTEMS_SMP)
return the_thread->scheduler;
#else
(void) the_thread;
return &_Scheduler_Table[ 0 ];
#endif
}
RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Get_by_CPU_index(
uint32_t cpu_index
)
@@ -80,18 +93,17 @@ RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Get_by_CPU(
*/
/**
* @brief Scheduler schedule.
* @brief General scheduling decision.
*
* This kernel routine implements the scheduling decision logic for
* the scheduler. It does NOT dispatch.
*
* @param[in] the_thread The thread which state changed previously.
*/
RTEMS_INLINE_ROUTINE void _Scheduler_Schedule(
const Scheduler_Control *scheduler,
Thread_Control *the_thread
)
RTEMS_INLINE_ROUTINE void _Scheduler_Schedule( Thread_Control *the_thread )
{
const Scheduler_Control *scheduler = _Scheduler_Get( the_thread );
( *scheduler->Operations.schedule )( scheduler, the_thread );
}
@@ -103,43 +115,44 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Schedule(
*
* @param[in] the_thread The yielding thread.
*/
RTEMS_INLINE_ROUTINE void _Scheduler_Yield(
const Scheduler_Control *scheduler,
Thread_Control *the_thread
)
RTEMS_INLINE_ROUTINE void _Scheduler_Yield( Thread_Control *the_thread )
{
const Scheduler_Control *scheduler = _Scheduler_Get( the_thread );
( *scheduler->Operations.yield )( scheduler, the_thread );
}
/**
* @brief Scheduler block.
* @brief Blocks a thread with respect to the scheduler.
*
* This routine removes @a the_thread from the scheduling decision for
* the scheduler. The primary task is to remove the thread from the
* ready queue. It performs any necessary schedulering operations
* including the selection of a new heir thread.
*
* @param[in] the_thread The thread.
*/
RTEMS_INLINE_ROUTINE void _Scheduler_Block(
const Scheduler_Control *scheduler,
Thread_Control *the_thread
)
RTEMS_INLINE_ROUTINE void _Scheduler_Block( Thread_Control *the_thread )
{
const Scheduler_Control *scheduler = _Scheduler_Get( the_thread );
( *scheduler->Operations.block )( scheduler, the_thread );
}
/**
* @brief Scheduler unblock.
* @brief Unblocks a thread with respect to the scheduler.
*
* This routine adds @a the_thread to the scheduling decision for
* the scheduler. The primary task is to add the thread to the
* ready queue per the schedulering policy and update any appropriate
* scheduling variables, for example the heir thread.
*
* @param[in] the_thread The thread.
*/
RTEMS_INLINE_ROUTINE void _Scheduler_Unblock(
const Scheduler_Control *scheduler,
Thread_Control *the_thread
)
RTEMS_INLINE_ROUTINE void _Scheduler_Unblock( Thread_Control *the_thread )
{
const Scheduler_Control *scheduler = _Scheduler_Get( the_thread );
( *scheduler->Operations.unblock )( scheduler, the_thread );
}
@@ -150,7 +163,6 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Unblock(
* must ensure that the priority value actually changed and is not equal to the
* current priority value.
*
* @param[in] scheduler The scheduler instance.
* @param[in] the_thread The thread changing its priority.
* @param[in] new_priority The new thread priority.
* @param[in] prepend_it In case this is true, then enqueue the thread as the
@@ -158,12 +170,13 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Unblock(
* priority group.
*/
RTEMS_INLINE_ROUTINE void _Scheduler_Change_priority(
const Scheduler_Control *scheduler,
Thread_Control *the_thread,
Priority_Control new_priority,
bool prepend_it
)
{
const Scheduler_Control *scheduler = _Scheduler_Get( the_thread );
( *scheduler->Operations.change_priority )(
scheduler,
the_thread,
@@ -215,11 +228,12 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Node_destroy(
* @param[in] new_priority The new priority of the thread.
*/
RTEMS_INLINE_ROUTINE void _Scheduler_Update_priority(
const Scheduler_Control *scheduler,
Thread_Control *the_thread,
Priority_Control new_priority
Thread_Control *the_thread,
Priority_Control new_priority
)
{
const Scheduler_Control *scheduler = _Scheduler_Get( the_thread );
( *scheduler->Operations.update_priority )(
scheduler,
the_thread,
@@ -253,16 +267,18 @@ RTEMS_INLINE_ROUTINE int _Scheduler_Priority_compare(
}
/**
* @brief Scheduler release job.
* @brief Releases a job of a thread with respect to the scheduler.
*
* This routine is called when a new period of task is issued.
* @param[in] the_thread The thread.
* @param[in] length The period length.
*/
RTEMS_INLINE_ROUTINE void _Scheduler_Release_job(
const Scheduler_Control *scheduler,
Thread_Control *the_thread,
uint32_t length
Thread_Control *the_thread,
uint32_t length
)
{
const Scheduler_Control *scheduler = _Scheduler_Get( the_thread );
( *scheduler->Operations.release_job )( scheduler, the_thread, length );
}
@@ -348,19 +364,6 @@ RTEMS_INLINE_ROUTINE bool _Scheduler_Has_processor_ownership(
#endif
}
RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Get(
const Thread_Control *the_thread
)
{
#if defined(RTEMS_SMP)
return the_thread->scheduler;
#else
(void) the_thread;
return &_Scheduler_Table[ 0 ];
#endif
}
RTEMS_INLINE_ROUTINE void _Scheduler_Set(
const Scheduler_Control *scheduler,
Thread_Control *the_thread
@@ -374,11 +377,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Set(
_Scheduler_Node_destroy( current_scheduler, the_thread );
the_thread->scheduler = scheduler;
_Scheduler_Node_initialize( scheduler, the_thread );
_Scheduler_Update_priority(
scheduler,
the_thread,
the_thread->current_priority
);
_Scheduler_Update_priority( the_thread, the_thread->current_priority );
_Thread_Clear_state( the_thread, STATES_MIGRATING );
}
#else
+2 -1
View File
@@ -18,6 +18,7 @@ void _Scheduler_default_Start_idle(
Per_CPU_Control *cpu
)
{
(void) scheduler;
(void) cpu;
_Scheduler_Unblock( scheduler, the_thread );
_Scheduler_Unblock( the_thread );
}
+3 -7
View File
@@ -81,17 +81,14 @@ void _Thread_Change_priority(
* we are not REALLY changing priority.
*/
if ( the_thread->current_priority != new_priority ) {
ISR_Level level;
const Scheduler_Control *scheduler;
ISR_Level level;
_ISR_Disable( level );
scheduler = _Scheduler_Get( the_thread );
the_thread->current_priority = new_priority;
if ( _States_Is_ready( the_thread->current_state ) ) {
_Scheduler_Change_priority(
scheduler,
the_thread,
new_priority,
prepend_it
@@ -103,10 +100,9 @@ void _Thread_Change_priority(
* We altered the set of thread priorities. So let's figure out
* who is the heir and if we need to switch to them.
*/
scheduler = _Scheduler_Get( the_thread );
_Scheduler_Schedule( scheduler, the_thread );
_Scheduler_Schedule( the_thread );
} else {
_Scheduler_Update_priority( scheduler, the_thread, new_priority );
_Scheduler_Update_priority( the_thread, new_priority );
}
_ISR_Enable( level );
+1 -1
View File
@@ -37,7 +37,7 @@ void _Thread_Clear_state(
the_thread->current_state = _States_Clear( state, current_state );
if ( _States_Is_ready( current_state ) ) {
_Scheduler_Unblock( _Scheduler_Get( the_thread ), the_thread );
_Scheduler_Unblock( the_thread );
}
}
_ISR_Enable( level );
+1 -1
View File
@@ -32,7 +32,7 @@ void _Thread_Ready(
the_thread->current_state = STATES_READY;
_Scheduler_Unblock( _Scheduler_Get( the_thread ), the_thread );
_Scheduler_Unblock( the_thread );
_ISR_Enable( level );
}
+1 -5
View File
@@ -28,9 +28,5 @@ void _Thread_Set_priority(
{
the_thread->current_priority = new_priority;
_Scheduler_Update_priority(
_Scheduler_Get( the_thread),
the_thread,
new_priority
);
_Scheduler_Update_priority( the_thread, new_priority );
}
+1 -1
View File
@@ -39,7 +39,7 @@ void _Thread_Set_state(
if ( _States_Is_ready( current_state ) ) {
the_thread->current_state = state;
_Scheduler_Block( _Scheduler_Get( the_thread ), the_thread );
_Scheduler_Block( the_thread );
} else {
the_thread->current_state = _States_Set( state, current_state);
}
+1 -1
View File
@@ -34,7 +34,7 @@ void _Thread_Yield( Thread_Control *executing )
_ISR_Disable( level );
if ( _States_Is_ready( executing->current_state ) ) {
_Scheduler_Yield( _Scheduler_Get( executing ), executing );
_Scheduler_Yield( executing );
}
_ISR_Enable( level );