[rtems commit] score: Remove scheduler parameter from most ops
Sebastian Huber
sebh at rtems.org
Mon Jun 23 08:27:13 UTC 2014
Module: rtems
Branch: master
Commit: 92635cb36d7af890c4fc76ac8323b79936001ddd
Changeset: http://git.rtems.org/rtems/commit/?id=92635cb36d7af890c4fc76ac8323b79936001ddd
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Tue Jun 3 16:27:53 2014 +0200
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.
---
cpukit/rtems/src/ratemoncancel.c | 6 +-
cpukit/rtems/src/ratemondelete.c | 6 +-
cpukit/rtems/src/ratemonperiod.c | 12 +---
cpukit/score/include/rtems/score/schedulerimpl.h | 93 +++++++++++-----------
cpukit/score/src/schedulerdefaultstartidle.c | 3 +-
cpukit/score/src/threadchangepriority.c | 10 +--
cpukit/score/src/threadclearstate.c | 2 +-
cpukit/score/src/threadready.c | 2 +-
cpukit/score/src/threadsetpriority.c | 6 +-
cpukit/score/src/threadsetstate.c | 2 +-
cpukit/score/src/threadyield.c | 2 +-
11 files changed, 60 insertions(+), 84 deletions(-)
diff --git a/cpukit/rtems/src/ratemoncancel.c b/cpukit/rtems/src/ratemoncancel.c
index 9f993f2..d4a9102 100644
--- a/cpukit/rtems/src/ratemoncancel.c
+++ b/cpukit/rtems/src/ratemoncancel.c
@@ -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;
diff --git a/cpukit/rtems/src/ratemondelete.c b/cpukit/rtems/src/ratemondelete.c
index ee0b236..971ad8e 100644
--- a/cpukit/rtems/src/ratemondelete.c
+++ b/cpukit/rtems/src/ratemondelete.c
@@ -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;
diff --git a/cpukit/rtems/src/ratemonperiod.c b/cpukit/rtems/src/ratemonperiod.c
index 9d31813..ca278fb 100644
--- a/cpukit/rtems/src/ratemonperiod.c
+++ b/cpukit/rtems/src/ratemonperiod.c
@@ -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;
}
diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h b/cpukit/score/include/rtems/score/schedulerimpl.h
index f162ab3..ad4c799 100644
--- a/cpukit/score/include/rtems/score/schedulerimpl.h
+++ b/cpukit/score/include/rtems/score/schedulerimpl.h
@@ -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
diff --git a/cpukit/score/src/schedulerdefaultstartidle.c b/cpukit/score/src/schedulerdefaultstartidle.c
index eeed928..2da7f8d 100644
--- a/cpukit/score/src/schedulerdefaultstartidle.c
+++ b/cpukit/score/src/schedulerdefaultstartidle.c
@@ -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 );
}
diff --git a/cpukit/score/src/threadchangepriority.c b/cpukit/score/src/threadchangepriority.c
index c2e48e1..8ddaa0b 100644
--- a/cpukit/score/src/threadchangepriority.c
+++ b/cpukit/score/src/threadchangepriority.c
@@ -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 );
diff --git a/cpukit/score/src/threadclearstate.c b/cpukit/score/src/threadclearstate.c
index 10bdae6..19e41df 100644
--- a/cpukit/score/src/threadclearstate.c
+++ b/cpukit/score/src/threadclearstate.c
@@ -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 );
diff --git a/cpukit/score/src/threadready.c b/cpukit/score/src/threadready.c
index d50debe..b79d8db 100644
--- a/cpukit/score/src/threadready.c
+++ b/cpukit/score/src/threadready.c
@@ -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 );
}
diff --git a/cpukit/score/src/threadsetpriority.c b/cpukit/score/src/threadsetpriority.c
index 455cf20..e1ff118 100644
--- a/cpukit/score/src/threadsetpriority.c
+++ b/cpukit/score/src/threadsetpriority.c
@@ -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 );
}
diff --git a/cpukit/score/src/threadsetstate.c b/cpukit/score/src/threadsetstate.c
index 97da2bf..a8cd38e 100644
--- a/cpukit/score/src/threadsetstate.c
+++ b/cpukit/score/src/threadsetstate.c
@@ -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);
}
diff --git a/cpukit/score/src/threadyield.c b/cpukit/score/src/threadyield.c
index b49e2b3..fc796da 100644
--- a/cpukit/score/src/threadyield.c
+++ b/cpukit/score/src/threadyield.c
@@ -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 );
More information about the vc
mailing list