[PATCH 3/3] score: Add scheduler control to scheduler ops
Sebastian Huber
sebastian.huber at embedded-brains.de
Thu Apr 3 14:28:34 UTC 2014
Scheduler operations must be free of a global scheduler context to
enable partitioned/clustered scheduling.
---
cpukit/posix/src/nanosleep.c | 2 +-
cpukit/posix/src/sched_yield.c | 5 +-
cpukit/rtems/src/clocktick.c | 2 +-
cpukit/rtems/src/ratemoncancel.c | 6 +-
cpukit/rtems/src/ratemondelete.c | 6 +-
cpukit/rtems/src/ratemonperiod.c | 12 ++-
cpukit/rtems/src/taskwakeafter.c | 2 +-
cpukit/score/include/rtems/score/scheduler.h | 83 ++++++++-----
cpukit/score/include/rtems/score/schedulercbs.h | 9 +-
cpukit/score/include/rtems/score/scheduleredf.h | 31 ++++--
.../score/include/rtems/score/scheduleredfimpl.h | 12 +-
cpukit/score/include/rtems/score/schedulerimpl.h | 126 ++++++++++++--------
.../score/include/rtems/score/schedulerpriority.h | 30 ++++--
.../include/rtems/score/schedulerpriorityimpl.h | 20 ++--
.../include/rtems/score/schedulerprioritysmp.h | 36 +++++-
cpukit/score/include/rtems/score/schedulersimple.h | 27 +++-
.../include/rtems/score/schedulersimpleimpl.h | 19 ++--
.../score/include/rtems/score/schedulersimplesmp.h | 31 ++++-
cpukit/score/include/rtems/score/threadimpl.h | 4 +-
cpukit/score/src/coremutexseize.c | 5 +-
cpukit/score/src/schedulercbsallocate.c | 5 +-
cpukit/score/src/schedulercbsreleasejob.c | 1 +
cpukit/score/src/schedulercbsunblock.c | 12 ++-
cpukit/score/src/schedulerdefaultallocatefree.c | 12 ++-
cpukit/score/src/schedulerdefaultreleasejob.c | 8 +-
cpukit/score/src/schedulerdefaultstartidle.c | 11 +-
cpukit/score/src/schedulerdefaulttick.c | 11 +-
cpukit/score/src/schedulerdefaultupdate.c | 6 +-
cpukit/score/src/scheduleredf.c | 2 +-
cpukit/score/src/scheduleredfallocate.c | 5 +-
cpukit/score/src/scheduleredfblock.c | 6 +-
cpukit/score/src/scheduleredfenqueue.c | 3 +-
cpukit/score/src/scheduleredfenqueuefirst.c | 3 +-
cpukit/score/src/scheduleredfextract.c | 5 +-
cpukit/score/src/scheduleredffree.c | 5 +-
cpukit/score/src/scheduleredfreleasejob.c | 3 +
cpukit/score/src/scheduleredfschedule.c | 7 +-
cpukit/score/src/scheduleredfunblock.c | 4 +-
cpukit/score/src/scheduleredfupdate.c | 5 +-
cpukit/score/src/scheduleredfyield.c | 11 +-
cpukit/score/src/schedulerpriorityallocate.c | 5 +-
cpukit/score/src/schedulerpriorityblock.c | 10 +-
cpukit/score/src/schedulerpriorityenqueue.c | 6 +-
cpukit/score/src/schedulerpriorityenqueuefirst.c | 8 +-
cpukit/score/src/schedulerpriorityextract.c | 7 +-
cpukit/score/src/schedulerpriorityfree.c | 3 +
.../score/src/schedulerpriorityprioritycompare.c | 4 +-
cpukit/score/src/schedulerpriorityschedule.c | 7 +-
cpukit/score/src/schedulerprioritysmp.c | 94 ++++++++++-----
cpukit/score/src/schedulerpriorityunblock.c | 8 +-
cpukit/score/src/schedulerpriorityupdate.c | 9 +-
cpukit/score/src/schedulerpriorityyield.c | 17 ++-
cpukit/score/src/schedulersimpleblock.c | 8 +-
cpukit/score/src/schedulersimpleenqueue.c | 5 +-
cpukit/score/src/schedulersimpleenqueuefirst.c | 5 +-
cpukit/score/src/schedulersimpleextract.c | 3 +
.../score/src/schedulersimplereadyqueueenqueue.c | 3 +-
.../src/schedulersimplereadyqueueenqueuefirst.c | 3 +-
cpukit/score/src/schedulersimpleschedule.c | 7 +-
cpukit/score/src/schedulersimplesmp.c | 90 +++++++++-----
cpukit/score/src/schedulersimpleunblock.c | 3 +-
cpukit/score/src/schedulersimpleyield.c | 9 +-
cpukit/score/src/threadchangepriority.c | 13 +-
cpukit/score/src/threadclearstate.c | 2 +-
cpukit/score/src/threadinitialize.c | 2 +-
cpukit/score/src/threadready.c | 2 +-
cpukit/score/src/threadrestart.c | 23 +++-
cpukit/score/src/threadsetpriority.c | 2 +-
cpukit/score/src/threadsetstate.c | 2 +-
cpukit/score/src/threadsettransient.c | 2 +-
cpukit/score/src/threadstart.c | 6 +-
testsuites/tmtests/tm26/task1.c | 12 ++-
testsuites/tmtests/tm27/task1.c | 6 +-
73 files changed, 655 insertions(+), 324 deletions(-)
diff --git a/cpukit/posix/src/nanosleep.c b/cpukit/posix/src/nanosleep.c
index 52fcc96..ebaef33 100644
--- a/cpukit/posix/src/nanosleep.c
+++ b/cpukit/posix/src/nanosleep.c
@@ -65,7 +65,7 @@ int nanosleep(
if ( !ticks ) {
_Thread_Disable_dispatch();
executing = _Thread_Executing;
- _Scheduler_Yield( executing );
+ _Scheduler_Yield( _Scheduler_Get( executing ), executing );
_Thread_Enable_dispatch();
if ( rmtp ) {
rmtp->tv_sec = 0;
diff --git a/cpukit/posix/src/sched_yield.c b/cpukit/posix/src/sched_yield.c
index 906d102..5293b19 100644
--- a/cpukit/posix/src/sched_yield.c
+++ b/cpukit/posix/src/sched_yield.c
@@ -26,8 +26,11 @@
int sched_yield( void )
{
+ Thread_Control *executing;
+
_Thread_Disable_dispatch();
- _Scheduler_Yield( _Thread_Executing );
+ executing = _Thread_Executing;
+ _Scheduler_Yield( _Scheduler_Get( executing ), executing );
_Thread_Enable_dispatch();
return 0;
}
diff --git a/cpukit/rtems/src/clocktick.c b/cpukit/rtems/src/clocktick.c
index a026b44..1abaa7f 100644
--- a/cpukit/rtems/src/clocktick.c
+++ b/cpukit/rtems/src/clocktick.c
@@ -34,7 +34,7 @@ rtems_status_code rtems_clock_tick( void )
_Watchdog_Tickle_ticks();
- _Scheduler_Tick();
+ _Scheduler_Tick( _Scheduler_Get( NULL ) );
#if defined( RTEMS_SMP )
_Thread_Enable_dispatch();
diff --git a/cpukit/rtems/src/ratemoncancel.c b/cpukit/rtems/src/ratemoncancel.c
index d9b5dee..9f993f2 100644
--- a/cpukit/rtems/src/ratemoncancel.c
+++ b/cpukit/rtems/src/ratemoncancel.c
@@ -40,7 +40,11 @@ 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);
+ _Scheduler_Release_job(
+ _Scheduler_Get( the_period->owner ),
+ 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 36480be..ee0b236 100644
--- a/cpukit/rtems/src/ratemondelete.c
+++ b/cpukit/rtems/src/ratemondelete.c
@@ -35,7 +35,11 @@ rtems_status_code rtems_rate_monotonic_delete(
switch ( location ) {
case OBJECTS_LOCAL:
- _Scheduler_Release_job(the_period->owner, 0);
+ _Scheduler_Release_job(
+ _Scheduler_Get( the_period->owner ),
+ 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 4c39fc5..9d31813 100644
--- a/cpukit/rtems/src/ratemonperiod.c
+++ b/cpukit/rtems/src/ratemonperiod.c
@@ -144,7 +144,11 @@ void _Rate_monotonic_Initiate_statistics(
}
#endif
- _Scheduler_Release_job(the_period->owner, the_period->next_length);
+ _Scheduler_Release_job(
+ _Scheduler_Get( the_period->owner ),
+ the_period->owner,
+ the_period->next_length
+ );
}
static void _Rate_monotonic_Update_statistics(
@@ -340,7 +344,11 @@ 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);
+ _Scheduler_Release_job(
+ _Scheduler_Get( the_period->owner ),
+ the_period->owner,
+ the_period->next_length
+ );
_Objects_Put( &the_period->Object );
return RTEMS_TIMEOUT;
}
diff --git a/cpukit/rtems/src/taskwakeafter.c b/cpukit/rtems/src/taskwakeafter.c
index aaa5bf3..367b43a 100644
--- a/cpukit/rtems/src/taskwakeafter.c
+++ b/cpukit/rtems/src/taskwakeafter.c
@@ -37,7 +37,7 @@ rtems_status_code rtems_task_wake_after(
executing = _Thread_Executing;
if ( ticks == 0 ) {
- _Scheduler_Yield( executing );
+ _Scheduler_Yield( _Scheduler_Get( executing ), executing );
} else {
_Thread_Set_state( executing, STATES_DELAYING );
_Watchdog_Initialize(
diff --git a/cpukit/score/include/rtems/score/scheduler.h b/cpukit/score/include/rtems/score/scheduler.h
index 01d0c3a..1bfb951 100644
--- a/cpukit/score/include/rtems/score/scheduler.h
+++ b/cpukit/score/include/rtems/score/scheduler.h
@@ -37,6 +37,8 @@ extern "C" {
*/
/**@{*/
+typedef struct Scheduler_Control Scheduler_Control;
+
/**
* function jump table that holds pointers to the functions that
* implement specific schedulers.
@@ -46,64 +48,71 @@ typedef struct {
void ( *initialize )(void);
/** Implements the scheduling decision logic (policy). */
- void ( *schedule )( Thread_Control *thread );
+ void ( *schedule )( Scheduler_Control *, Thread_Control *);
/**
* @brief Voluntarily yields the processor per the scheduling policy.
*
* @see _Scheduler_Yield().
*/
- void ( *yield )( Thread_Control *thread );
+ void ( *yield )( Scheduler_Control *, Thread_Control *);
/** Removes the given thread from scheduling decisions. */
- void ( *block )(Thread_Control *);
+ void ( *block )( Scheduler_Control *, Thread_Control * );
/** Adds the given thread to scheduling decisions. */
- void ( *unblock )(Thread_Control *);
+ void ( *unblock )( Scheduler_Control *, Thread_Control * );
/** allocates the scheduler field of the given thread */
- void * ( *allocate )(Thread_Control *);
+ void * ( *allocate )( Scheduler_Control *, Thread_Control * );
/** frees the scheduler field of the given thread */
- void ( *free )(Thread_Control *);
+ void ( *free )( Scheduler_Control *, Thread_Control * );
/** updates the scheduler field of the given thread -- primarily used
* when changing the thread's priority. */
- void ( *update )(Thread_Control *);
+ void ( *update )( Scheduler_Control *, Thread_Control * );
/** enqueue a thread as the last of its priority group */
- void ( *enqueue )(Thread_Control *);
+ void ( *enqueue )( Scheduler_Control *, Thread_Control * );
/** enqueue a thread as the first of its priority group */
- void ( *enqueue_first )(Thread_Control *);
+ void ( *enqueue_first )( Scheduler_Control *, Thread_Control * );
/** extract a thread from the ready set */
- void ( *extract )(Thread_Control *);
+ void ( *extract )( Scheduler_Control *, 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);
+ int ( *priority_compare )(
+ Priority_Control,
+ Priority_Control
+ );
/** This routine is called upon release of a new job. */
- void ( *release_job ) (Thread_Control *, uint32_t);
+ void ( *release_job ) ( Scheduler_Control *, Thread_Control *, uint32_t );
/** perform scheduler update actions required at each clock tick */
- void ( *tick )(void);
+ void ( *tick )( Scheduler_Control * );
/**
* @brief Starts the idle thread for a particular processor.
*
* @see _Scheduler_Start_idle().
*/
- void ( *start_idle )( Thread_Control *thread, Per_CPU_Control *processor );
+ void ( *start_idle )(
+ Scheduler_Control *,
+ Thread_Control *,
+ Per_CPU_Control *
+ );
} Scheduler_Operations;
/**
* This is the structure used to manage the scheduler.
*/
-typedef struct {
+struct Scheduler_Control {
/**
* This points to the data structure used to manage the ready set of
* tasks. The pointer varies based upon the type of
@@ -113,7 +122,7 @@ typedef struct {
/** The jump table for scheduler-specific functions */
Scheduler_Operations Operations;
-} Scheduler_Control;
+};
/**
* The _Scheduler holds the structures used to manage the
@@ -128,41 +137,49 @@ extern Scheduler_Control _Scheduler;
/**
* @brief Returns an arbitrary non-NULL value.
*
- * @param[in] thread Unused.
+ * @param[in] scheduler Unused.
+ * @param[in] the_thread Unused.
*
* @return An arbitrary non-NULL value.
*/
void *_Scheduler_default_Allocate(
- Thread_Control *thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
);
/**
* @brief Does nothing.
*
- * @param[in] thread Unused.
+ * @param[in] scheduler Unused.
+ * @param[in] the_thread Unused.
*/
void _Scheduler_default_Free(
- Thread_Control *thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
);
/**
* @brief Does nothing.
*
- * @param[in] thread Unused.
+ * @param[in] scheduler Unused.
+ * @param[in] the_thread Unused.
*/
void _Scheduler_default_Update(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
);
/**
* @brief Does nothing.
*
- * @param[in] thread Unused.
+ * @param[in] scheduler Unused.
+ * @param[in] the_thread Unused.
* @param[in] deadline Unused.
*/
void _Scheduler_default_Release_job(
- Thread_Control *thread,
- uint32_t deadline
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread,
+ uint32_t deadline
);
/**
@@ -170,18 +187,22 @@ void _Scheduler_default_Release_job(
* each executing thread.
*
* This routine is invoked as part of processing each clock tick.
+ *
+ * @param[in] scheduler The scheduler.
*/
-void _Scheduler_default_Tick( void );
+void _Scheduler_default_Tick( Scheduler_Control *scheduler );
/**
- * @brief Unblocks the thread.
+ * @brief Starts an idle thread.
*
- * @param[in,out] thread An idle thread.
- * @param[in] processor This parameter is unused.
+ * @param[in] scheduler The scheduler.
+ * @param[in] the_thread An idle thread.
+ * @param[in] cpu This parameter is unused.
*/
void _Scheduler_default_Start_idle(
- Thread_Control *thread,
- Per_CPU_Control *processor
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread,
+ Per_CPU_Control *cpu
);
/*
diff --git a/cpukit/score/include/rtems/score/schedulercbs.h b/cpukit/score/include/rtems/score/schedulercbs.h
index d4ed7ef..f654225 100644
--- a/cpukit/score/include/rtems/score/schedulercbs.h
+++ b/cpukit/score/include/rtems/score/schedulercbs.h
@@ -148,6 +148,7 @@ extern Scheduler_CBS_Server **_Scheduler_CBS_Server_list;
* @note This has to be asessed as missed deadline of the current job.
*/
void _Scheduler_CBS_Unblock(
+ Scheduler_Control *scheduler,
Thread_Control *the_thread
);
@@ -164,8 +165,9 @@ void _Scheduler_CBS_Unblock(
*/
void _Scheduler_CBS_Release_job (
- Thread_Control *the_thread,
- uint32_t length
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread,
+ uint32_t length
);
/**
@@ -336,7 +338,8 @@ void _Scheduler_CBS_Budget_callout(
* management memory for.
*/
void *_Scheduler_CBS_Allocate(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
);
#ifdef __cplusplus
}
diff --git a/cpukit/score/include/rtems/score/scheduleredf.h b/cpukit/score/include/rtems/score/scheduleredf.h
index 2d5f537..16d46a4 100644
--- a/cpukit/score/include/rtems/score/scheduleredf.h
+++ b/cpukit/score/include/rtems/score/scheduleredf.h
@@ -121,6 +121,7 @@ void _Scheduler_EDF_Initialize( void );
* @param[in] the_thread is the thread to be blocked.
*/
void _Scheduler_EDF_Block(
+ Scheduler_Control *scheduler,
Thread_Control *the_thread
);
@@ -131,7 +132,10 @@ void _Scheduler_EDF_Block(
* This kernel routine sets the heir thread to be the next ready thread
* in the rbtree ready queue.
*/
-void _Scheduler_EDF_Schedule( Thread_Control *thread );
+void _Scheduler_EDF_Schedule(
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
+);
/**
* @brief Allocates EDF specific information of @a the_thread.
@@ -142,7 +146,8 @@ void _Scheduler_EDF_Schedule( Thread_Control *thread );
* management memory for.
*/
void *_Scheduler_EDF_Allocate(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
);
/**
@@ -154,7 +159,8 @@ void *_Scheduler_EDF_Allocate(
* will be deallocated.
*/
void _Scheduler_EDF_Free(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
);
/**
@@ -166,7 +172,8 @@ void _Scheduler_EDF_Free(
* structure updated.
*/
void _Scheduler_EDF_Update(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
);
/**
@@ -179,6 +186,7 @@ void _Scheduler_EDF_Update(
* @param[in] the_thread will be unblocked.
*/
void _Scheduler_EDF_Unblock(
+ Scheduler_Control *scheduler,
Thread_Control *the_thread
);
@@ -197,7 +205,10 @@ void _Scheduler_EDF_Unblock(
*
* @param[in,out] thread The yielding thread.
*/
-void _Scheduler_EDF_Yield( Thread_Control *thread );
+void _Scheduler_EDF_Yield(
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
+);
/**
* @brief Put @a the_thread to the rbtree ready queue.
@@ -207,6 +218,7 @@ void _Scheduler_EDF_Yield( Thread_Control *thread );
* @param[in] the_thread will be enqueued to the ready queue.
*/
void _Scheduler_EDF_Enqueue(
+ Scheduler_Control *scheduler,
Thread_Control *the_thread
);
@@ -219,6 +231,7 @@ void _Scheduler_EDF_Enqueue(
* @param[in] the_thread will be enqueued to the ready queue.
*/
void _Scheduler_EDF_Enqueue_first(
+ Scheduler_Control *scheduler,
Thread_Control *the_thread
);
@@ -232,7 +245,8 @@ void _Scheduler_EDF_Enqueue_first(
* @param[in] the_thread will be extracted from the ready set.
*/
void _Scheduler_EDF_Extract(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
);
/**
@@ -261,8 +275,9 @@ int _Scheduler_EDF_Priority_compare (
* has to be suspended.
*/
void _Scheduler_EDF_Release_job (
- Thread_Control *the_thread,
- uint32_t deadline
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread,
+ uint32_t deadline
);
#ifdef __cplusplus
diff --git a/cpukit/score/include/rtems/score/scheduleredfimpl.h b/cpukit/score/include/rtems/score/scheduleredfimpl.h
index aa1d215..bfeff63 100644
--- a/cpukit/score/include/rtems/score/scheduleredfimpl.h
+++ b/cpukit/score/include/rtems/score/scheduleredfimpl.h
@@ -31,24 +31,26 @@ extern "C" {
* @{
*/
-RTEMS_INLINE_ROUTINE Scheduler_EDF_Control *_Scheduler_EDF_Instance( void )
+RTEMS_INLINE_ROUTINE Scheduler_EDF_Control *
+ _Scheduler_EDF_Self_from_base( Scheduler_Control *scheduler_base )
{
- return _Scheduler.information;
+ return (Scheduler_EDF_Control *) scheduler_base->information;
}
RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Schedule_body(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler_base,
+ Thread_Control *the_thread,
bool force_dispatch
)
{
Scheduler_EDF_Control *scheduler =
- _Scheduler_EDF_Instance();
+ _Scheduler_EDF_Self_from_base( scheduler_base );
RBTree_Node *first = _RBTree_First(&scheduler->Ready, RBT_LEFT);
Scheduler_EDF_Per_thread *sched_info =
_RBTree_Container_of(first, Scheduler_EDF_Per_thread, Node);
Thread_Control *heir = (Thread_Control *) sched_info->thread;
- ( void ) thread;
+ ( void ) the_thread;
_Scheduler_Update_heir( heir, force_dispatch );
}
diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h b/cpukit/score/include/rtems/score/schedulerimpl.h
index a031715..9ffe1a6 100644
--- a/cpukit/score/include/rtems/score/schedulerimpl.h
+++ b/cpukit/score/include/rtems/score/schedulerimpl.h
@@ -61,11 +61,14 @@ void _Scheduler_Handler_initialization( void );
* This kernel routine implements the scheduling decision logic for
* the scheduler. It does NOT dispatch.
*
- * @param[in] thread The thread which state changed previously.
+ * @param[in] the_thread The thread which state changed previously.
*/
-RTEMS_INLINE_ROUTINE void _Scheduler_Schedule( Thread_Control *thread )
+RTEMS_INLINE_ROUTINE void _Scheduler_Schedule(
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
+)
{
- _Scheduler.Operations.schedule( thread );
+ ( *scheduler->Operations.schedule )( scheduler, the_thread );
}
/**
@@ -74,13 +77,14 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Schedule( Thread_Control *thread )
* This routine is invoked when a thread wishes to voluntarily transfer control
* of the processor to another thread.
*
- * @param[in] thread The yielding thread.
+ * @param[in] the_thread The yielding thread.
*/
RTEMS_INLINE_ROUTINE void _Scheduler_Yield(
- Thread_Control *thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
)
{
- ( *_Scheduler.Operations.yield )( thread );
+ ( *scheduler->Operations.yield )( scheduler, the_thread );
}
/**
@@ -92,10 +96,11 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Yield(
* including the selection of a new heir thread.
*/
RTEMS_INLINE_ROUTINE void _Scheduler_Block(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
)
{
- _Scheduler.Operations.block( the_thread );
+ ( *scheduler->Operations.block )( scheduler, the_thread );
}
/**
@@ -107,10 +112,11 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Block(
* scheduling variables, for example the heir thread.
*/
RTEMS_INLINE_ROUTINE void _Scheduler_Unblock(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
)
{
- _Scheduler.Operations.unblock( the_thread );
+ ( *scheduler->Operations.unblock )( scheduler, the_thread );
}
/**
@@ -119,10 +125,11 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Unblock(
* This routine allocates @a the_thread->scheduler
*/
RTEMS_INLINE_ROUTINE void* _Scheduler_Allocate(
+ Scheduler_Control *scheduler,
Thread_Control *the_thread
)
{
- return _Scheduler.Operations.allocate( the_thread );
+ return ( *scheduler->Operations.allocate )( scheduler, the_thread );
}
/**
@@ -131,10 +138,11 @@ RTEMS_INLINE_ROUTINE void* _Scheduler_Allocate(
* This routine frees @a the_thread->scheduler
*/
RTEMS_INLINE_ROUTINE void _Scheduler_Free(
+ Scheduler_Control *scheduler,
Thread_Control *the_thread
)
{
- _Scheduler.Operations.free( the_thread );
+ ( *scheduler->Operations.free )( scheduler, the_thread );
}
/**
@@ -143,10 +151,11 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Free(
* This routine updates @a the_thread->scheduler
*/
RTEMS_INLINE_ROUTINE void _Scheduler_Update(
+ Scheduler_Control *scheduler,
Thread_Control *the_thread
)
{
- _Scheduler.Operations.update( the_thread );
+ ( *scheduler->Operations.update )( scheduler, the_thread );
}
/**
@@ -155,10 +164,11 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Update(
* This routine enqueue @a the_thread->scheduler
*/
RTEMS_INLINE_ROUTINE void _Scheduler_Enqueue(
+ Scheduler_Control *scheduler,
Thread_Control *the_thread
)
{
- _Scheduler.Operations.enqueue( the_thread );
+ ( *scheduler->Operations.enqueue )( scheduler, the_thread );
}
/**
@@ -167,10 +177,11 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Enqueue(
* This routine enqueue_first @a the_thread->scheduler
*/
RTEMS_INLINE_ROUTINE void _Scheduler_Enqueue_first(
+ Scheduler_Control *scheduler,
Thread_Control *the_thread
)
{
- _Scheduler.Operations.enqueue_first( the_thread );
+ ( *scheduler->Operations.enqueue_first )( scheduler, the_thread );
}
/**
@@ -179,10 +190,11 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Enqueue_first(
* This routine extract @a the_thread->scheduler
*/
RTEMS_INLINE_ROUTINE void _Scheduler_Extract(
+ Scheduler_Control *scheduler,
Thread_Control *the_thread
)
{
- _Scheduler.Operations.extract( the_thread );
+ ( *scheduler->Operations.extract )( scheduler, the_thread );
}
/**
@@ -191,11 +203,12 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Extract(
* This routine compares two priorities.
*/
RTEMS_INLINE_ROUTINE int _Scheduler_Priority_compare(
+ Scheduler_Control *scheduler,
Priority_Control p1,
Priority_Control p2
)
{
- return _Scheduler.Operations.priority_compare(p1, p2);
+ return ( *scheduler->Operations.priority_compare )( p1, p2 );
}
/**
@@ -204,11 +217,12 @@ RTEMS_INLINE_ROUTINE int _Scheduler_Priority_compare(
* 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_Control *scheduler,
+ Thread_Control *the_thread,
+ uint32_t length
)
{
- _Scheduler.Operations.release_job(the_thread, length);
+ ( *scheduler->Operations.release_job )( scheduler, the_thread, length );
}
/**
@@ -219,25 +233,26 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Release_job(
* scheduler which support standard RTEMS features, this includes
* time-slicing management.
*/
-RTEMS_INLINE_ROUTINE void _Scheduler_Tick( void )
+RTEMS_INLINE_ROUTINE void _Scheduler_Tick( Scheduler_Control *scheduler )
{
- _Scheduler.Operations.tick();
+ ( *scheduler->Operations.tick )( scheduler );
}
/**
* @brief Starts the idle thread for a particular processor.
*
- * @param[in,out] thread The idle thread for the processor.
+ * @param[in,out] the_thread The idle thread for the processor.
* @parma[in,out] processor The processor for the idle thread.
*
* @see _Thread_Create_idle().
*/
RTEMS_INLINE_ROUTINE void _Scheduler_Start_idle(
- Thread_Control *thread,
- Per_CPU_Control *processor
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread,
+ Per_CPU_Control *cpu
)
{
- ( *_Scheduler.Operations.start_idle )( thread, processor );
+ ( *scheduler->Operations.start_idle )( scheduler, the_thread, cpu );
}
RTEMS_INLINE_ROUTINE void _Scheduler_Update_heir(
@@ -254,17 +269,18 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Update_heir(
}
RTEMS_INLINE_ROUTINE void _Scheduler_Generic_block(
- void ( *extract )( Thread_Control *thread ),
- void ( *schedule )( Thread_Control *thread, bool force_dispatch ),
- Thread_Control *thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread,
+ void ( *extract )( Scheduler_Control *, Thread_Control * ),
+ void ( *schedule )( Scheduler_Control *, Thread_Control *, bool )
)
{
- ( *extract )( thread );
+ ( *extract )( scheduler, the_thread );
/* TODO: flash critical section? */
- if ( _Thread_Is_executing( thread ) || _Thread_Is_heir( thread ) ) {
- ( *schedule )( thread, true );
+ if ( _Thread_Is_executing( the_thread ) || _Thread_Is_heir( the_thread ) ) {
+ ( *schedule )( scheduler, the_thread, true );
}
}
@@ -273,11 +289,12 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Generic_block(
* intuitive sense of priority.
*/
RTEMS_INLINE_ROUTINE bool _Scheduler_Is_priority_lower_than(
- Priority_Control p1,
- Priority_Control p2
+ Scheduler_Control *scheduler,
+ Priority_Control p1,
+ Priority_Control p2
)
{
- return _Scheduler_Priority_compare( p1, p2 ) < 0;
+ return _Scheduler_Priority_compare( scheduler, p1, p2 ) < 0;
}
/**
@@ -285,11 +302,12 @@ RTEMS_INLINE_ROUTINE bool _Scheduler_Is_priority_lower_than(
* intuitive sense of priority.
*/
RTEMS_INLINE_ROUTINE bool _Scheduler_Is_priority_higher_than(
- Priority_Control p1,
- Priority_Control p2
+ Scheduler_Control *scheduler,
+ Priority_Control p1,
+ Priority_Control p2
)
{
- return _Scheduler_Priority_compare( p1, p2 ) > 0;
+ return _Scheduler_Priority_compare( scheduler, p1, p2 ) > 0;
}
/**
@@ -297,11 +315,12 @@ RTEMS_INLINE_ROUTINE bool _Scheduler_Is_priority_higher_than(
* in the intuitive sense of priority.
*/
RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Highest_priority_of_two(
- Priority_Control p1,
- Priority_Control p2
+ Scheduler_Control *scheduler,
+ Priority_Control p1,
+ Priority_Control p2
)
{
- return _Scheduler_Is_priority_higher_than( p1, p2 ) ? p1 : p2;
+ return _Scheduler_Is_priority_higher_than( scheduler, p1, p2 ) ? p1 : p2;
}
/**
@@ -309,13 +328,14 @@ RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Highest_priority_of_two(
* current priority of the thread in the intuitive sense of priority.
*/
RTEMS_INLINE_ROUTINE void _Scheduler_Set_priority_if_higher(
- Thread_Control *the_thread,
- Priority_Control priority
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread,
+ Priority_Control priority
)
{
Priority_Control current = the_thread->current_priority;
- if ( _Scheduler_Is_priority_higher_than( priority, current ) ) {
+ if ( _Scheduler_Is_priority_higher_than( scheduler, priority, current ) ) {
_Thread_Set_priority( the_thread, priority );
}
}
@@ -325,18 +345,28 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Set_priority_if_higher(
* current priority of the thread in the intuitive sense of priority.
*/
RTEMS_INLINE_ROUTINE void _Scheduler_Change_priority_if_higher(
- Thread_Control *the_thread,
- Priority_Control priority,
- bool prepend_it
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread,
+ Priority_Control priority,
+ bool prepend_it
)
{
Priority_Control current = the_thread->current_priority;
- if ( _Scheduler_Is_priority_higher_than( priority, current ) ) {
+ if ( _Scheduler_Is_priority_higher_than( scheduler, priority, current ) ) {
_Thread_Change_priority( the_thread, priority, prepend_it );
}
}
+RTEMS_INLINE_ROUTINE Scheduler_Control *_Scheduler_Get(
+ Thread_Control *the_thread
+)
+{
+ (void) the_thread;
+
+ return &_Scheduler;
+}
+
/** @} */
#ifdef __cplusplus
diff --git a/cpukit/score/include/rtems/score/schedulerpriority.h b/cpukit/score/include/rtems/score/schedulerpriority.h
index 40e784b..7dd3a75 100644
--- a/cpukit/score/include/rtems/score/schedulerpriority.h
+++ b/cpukit/score/include/rtems/score/schedulerpriority.h
@@ -96,6 +96,7 @@ void _Scheduler_priority_Initialize(void);
* @param[in] the_thread is the thread to be blocked
*/
void _Scheduler_priority_Block(
+ Scheduler_Control *scheduler,
Thread_Control *the_thread
);
@@ -105,7 +106,10 @@ void _Scheduler_priority_Block(
* This kernel routine sets the heir thread to be the next ready thread
* by invoking the_scheduler->ready_queue->operations->first().
*/
-void _Scheduler_priority_Schedule( Thread_Control *thread );
+void _Scheduler_priority_Schedule(
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
+);
/**
* @brief Allocates @a the_thread->scheduler.
@@ -116,7 +120,8 @@ void _Scheduler_priority_Schedule( Thread_Control *thread );
* management memory for
*/
void * _Scheduler_priority_Allocate(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
);
/**
@@ -128,7 +133,8 @@ void * _Scheduler_priority_Allocate(
* will be deallocated.
*/
void _Scheduler_priority_Free(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
);
/**
@@ -140,7 +146,8 @@ void _Scheduler_priority_Free(
* structure updated.
*/
void _Scheduler_priority_Update(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
);
/**
@@ -153,6 +160,7 @@ void _Scheduler_priority_Update(
* @param[in] the_thread will be unblocked
*/
void _Scheduler_priority_Unblock(
+ Scheduler_Control *scheduler,
Thread_Control *the_thread
);
@@ -175,7 +183,10 @@ void _Scheduler_priority_Unblock(
*
* @param[in,out] thread The yielding thread.
*/
-void _Scheduler_priority_Yield( Thread_Control *thread );
+void _Scheduler_priority_Yield(
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
+);
/**
* @brief Puts @a the_thread on to the priority-based ready queue.
@@ -185,6 +196,7 @@ void _Scheduler_priority_Yield( Thread_Control *thread );
* @param[in] the_thread will be enqueued at the TAIL of its priority.
*/
void _Scheduler_priority_Enqueue(
+ Scheduler_Control *scheduler,
Thread_Control *the_thread
);
@@ -198,6 +210,7 @@ void _Scheduler_priority_Enqueue(
* @param[in] the_thread will be enqueued at the HEAD of its priority.
*/
void _Scheduler_priority_Enqueue_first(
+ Scheduler_Control *scheduler,
Thread_Control *the_thread
);
@@ -210,7 +223,8 @@ void _Scheduler_priority_Enqueue_first(
* @param[in] the_thread will be extracted from the ready set.
*/
void _Scheduler_priority_Extract(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
);
/**
@@ -219,8 +233,8 @@ void _Scheduler_priority_Extract(
* This routine compares two priorities.
*/
int _Scheduler_priority_Priority_compare(
- Priority_Control p1,
- Priority_Control p2
+ Priority_Control p1,
+ Priority_Control p2
);
/**@}*/
diff --git a/cpukit/score/include/rtems/score/schedulerpriorityimpl.h b/cpukit/score/include/rtems/score/schedulerpriorityimpl.h
index ebcc3f1..7861df5 100644
--- a/cpukit/score/include/rtems/score/schedulerpriorityimpl.h
+++ b/cpukit/score/include/rtems/score/schedulerpriorityimpl.h
@@ -36,9 +36,9 @@ extern "C" {
/**@{**/
RTEMS_INLINE_ROUTINE Scheduler_priority_Control *
- _Scheduler_priority_Instance( void )
+ _Scheduler_priority_Self_from_base( Scheduler_Control *scheduler_base )
{
- return _Scheduler.information;
+ return (Scheduler_priority_Control *) scheduler_base->information;
}
/**
@@ -134,10 +134,12 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_extract(
}
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Extract_body(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler_base,
+ Thread_Control *the_thread
)
{
- Scheduler_priority_Control *scheduler = _Scheduler_priority_Instance();
+ Scheduler_priority_Control *scheduler =
+ _Scheduler_priority_Self_from_base( scheduler_base );
_Scheduler_priority_Ready_queue_extract( the_thread, &scheduler->Bit_map );
}
@@ -191,17 +193,19 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_requeue(
* for priority-based scheduling.
*/
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Schedule_body(
- Thread_Control *thread,
- bool force_dispatch
+ Scheduler_Control *scheduler_base,
+ Thread_Control *the_thread,
+ bool force_dispatch
)
{
- Scheduler_priority_Control *scheduler = _Scheduler_priority_Instance();
+ Scheduler_priority_Control *scheduler =
+ _Scheduler_priority_Self_from_base( scheduler_base );
Thread_Control *heir = _Scheduler_priority_Ready_queue_first(
&scheduler->Bit_map,
&scheduler->Ready[ 0 ]
);
- ( void ) thread;
+ ( void ) the_thread;
_Scheduler_Update_heir( heir, force_dispatch );
}
diff --git a/cpukit/score/include/rtems/score/schedulerprioritysmp.h b/cpukit/score/include/rtems/score/schedulerprioritysmp.h
index f30b706..8f3f4b7 100644
--- a/cpukit/score/include/rtems/score/schedulerprioritysmp.h
+++ b/cpukit/score/include/rtems/score/schedulerprioritysmp.h
@@ -71,21 +71,43 @@ extern "C" {
void _Scheduler_priority_SMP_Initialize( void );
-void _Scheduler_priority_SMP_Schedule( Thread_Control *thread );
+void _Scheduler_priority_SMP_Schedule(
+ Scheduler_Control *base,
+ Thread_Control *thread
+);
-void _Scheduler_priority_SMP_Block( Thread_Control *thread );
+void _Scheduler_priority_SMP_Block(
+ Scheduler_Control *base,
+ Thread_Control *thread
+);
-void _Scheduler_priority_SMP_Update( Thread_Control *thread );
+void _Scheduler_priority_SMP_Update(
+ Scheduler_Control *base,
+ Thread_Control *thread
+);
-void _Scheduler_priority_SMP_Enqueue_fifo( Thread_Control *thread );
+void _Scheduler_priority_SMP_Enqueue_fifo(
+ Scheduler_Control *base,
+ Thread_Control *thread
+);
-void _Scheduler_priority_SMP_Enqueue_lifo( Thread_Control *thread );
+void _Scheduler_priority_SMP_Enqueue_lifo(
+ Scheduler_Control *base,
+ Thread_Control *thread
+);
-void _Scheduler_priority_SMP_Extract( Thread_Control *thread );
+void _Scheduler_priority_SMP_Extract(
+ Scheduler_Control *base,
+ Thread_Control *thread
+);
-void _Scheduler_priority_SMP_Yield( Thread_Control *thread );
+void _Scheduler_priority_SMP_Yield(
+ Scheduler_Control *base,
+ Thread_Control *thread
+);
void _Scheduler_priority_SMP_Start_idle(
+ Scheduler_Control *base,
Thread_Control *thread,
Per_CPU_Control *cpu
);
diff --git a/cpukit/score/include/rtems/score/schedulersimple.h b/cpukit/score/include/rtems/score/schedulersimple.h
index 54b0801..889c5a7 100644
--- a/cpukit/score/include/rtems/score/schedulersimple.h
+++ b/cpukit/score/include/rtems/score/schedulersimple.h
@@ -76,7 +76,10 @@ void _Scheduler_simple_Initialize( void );
* on the ready queue by getting the first node in the scheduler
* information.
*/
-void _Scheduler_simple_Schedule( Thread_Control *thread );
+void _Scheduler_simple_Schedule(
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
+);
/**
* @brief Invoked when a thread wishes to voluntarily
@@ -94,7 +97,10 @@ void _Scheduler_simple_Schedule( Thread_Control *thread );
*
* @param[in,out] thread The yielding thread.
*/
-void _Scheduler_simple_Yield( Thread_Control *thread );
+void _Scheduler_simple_Yield(
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
+);
/**
* @brief Remove a simple-priority-based thread from the queue.
@@ -107,7 +113,8 @@ void _Scheduler_simple_Yield( Thread_Control *thread );
* @param[in] the_thread is the thread that is to be blocked
*/
void _Scheduler_simple_Block(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
);
/**
@@ -120,7 +127,8 @@ void _Scheduler_simple_Block(
* @param[in] the_thread is the thread that is to be unblocked
*/
void _Scheduler_simple_Unblock(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
);
/**
@@ -132,7 +140,8 @@ void _Scheduler_simple_Unblock(
* @param[in] the_thread is the thread to be blocked
*/
void _Scheduler_simple_Extract(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
);
/**
@@ -143,7 +152,8 @@ void _Scheduler_simple_Extract(
* @param[in] the_thread is the thread to be enqueued
*/
void _Scheduler_simple_Enqueue(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
);
/**
@@ -156,7 +166,8 @@ void _Scheduler_simple_Enqueue(
* @param[in] the_thread is the thread to be blocked
*/
void _Scheduler_simple_Enqueue_first(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
);
/**
@@ -168,6 +179,7 @@ void _Scheduler_simple_Enqueue_first(
* @param[in] the_thread - pointer to a thread control block
*/
void _Scheduler_simple_Ready_queue_enqueue(
+ Scheduler_Control *scheduler,
Thread_Control *the_thread
);
@@ -181,6 +193,7 @@ void _Scheduler_simple_Ready_queue_enqueue(
* @param[in] the_thread - pointer to a thread control block
*/
void _Scheduler_simple_Ready_queue_enqueue_first(
+ Scheduler_Control *scheduler,
Thread_Control *the_thread
);
diff --git a/cpukit/score/include/rtems/score/schedulersimpleimpl.h b/cpukit/score/include/rtems/score/schedulersimpleimpl.h
index c51c6c3..8ad142f 100644
--- a/cpukit/score/include/rtems/score/schedulersimpleimpl.h
+++ b/cpukit/score/include/rtems/score/schedulersimpleimpl.h
@@ -32,9 +32,10 @@ extern "C" {
*/
/**@{**/
-RTEMS_INLINE_ROUTINE Scheduler_simple_Control *_Scheduler_simple_Instance( void )
+RTEMS_INLINE_ROUTINE Scheduler_simple_Control *
+ _Scheduler_simple_Self_from_base( Scheduler_Control *scheduler_base )
{
- return _Scheduler.information;
+ return (Scheduler_simple_Control *) scheduler_base->information;
}
/**
@@ -44,7 +45,7 @@ RTEMS_INLINE_ROUTINE Scheduler_simple_Control *_Scheduler_simple_Instance( void
* @param[in] the_thread is the thread to be blocked
*/
RTEMS_INLINE_ROUTINE void _Scheduler_simple_Ready_queue_requeue(
- Scheduler_Control *the_ready_queue,
+ Scheduler_Control *scheduler,
Thread_Control *the_thread
)
{
@@ -52,7 +53,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_simple_Ready_queue_requeue(
_Chain_Extract_unprotected( &the_thread->Object.Node );
/* enqueue */
- _Scheduler_simple_Ready_queue_enqueue( the_thread );
+ _Scheduler_simple_Ready_queue_enqueue( scheduler, the_thread );
}
RTEMS_INLINE_ROUTINE bool _Scheduler_simple_Insert_priority_lifo_order(
@@ -102,14 +103,16 @@ RTEMS_INLINE_ROUTINE void _Scheduler_simple_Insert_priority_fifo(
}
RTEMS_INLINE_ROUTINE void _Scheduler_simple_Schedule_body(
- Thread_Control *thread,
- bool force_dispatch
+ Scheduler_Control *scheduler_base,
+ Thread_Control *the_thread,
+ bool force_dispatch
)
{
- Scheduler_simple_Control *scheduler = _Scheduler_simple_Instance();
+ Scheduler_simple_Control *scheduler =
+ _Scheduler_simple_Self_from_base( scheduler_base );
Thread_Control *heir = (Thread_Control *) _Chain_First( &scheduler->Ready );
- ( void ) thread;
+ ( void ) the_thread;
_Scheduler_Update_heir( heir, force_dispatch );
}
diff --git a/cpukit/score/include/rtems/score/schedulersimplesmp.h b/cpukit/score/include/rtems/score/schedulersimplesmp.h
index 01ebf03..01acef9 100644
--- a/cpukit/score/include/rtems/score/schedulersimplesmp.h
+++ b/cpukit/score/include/rtems/score/schedulersimplesmp.h
@@ -73,19 +73,38 @@ extern "C" {
void _Scheduler_simple_smp_Initialize( void );
-void _Scheduler_simple_smp_Block( Thread_Control *thread );
+void _Scheduler_simple_smp_Block(
+ Scheduler_Control *base,
+ Thread_Control *thread
+);
-void _Scheduler_simple_smp_Enqueue_priority_fifo( Thread_Control *thread );
+void _Scheduler_simple_smp_Enqueue_priority_fifo(
+ Scheduler_Control *base,
+ Thread_Control *thread
+);
-void _Scheduler_simple_smp_Enqueue_priority_lifo( Thread_Control *thread );
+void _Scheduler_simple_smp_Enqueue_priority_lifo(
+ Scheduler_Control *base,
+ Thread_Control *thread
+);
-void _Scheduler_simple_smp_Extract( Thread_Control *thread );
+void _Scheduler_simple_smp_Extract(
+ Scheduler_Control *base,
+ Thread_Control *thread
+);
-void _Scheduler_simple_smp_Yield( Thread_Control *thread );
+void _Scheduler_simple_smp_Yield(
+ Scheduler_Control *base,
+ Thread_Control *thread
+);
-void _Scheduler_simple_smp_Schedule( Thread_Control *thread );
+void _Scheduler_simple_smp_Schedule(
+ Scheduler_Control *base,
+ Thread_Control *thread
+);
void _Scheduler_simple_smp_Start_idle(
+ Scheduler_Control *base,
Thread_Control *thread,
Per_CPU_Control *cpu
);
diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h
index 2ac8344..6d4ca9f 100644
--- a/cpukit/score/include/rtems/score/threadimpl.h
+++ b/cpukit/score/include/rtems/score/threadimpl.h
@@ -176,7 +176,7 @@ bool _Thread_Initialize(
* @param entry_point
* @param pointer_argument
* @param numeric_argument
- * @param[in,out] processor The processor if used to start an idle thread
+ * @param[in,out] cpu The processor if used to start an idle thread
* during system initialization. Must be set to @c NULL to start a normal
* thread.
*/
@@ -186,7 +186,7 @@ bool _Thread_Start(
void *entry_point,
void *pointer_argument,
Thread_Entry_numeric_type numeric_argument,
- Per_CPU_Control *processor
+ Per_CPU_Control *cpu
);
bool _Thread_Restart(
diff --git a/cpukit/score/src/coremutexseize.c b/cpukit/score/src/coremutexseize.c
index fe6ee5e..2f9c8da 100644
--- a/cpukit/score/src/coremutexseize.c
+++ b/cpukit/score/src/coremutexseize.c
@@ -53,8 +53,11 @@ void _CORE_mutex_Seize_interrupt_blocking(
{
if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) ) {
+ Thread_Control *holder = the_mutex->holder;
+
_Scheduler_Change_priority_if_higher(
- the_mutex->holder,
+ _Scheduler_Get( holder ),
+ holder,
executing->current_priority,
false
);
diff --git a/cpukit/score/src/schedulercbsallocate.c b/cpukit/score/src/schedulercbsallocate.c
index a1ac577..908ea90 100644
--- a/cpukit/score/src/schedulercbsallocate.c
+++ b/cpukit/score/src/schedulercbsallocate.c
@@ -26,12 +26,15 @@
#include <rtems/score/wkspace.h>
void *_Scheduler_CBS_Allocate(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
)
{
void *sched;
Scheduler_CBS_Per_thread *schinfo;
+ (void) scheduler;
+
sched = _Workspace_Allocate(sizeof(Scheduler_CBS_Per_thread));
if ( sched ) {
the_thread->scheduler_info = sched;
diff --git a/cpukit/score/src/schedulercbsreleasejob.c b/cpukit/score/src/schedulercbsreleasejob.c
index a73dbb5..f4fc1a8 100644
--- a/cpukit/score/src/schedulercbsreleasejob.c
+++ b/cpukit/score/src/schedulercbsreleasejob.c
@@ -24,6 +24,7 @@
#include <rtems/score/watchdogimpl.h>
void _Scheduler_CBS_Release_job(
+ Scheduler_Control *scheduler,
Thread_Control *the_thread,
uint32_t deadline
)
diff --git a/cpukit/score/src/schedulercbsunblock.c b/cpukit/score/src/schedulercbsunblock.c
index 54030e4..11465f2 100644
--- a/cpukit/score/src/schedulercbsunblock.c
+++ b/cpukit/score/src/schedulercbsunblock.c
@@ -25,6 +25,7 @@
#include <rtems/score/watchdogimpl.h>
void _Scheduler_CBS_Unblock(
+ Scheduler_Control *scheduler,
Thread_Control *the_thread
)
{
@@ -32,7 +33,7 @@ void _Scheduler_CBS_Unblock(
Scheduler_CBS_Server *serv_info;
Priority_Control new_priority;
- _Scheduler_EDF_Enqueue(the_thread);
+ _Scheduler_EDF_Enqueue( scheduler, the_thread );
/* TODO: flash critical section? */
sched_info = (Scheduler_CBS_Per_thread *) the_thread->scheduler_info;
@@ -73,8 +74,13 @@ void _Scheduler_CBS_Unblock(
* Even if the thread isn't preemptible, if the new heir is
* a pseudo-ISR system task, we need to do a context switch.
*/
- if ( _Scheduler_Is_priority_higher_than( the_thread->current_priority,
- _Thread_Heir->current_priority)) {
+ if (
+ _Scheduler_Is_priority_higher_than(
+ scheduler,
+ the_thread->current_priority,
+ _Thread_Heir->current_priority
+ )
+ ) {
_Thread_Heir = the_thread;
if ( _Thread_Executing->is_preemptible ||
the_thread->current_priority == 0 )
diff --git a/cpukit/score/src/schedulerdefaultallocatefree.c b/cpukit/score/src/schedulerdefaultallocatefree.c
index a3be5a3..7ffade2 100644
--- a/cpukit/score/src/schedulerdefaultallocatefree.c
+++ b/cpukit/score/src/schedulerdefaultallocatefree.c
@@ -22,17 +22,21 @@
#include <rtems/score/scheduler.h>
void *_Scheduler_default_Allocate(
- Thread_Control *thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
)
{
- ( void ) thread;
+ ( void ) scheduler;
+ ( void ) the_thread;
return ( void * )-1; /* maybe pick an appropriate poison value */
}
void _Scheduler_default_Free(
- Thread_Control *thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
)
{
- ( void ) thread;
+ ( void ) scheduler;
+ ( void ) the_thread;
}
diff --git a/cpukit/score/src/schedulerdefaultreleasejob.c b/cpukit/score/src/schedulerdefaultreleasejob.c
index e029aac..10ebf84 100644
--- a/cpukit/score/src/schedulerdefaultreleasejob.c
+++ b/cpukit/score/src/schedulerdefaultreleasejob.c
@@ -22,10 +22,12 @@
#include <rtems/score/scheduler.h>
void _Scheduler_default_Release_job(
- Thread_Control *thread,
- uint32_t deadline
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread,
+ uint32_t deadline
)
{
- ( void ) thread;
+ ( void ) scheduler;
+ ( void ) the_thread;
( void ) deadline;
}
diff --git a/cpukit/score/src/schedulerdefaultstartidle.c b/cpukit/score/src/schedulerdefaultstartidle.c
index 09fab26..caddb7f 100644
--- a/cpukit/score/src/schedulerdefaultstartidle.c
+++ b/cpukit/score/src/schedulerdefaultstartidle.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 embedded brains GmbH
+ * Copyright (c) 2013-2014 embedded brains GmbH
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
@@ -13,10 +13,11 @@
#include <rtems/score/schedulerimpl.h>
void _Scheduler_default_Start_idle(
- Thread_Control *thread,
- Per_CPU_Control *processor
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread,
+ Per_CPU_Control *cpu
)
{
- (void) processor;
- _Scheduler_Unblock( thread );
+ (void) cpu;
+ _Scheduler_Unblock( scheduler, the_thread );
}
diff --git a/cpukit/score/src/schedulerdefaulttick.c b/cpukit/score/src/schedulerdefaulttick.c
index 5d9daa1..1976a74 100644
--- a/cpukit/score/src/schedulerdefaulttick.c
+++ b/cpukit/score/src/schedulerdefaulttick.c
@@ -23,7 +23,10 @@
#include <rtems/score/threadimpl.h>
#include <rtems/score/smp.h>
-static void _Scheduler_default_Tick_for_executing( Thread_Control *executing )
+static void _Scheduler_default_Tick_for_executing(
+ Scheduler_Control *scheduler,
+ Thread_Control *executing
+)
{
#ifdef __RTEMS_USE_TICKS_FOR_STATISTICS__
/*
@@ -65,7 +68,7 @@ static void _Scheduler_default_Tick_for_executing( Thread_Control *executing )
* currently executing thread is placed at the rear of the
* FIFO for this priority and a new heir is selected.
*/
- _Scheduler_Yield( executing );
+ _Scheduler_Yield( scheduler, executing );
executing->cpu_time_budget = _Thread_Ticks_per_timeslice;
}
break;
@@ -79,7 +82,7 @@ static void _Scheduler_default_Tick_for_executing( Thread_Control *executing )
}
}
-void _Scheduler_default_Tick( void )
+void _Scheduler_default_Tick( Scheduler_Control *scheduler )
{
uint32_t processor_count = _SMP_Get_processor_count();
uint32_t processor;
@@ -87,6 +90,6 @@ void _Scheduler_default_Tick( void )
for ( processor = 0 ; processor < processor_count ; ++processor ) {
const Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( processor );
- _Scheduler_default_Tick_for_executing( per_cpu->executing );
+ _Scheduler_default_Tick_for_executing( scheduler, per_cpu->executing );
}
}
diff --git a/cpukit/score/src/schedulerdefaultupdate.c b/cpukit/score/src/schedulerdefaultupdate.c
index 44f0c08..c1b62b2 100644
--- a/cpukit/score/src/schedulerdefaultupdate.c
+++ b/cpukit/score/src/schedulerdefaultupdate.c
@@ -22,8 +22,10 @@
#include <rtems/score/scheduler.h>
void _Scheduler_default_Update(
- Thread_Control *thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
)
{
- ( void ) thread;
+ ( void ) scheduler;
+ ( void ) the_thread;
}
diff --git a/cpukit/score/src/scheduleredf.c b/cpukit/score/src/scheduleredf.c
index 14f784f..502a2a1 100644
--- a/cpukit/score/src/scheduleredf.c
+++ b/cpukit/score/src/scheduleredf.c
@@ -38,7 +38,7 @@ static int _Scheduler_EDF_RBTree_compare_function
* This function compares only numbers for the red-black tree,
* but priorities have an opposite sense.
*/
- return (-1)*_Scheduler_Priority_compare(value1, value2);
+ return (-1)*_Scheduler_EDF_Priority_compare(value1, value2);
}
void _Scheduler_EDF_Initialize(void)
diff --git a/cpukit/score/src/scheduleredfallocate.c b/cpukit/score/src/scheduleredfallocate.c
index 6057266..73df5b8 100644
--- a/cpukit/score/src/scheduleredfallocate.c
+++ b/cpukit/score/src/scheduleredfallocate.c
@@ -25,12 +25,15 @@
#include <rtems/score/wkspace.h>
void *_Scheduler_EDF_Allocate(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
)
{
void *sched;
Scheduler_EDF_Per_thread *schinfo;
+ (void) scheduler;
+
sched = _Workspace_Allocate( sizeof(Scheduler_EDF_Per_thread) );
if ( sched ) {
diff --git a/cpukit/score/src/scheduleredfblock.c b/cpukit/score/src/scheduleredfblock.c
index b1eb081..9ea5fc9 100644
--- a/cpukit/score/src/scheduleredfblock.c
+++ b/cpukit/score/src/scheduleredfblock.c
@@ -22,12 +22,14 @@
#include <rtems/score/scheduleredfimpl.h>
void _Scheduler_EDF_Block(
+ Scheduler_Control *scheduler,
Thread_Control *the_thread
)
{
_Scheduler_Generic_block(
+ scheduler,
+ the_thread,
_Scheduler_EDF_Extract,
- _Scheduler_EDF_Schedule_body,
- the_thread
+ _Scheduler_EDF_Schedule_body
);
}
diff --git a/cpukit/score/src/scheduleredfenqueue.c b/cpukit/score/src/scheduleredfenqueue.c
index e7c2e44..2e7365b 100644
--- a/cpukit/score/src/scheduleredfenqueue.c
+++ b/cpukit/score/src/scheduleredfenqueue.c
@@ -21,11 +21,12 @@
#include <rtems/score/scheduleredfimpl.h>
void _Scheduler_EDF_Enqueue(
+ Scheduler_Control *scheduler_base,
Thread_Control *the_thread
)
{
Scheduler_EDF_Control *scheduler =
- _Scheduler_EDF_Instance();
+ _Scheduler_EDF_Self_from_base( scheduler_base );
Scheduler_EDF_Per_thread *sched_info =
(Scheduler_EDF_Per_thread*) the_thread->scheduler_info;
RBTree_Node *node = &(sched_info->Node);
diff --git a/cpukit/score/src/scheduleredfenqueuefirst.c b/cpukit/score/src/scheduleredfenqueuefirst.c
index b3ff0bb..bcf70b4 100644
--- a/cpukit/score/src/scheduleredfenqueuefirst.c
+++ b/cpukit/score/src/scheduleredfenqueuefirst.c
@@ -24,8 +24,9 @@
#include <rtems/score/scheduleredf.h>
void _Scheduler_EDF_Enqueue_first(
+ Scheduler_Control *scheduler,
Thread_Control *the_thread
)
{
- _Scheduler_EDF_Enqueue(the_thread);
+ _Scheduler_EDF_Enqueue( scheduler, the_thread );
}
diff --git a/cpukit/score/src/scheduleredfextract.c b/cpukit/score/src/scheduleredfextract.c
index 0287b4e..ec634e0 100644
--- a/cpukit/score/src/scheduleredfextract.c
+++ b/cpukit/score/src/scheduleredfextract.c
@@ -21,11 +21,12 @@
#include <rtems/score/scheduleredfimpl.h>
void _Scheduler_EDF_Extract(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler_base,
+ Thread_Control *the_thread
)
{
Scheduler_EDF_Control *scheduler =
- _Scheduler_EDF_Instance();
+ _Scheduler_EDF_Self_from_base( scheduler_base );
Scheduler_EDF_Per_thread *sched_info =
(Scheduler_EDF_Per_thread*) the_thread->scheduler_info;
RBTree_Node *node = &(sched_info->Node);
diff --git a/cpukit/score/src/scheduleredffree.c b/cpukit/score/src/scheduleredffree.c
index 6dc2ec3..d9493cc 100644
--- a/cpukit/score/src/scheduleredffree.c
+++ b/cpukit/score/src/scheduleredffree.c
@@ -26,8 +26,11 @@
#include <rtems/score/wkspace.h>
void _Scheduler_EDF_Free(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
)
{
+ (void) scheduler;
+
_Workspace_Free( the_thread->scheduler_info );
}
diff --git a/cpukit/score/src/scheduleredfreleasejob.c b/cpukit/score/src/scheduleredfreleasejob.c
index f1b7d07..37ff2d5 100644
--- a/cpukit/score/src/scheduleredfreleasejob.c
+++ b/cpukit/score/src/scheduleredfreleasejob.c
@@ -23,12 +23,15 @@
#include <rtems/score/watchdogimpl.h>
void _Scheduler_EDF_Release_job(
+ Scheduler_Control *scheduler,
Thread_Control *the_thread,
uint32_t deadline
)
{
Priority_Control new_priority;
+ (void) scheduler;
+
if (deadline) {
/* Initializing or shifting deadline. */
new_priority = (_Watchdog_Ticks_since_boot + deadline)
diff --git a/cpukit/score/src/scheduleredfschedule.c b/cpukit/score/src/scheduleredfschedule.c
index 42ad044..f7acde3 100644
--- a/cpukit/score/src/scheduleredfschedule.c
+++ b/cpukit/score/src/scheduleredfschedule.c
@@ -20,7 +20,10 @@
#include <rtems/score/scheduleredfimpl.h>
-void _Scheduler_EDF_Schedule( Thread_Control *thread )
+void _Scheduler_EDF_Schedule(
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
+)
{
- _Scheduler_EDF_Schedule_body( thread, false );
+ _Scheduler_EDF_Schedule_body( scheduler, the_thread, false );
}
diff --git a/cpukit/score/src/scheduleredfunblock.c b/cpukit/score/src/scheduleredfunblock.c
index 5c2caf8..0640e8c 100644
--- a/cpukit/score/src/scheduleredfunblock.c
+++ b/cpukit/score/src/scheduleredfunblock.c
@@ -23,10 +23,11 @@
#include <rtems/score/thread.h>
void _Scheduler_EDF_Unblock(
+ Scheduler_Control *scheduler,
Thread_Control *the_thread
)
{
- _Scheduler_EDF_Enqueue(the_thread);
+ _Scheduler_EDF_Enqueue( scheduler, the_thread);
/* TODO: flash critical section? */
/*
@@ -42,6 +43,7 @@ void _Scheduler_EDF_Unblock(
* a pseudo-ISR system task, we need to do a context switch.
*/
if ( _Scheduler_Is_priority_lower_than(
+ scheduler,
_Thread_Heir->current_priority,
the_thread->current_priority )) {
_Thread_Heir = the_thread;
diff --git a/cpukit/score/src/scheduleredfupdate.c b/cpukit/score/src/scheduleredfupdate.c
index 79e3277..3069068 100644
--- a/cpukit/score/src/scheduleredfupdate.c
+++ b/cpukit/score/src/scheduleredfupdate.c
@@ -26,12 +26,15 @@
#include <rtems/score/thread.h>
void _Scheduler_EDF_Update(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
)
{
Scheduler_EDF_Per_thread *sched_info =
(Scheduler_EDF_Per_thread*)the_thread->scheduler_info;
+ (void) scheduler;
+
if (sched_info->queue_state == SCHEDULER_EDF_QUEUE_STATE_NEVER_HAS_BEEN) {
/* Shifts the priority to the region of background tasks. */
the_thread->Start.initial_priority |= (SCHEDULER_EDF_PRIO_MSB);
diff --git a/cpukit/score/src/scheduleredfyield.c b/cpukit/score/src/scheduleredfyield.c
index c985684..5b14cad 100644
--- a/cpukit/score/src/scheduleredfyield.c
+++ b/cpukit/score/src/scheduleredfyield.c
@@ -21,14 +21,17 @@
#include <rtems/score/scheduleredfimpl.h>
-void _Scheduler_EDF_Yield( Thread_Control *thread )
+void _Scheduler_EDF_Yield(
+ Scheduler_Control *scheduler_base,
+ Thread_Control *the_thread
+)
{
Scheduler_EDF_Control *scheduler =
- _Scheduler_EDF_Instance();
+ _Scheduler_EDF_Self_from_base( scheduler_base );
ISR_Level level;
Scheduler_EDF_Per_thread *thread_info =
- (Scheduler_EDF_Per_thread *) thread->scheduler_info;
+ (Scheduler_EDF_Per_thread *) the_thread->scheduler_info;
RBTree_Node *thread_node = &(thread_info->Node);
_ISR_Disable( level );
@@ -42,7 +45,7 @@ void _Scheduler_EDF_Yield( Thread_Control *thread )
_ISR_Flash( level );
- _Scheduler_EDF_Schedule_body( thread, false );
+ _Scheduler_EDF_Schedule_body( scheduler_base, the_thread, false );
_ISR_Enable( level );
}
diff --git a/cpukit/score/src/schedulerpriorityallocate.c b/cpukit/score/src/schedulerpriorityallocate.c
index bbf0859..2225d3d 100644
--- a/cpukit/score/src/schedulerpriorityallocate.c
+++ b/cpukit/score/src/schedulerpriorityallocate.c
@@ -23,12 +23,15 @@
#include <rtems/score/wkspace.h>
void *_Scheduler_priority_Allocate (
- Thread_Control *the_thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
)
{
Scheduler_priority_Per_thread *sched_info_of_thread =
_Workspace_Allocate( sizeof( *sched_info_of_thread ) );
+ (void) scheduler;
+
the_thread->scheduler_info = sched_info_of_thread;
return sched_info_of_thread;
diff --git a/cpukit/score/src/schedulerpriorityblock.c b/cpukit/score/src/schedulerpriorityblock.c
index 259d6f0..02d7387 100644
--- a/cpukit/score/src/schedulerpriorityblock.c
+++ b/cpukit/score/src/schedulerpriorityblock.c
@@ -22,11 +22,15 @@
#include <rtems/score/schedulerpriorityimpl.h>
-void _Scheduler_priority_Block( Thread_Control *the_thread )
+void _Scheduler_priority_Block(
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
+)
{
_Scheduler_Generic_block(
+ scheduler,
+ the_thread,
_Scheduler_priority_Extract_body,
- _Scheduler_priority_Schedule_body,
- the_thread
+ _Scheduler_priority_Schedule_body
);
}
diff --git a/cpukit/score/src/schedulerpriorityenqueue.c b/cpukit/score/src/schedulerpriorityenqueue.c
index 54375cd..9d62c2c 100644
--- a/cpukit/score/src/schedulerpriorityenqueue.c
+++ b/cpukit/score/src/schedulerpriorityenqueue.c
@@ -21,10 +21,12 @@
#include <rtems/score/schedulerpriorityimpl.h>
void _Scheduler_priority_Enqueue(
- Thread_Control *the_thread
+ Scheduler_Control *base,
+ Thread_Control *the_thread
)
{
- Scheduler_priority_Control *scheduler = _Scheduler_priority_Instance();
+ Scheduler_priority_Control *scheduler =
+ _Scheduler_priority_Self_from_base( base );
_Scheduler_priority_Ready_queue_enqueue( the_thread, &scheduler->Bit_map );
}
diff --git a/cpukit/score/src/schedulerpriorityenqueuefirst.c b/cpukit/score/src/schedulerpriorityenqueuefirst.c
index 8de06fa..1f0605d 100644
--- a/cpukit/score/src/schedulerpriorityenqueuefirst.c
+++ b/cpukit/score/src/schedulerpriorityenqueuefirst.c
@@ -21,14 +21,16 @@
#include <rtems/score/schedulerpriorityimpl.h>
void _Scheduler_priority_Enqueue_first(
- Thread_Control *the_thread
+ Scheduler_Control *base,
+ Thread_Control *the_thread
)
{
- Scheduler_priority_Control *scheduler = _Scheduler_priority_Instance();
+ Scheduler_priority_Control *self =
+ _Scheduler_priority_Self_from_base( base );
_Scheduler_priority_Ready_queue_enqueue_first(
the_thread,
- &scheduler->Bit_map
+ &self->Bit_map
);
}
diff --git a/cpukit/score/src/schedulerpriorityextract.c b/cpukit/score/src/schedulerpriorityextract.c
index e5888dc..492c537 100644
--- a/cpukit/score/src/schedulerpriorityextract.c
+++ b/cpukit/score/src/schedulerpriorityextract.c
@@ -21,7 +21,10 @@
#include <rtems/score/schedulerpriorityimpl.h>
-void _Scheduler_priority_Extract( Thread_Control *the_thread )
+void _Scheduler_priority_Extract(
+ Scheduler_Control *base,
+ Thread_Control *the_thread
+)
{
- _Scheduler_priority_Extract_body( the_thread );
+ _Scheduler_priority_Extract_body( base, the_thread );
}
diff --git a/cpukit/score/src/schedulerpriorityfree.c b/cpukit/score/src/schedulerpriorityfree.c
index d494bd6..5529f78 100644
--- a/cpukit/score/src/schedulerpriorityfree.c
+++ b/cpukit/score/src/schedulerpriorityfree.c
@@ -25,8 +25,11 @@
#include <rtems/score/wkspace.h>
void _Scheduler_priority_Free (
+ Scheduler_Control *base,
Thread_Control *the_thread
)
{
+ (void) base;
+
_Workspace_Free( the_thread->scheduler_info );
}
diff --git a/cpukit/score/src/schedulerpriorityprioritycompare.c b/cpukit/score/src/schedulerpriorityprioritycompare.c
index 9b5bf84..6879d01 100644
--- a/cpukit/score/src/schedulerpriorityprioritycompare.c
+++ b/cpukit/score/src/schedulerpriorityprioritycompare.c
@@ -21,8 +21,8 @@
#include <rtems/score/schedulerpriorityimpl.h>
int _Scheduler_priority_Priority_compare(
- Priority_Control p1,
- Priority_Control p2
+ Priority_Control p1,
+ Priority_Control p2
)
{
return _Scheduler_priority_Priority_compare_body( p1, p2 );
diff --git a/cpukit/score/src/schedulerpriorityschedule.c b/cpukit/score/src/schedulerpriorityschedule.c
index eb97779..aa6c09a 100644
--- a/cpukit/score/src/schedulerpriorityschedule.c
+++ b/cpukit/score/src/schedulerpriorityschedule.c
@@ -20,7 +20,10 @@
#include <rtems/score/schedulerpriorityimpl.h>
-void _Scheduler_priority_Schedule( Thread_Control *thread )
+void _Scheduler_priority_Schedule(
+ Scheduler_Control *base,
+ Thread_Control *the_thread
+)
{
- _Scheduler_priority_Schedule_body( thread, false );
+ _Scheduler_priority_Schedule_body( base, the_thread, false );
}
diff --git a/cpukit/score/src/schedulerprioritysmp.c b/cpukit/score/src/schedulerprioritysmp.c
index 458d87b..5361023 100644
--- a/cpukit/score/src/schedulerprioritysmp.c
+++ b/cpukit/score/src/schedulerprioritysmp.c
@@ -29,16 +29,17 @@
#include <rtems/score/schedulersmpimpl.h>
#include <rtems/score/wkspace.h>
-static Scheduler_priority_SMP_Control *_Scheduler_priority_SMP_Instance( void )
+static Scheduler_priority_SMP_Control *
+_Scheduler_priority_SMP_Self_from_base( Scheduler_Control *base )
{
- return _Scheduler.information;
+ return (Scheduler_priority_SMP_Control *) base->information;
}
static Scheduler_priority_SMP_Control *
-_Scheduler_priority_SMP_Self_from_SMP_base( Scheduler_SMP_Control *base )
+_Scheduler_priority_SMP_Self_from_SMP_base( Scheduler_SMP_Control *smp_base )
{
return (Scheduler_priority_SMP_Control *)
- ( (char *) base
+ ( (char *) smp_base
- offsetof( Scheduler_priority_SMP_Control, Base ) );
}
@@ -55,9 +56,13 @@ void _Scheduler_priority_SMP_Initialize( void )
_Scheduler.information = self;
}
-void _Scheduler_priority_SMP_Update( Thread_Control *thread )
+void _Scheduler_priority_SMP_Update(
+ Scheduler_Control *base,
+ Thread_Control *thread
+)
{
- Scheduler_priority_SMP_Control *self = _Scheduler_priority_SMP_Instance();
+ Scheduler_priority_SMP_Control *self =
+ _Scheduler_priority_SMP_Self_from_base( base );
_Scheduler_priority_Update_body(
thread,
@@ -67,11 +72,11 @@ void _Scheduler_priority_SMP_Update( Thread_Control *thread )
}
static Thread_Control *_Scheduler_priority_SMP_Get_highest_ready(
- Scheduler_SMP_Control *base
+ Scheduler_SMP_Control *smp_base
)
{
Scheduler_priority_SMP_Control *self =
- _Scheduler_priority_SMP_Self_from_SMP_base( base );
+ _Scheduler_priority_SMP_Self_from_SMP_base( smp_base );
Thread_Control *highest_ready = NULL;
if ( !_Priority_bit_map_Is_empty( &self->Bit_map ) ) {
@@ -85,12 +90,12 @@ static Thread_Control *_Scheduler_priority_SMP_Get_highest_ready(
}
static void _Scheduler_priority_SMP_Move_from_scheduled_to_ready(
- Scheduler_SMP_Control *base,
+ Scheduler_SMP_Control *smp_base,
Thread_Control *scheduled_to_ready
)
{
Scheduler_priority_SMP_Control *self =
- _Scheduler_priority_SMP_Self_from_SMP_base( base );
+ _Scheduler_priority_SMP_Self_from_SMP_base( smp_base );
_Chain_Extract_unprotected( &scheduled_to_ready->Object.Node );
_Scheduler_priority_Ready_queue_enqueue_first(
@@ -100,12 +105,12 @@ static void _Scheduler_priority_SMP_Move_from_scheduled_to_ready(
}
static void _Scheduler_priority_SMP_Move_from_ready_to_scheduled(
- Scheduler_SMP_Control *base,
+ Scheduler_SMP_Control *smp_base,
Thread_Control *ready_to_scheduled
)
{
Scheduler_priority_SMP_Control *self =
- _Scheduler_priority_SMP_Self_from_SMP_base( base );
+ _Scheduler_priority_SMP_Self_from_SMP_base( smp_base );
_Scheduler_priority_Ready_queue_extract(
ready_to_scheduled,
@@ -118,34 +123,34 @@ static void _Scheduler_priority_SMP_Move_from_ready_to_scheduled(
}
static void _Scheduler_priority_SMP_Insert_ready_lifo(
- Scheduler_SMP_Control *base,
+ Scheduler_SMP_Control *smp_base,
Thread_Control *thread
)
{
Scheduler_priority_SMP_Control *self =
- _Scheduler_priority_SMP_Self_from_SMP_base( base );
+ _Scheduler_priority_SMP_Self_from_SMP_base( smp_base );
_Scheduler_priority_Ready_queue_enqueue( thread, &self->Bit_map );
}
static void _Scheduler_priority_SMP_Insert_ready_fifo(
- Scheduler_SMP_Control *base,
+ Scheduler_SMP_Control *smp_base,
Thread_Control *thread
)
{
Scheduler_priority_SMP_Control *self =
- _Scheduler_priority_SMP_Self_from_SMP_base( base );
+ _Scheduler_priority_SMP_Self_from_SMP_base( smp_base );
_Scheduler_priority_Ready_queue_enqueue_first( thread, &self->Bit_map );
}
static void _Scheduler_priority_SMP_Do_extract(
- Scheduler_SMP_Control *base,
+ Scheduler_SMP_Control *smp_base,
Thread_Control *thread
)
{
Scheduler_priority_SMP_Control *self =
- _Scheduler_priority_SMP_Self_from_SMP_base( base );
+ _Scheduler_priority_SMP_Self_from_SMP_base( smp_base );
bool is_scheduled = thread->is_scheduled;
thread->is_in_the_air = is_scheduled;
@@ -158,9 +163,13 @@ static void _Scheduler_priority_SMP_Do_extract(
}
}
-void _Scheduler_priority_SMP_Block( Thread_Control *thread )
+void _Scheduler_priority_SMP_Block(
+ Scheduler_Control *base,
+ Thread_Control *thread
+)
{
- Scheduler_priority_SMP_Control *self = _Scheduler_priority_SMP_Instance();
+ Scheduler_priority_SMP_Control *self =
+ _Scheduler_priority_SMP_Self_from_base( base );
_Scheduler_SMP_Block(
&self->Base,
@@ -191,9 +200,13 @@ static void _Scheduler_priority_SMP_Enqueue_ordered(
);
}
-void _Scheduler_priority_SMP_Enqueue_lifo( Thread_Control *thread )
+void _Scheduler_priority_SMP_Enqueue_lifo(
+ Scheduler_Control *base,
+ Thread_Control *thread
+)
{
- Scheduler_priority_SMP_Control *self = _Scheduler_priority_SMP_Instance();
+ Scheduler_priority_SMP_Control *self =
+ _Scheduler_priority_SMP_Self_from_base( base );
_Scheduler_priority_SMP_Enqueue_ordered(
&self->Base,
@@ -204,9 +217,13 @@ void _Scheduler_priority_SMP_Enqueue_lifo( Thread_Control *thread )
);
}
-void _Scheduler_priority_SMP_Enqueue_fifo( Thread_Control *thread )
+void _Scheduler_priority_SMP_Enqueue_fifo(
+ Scheduler_Control *base,
+ Thread_Control *thread
+)
{
- Scheduler_priority_SMP_Control *self = _Scheduler_priority_SMP_Instance();
+ Scheduler_priority_SMP_Control *self =
+ _Scheduler_priority_SMP_Self_from_base( base );
_Scheduler_priority_SMP_Enqueue_ordered(
&self->Base,
@@ -217,9 +234,13 @@ void _Scheduler_priority_SMP_Enqueue_fifo( Thread_Control *thread )
);
}
-void _Scheduler_priority_SMP_Extract( Thread_Control *thread )
+void _Scheduler_priority_SMP_Extract(
+ Scheduler_Control *base,
+ Thread_Control *thread
+)
{
- Scheduler_priority_SMP_Control *self = _Scheduler_priority_SMP_Instance();
+ Scheduler_priority_SMP_Control *self =
+ _Scheduler_priority_SMP_Self_from_base( base );
_Scheduler_SMP_Extract(
&self->Base,
@@ -228,21 +249,28 @@ void _Scheduler_priority_SMP_Extract( Thread_Control *thread )
);
}
-void _Scheduler_priority_SMP_Yield( Thread_Control *thread )
+void _Scheduler_priority_SMP_Yield(
+ Scheduler_Control *base,
+ Thread_Control *thread
+)
{
ISR_Level level;
_ISR_Disable( level );
- _Scheduler_priority_SMP_Extract( thread );
- _Scheduler_priority_SMP_Enqueue_fifo( thread );
+ _Scheduler_priority_SMP_Extract( base, thread );
+ _Scheduler_priority_SMP_Enqueue_fifo( base, thread );
_ISR_Enable( level );
}
-void _Scheduler_priority_SMP_Schedule( Thread_Control *thread )
+void _Scheduler_priority_SMP_Schedule(
+ Scheduler_Control *base,
+ Thread_Control *thread
+)
{
- Scheduler_priority_SMP_Control *self = _Scheduler_priority_SMP_Instance();
+ Scheduler_priority_SMP_Control *self =
+ _Scheduler_priority_SMP_Self_from_base( base );
_Scheduler_SMP_Schedule(
&self->Base,
@@ -253,11 +281,13 @@ void _Scheduler_priority_SMP_Schedule( Thread_Control *thread )
}
void _Scheduler_priority_SMP_Start_idle(
+ Scheduler_Control *base,
Thread_Control *thread,
Per_CPU_Control *cpu
)
{
- Scheduler_priority_SMP_Control *self = _Scheduler_priority_SMP_Instance();
+ Scheduler_priority_SMP_Control *self =
+ _Scheduler_priority_SMP_Self_from_base( base );
_Scheduler_SMP_Start_idle( &self->Base, thread, cpu );
}
diff --git a/cpukit/score/src/schedulerpriorityunblock.c b/cpukit/score/src/schedulerpriorityunblock.c
index f69c1e2..c84111c 100644
--- a/cpukit/score/src/schedulerpriorityunblock.c
+++ b/cpukit/score/src/schedulerpriorityunblock.c
@@ -23,12 +23,14 @@
#include <rtems/score/schedulerpriorityimpl.h>
void _Scheduler_priority_Unblock (
- Thread_Control *the_thread
+ Scheduler_Control *base,
+ Thread_Control *the_thread
)
{
- Scheduler_priority_Control *scheduler = _Scheduler_priority_Instance();
+ Scheduler_priority_Control *self =
+ _Scheduler_priority_Self_from_base( base );
- _Scheduler_priority_Ready_queue_enqueue( the_thread, &scheduler->Bit_map );
+ _Scheduler_priority_Ready_queue_enqueue( the_thread, &self->Bit_map );
/* TODO: flash critical section? */
diff --git a/cpukit/score/src/schedulerpriorityupdate.c b/cpukit/score/src/schedulerpriorityupdate.c
index a56acd0..0e7032a 100644
--- a/cpukit/score/src/schedulerpriorityupdate.c
+++ b/cpukit/score/src/schedulerpriorityupdate.c
@@ -19,17 +19,18 @@
#endif
#include <rtems/score/schedulerpriorityimpl.h>
-#include <rtems/score/thread.h>
void _Scheduler_priority_Update(
+ Scheduler_Control *base,
Thread_Control *the_thread
)
{
- Scheduler_priority_Control *scheduler = _Scheduler_priority_Instance();
+ Scheduler_priority_Control *self =
+ _Scheduler_priority_Self_from_base( base );
_Scheduler_priority_Update_body(
the_thread,
- &scheduler->Bit_map,
- &scheduler->Ready[ 0 ]
+ &self->Bit_map,
+ &self->Ready[ 0 ]
);
}
diff --git a/cpukit/score/src/schedulerpriorityyield.c b/cpukit/score/src/schedulerpriorityyield.c
index 1e83c55..2bcefa5 100644
--- a/cpukit/score/src/schedulerpriorityyield.c
+++ b/cpukit/score/src/schedulerpriorityyield.c
@@ -22,25 +22,30 @@
#include <rtems/score/isr.h>
#include <rtems/score/threadimpl.h>
-void _Scheduler_priority_Yield( Thread_Control *thread )
+void _Scheduler_priority_Yield(
+ Scheduler_Control *base,
+ Thread_Control *the_thread
+)
{
Scheduler_priority_Per_thread *sched_info_of_thread =
- _Scheduler_priority_Get_scheduler_info( thread );
+ _Scheduler_priority_Get_scheduler_info( the_thread );
Chain_Control *ready_chain = sched_info_of_thread->ready_chain;
ISR_Level level;
+ (void) base;
+
_ISR_Disable( level );
if ( !_Chain_Has_only_one_node( ready_chain ) ) {
- _Chain_Extract_unprotected( &thread->Object.Node );
- _Chain_Append_unprotected( ready_chain, &thread->Object.Node );
+ _Chain_Extract_unprotected( &the_thread->Object.Node );
+ _Chain_Append_unprotected( ready_chain, &the_thread->Object.Node );
_ISR_Flash( level );
- if ( _Thread_Is_heir( thread ) )
+ if ( _Thread_Is_heir( the_thread ) )
_Thread_Heir = (Thread_Control *) _Chain_First( ready_chain );
_Thread_Dispatch_necessary = true;
}
- else if ( !_Thread_Is_heir( thread ) )
+ else if ( !_Thread_Is_heir( the_thread ) )
_Thread_Dispatch_necessary = true;
_ISR_Enable( level );
diff --git a/cpukit/score/src/schedulersimpleblock.c b/cpukit/score/src/schedulersimpleblock.c
index ac2ab6b..8bfab69 100644
--- a/cpukit/score/src/schedulersimpleblock.c
+++ b/cpukit/score/src/schedulersimpleblock.c
@@ -22,12 +22,14 @@
#include <rtems/score/schedulersimpleimpl.h>
void _Scheduler_simple_Block(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
)
{
_Scheduler_Generic_block(
+ scheduler,
+ the_thread,
_Scheduler_simple_Extract,
- _Scheduler_simple_Schedule_body,
- the_thread
+ _Scheduler_simple_Schedule_body
);
}
diff --git a/cpukit/score/src/schedulersimpleenqueue.c b/cpukit/score/src/schedulersimpleenqueue.c
index e8ad466..b0d4992 100644
--- a/cpukit/score/src/schedulersimpleenqueue.c
+++ b/cpukit/score/src/schedulersimpleenqueue.c
@@ -26,8 +26,9 @@
#include <rtems/score/schedulersimple.h>
void _Scheduler_simple_Enqueue(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
)
{
- _Scheduler_simple_Ready_queue_enqueue( the_thread );
+ _Scheduler_simple_Ready_queue_enqueue( scheduler, the_thread );
}
diff --git a/cpukit/score/src/schedulersimpleenqueuefirst.c b/cpukit/score/src/schedulersimpleenqueuefirst.c
index 4860308..b9005a7 100644
--- a/cpukit/score/src/schedulersimpleenqueuefirst.c
+++ b/cpukit/score/src/schedulersimpleenqueuefirst.c
@@ -24,8 +24,9 @@
#include <rtems/score/schedulersimple.h>
void _Scheduler_simple_Enqueue_first(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
)
{
- _Scheduler_simple_Ready_queue_enqueue_first( the_thread );
+ _Scheduler_simple_Ready_queue_enqueue_first( scheduler, the_thread );
}
diff --git a/cpukit/score/src/schedulersimpleextract.c b/cpukit/score/src/schedulersimpleextract.c
index ab38fb9..7bb4339 100644
--- a/cpukit/score/src/schedulersimpleextract.c
+++ b/cpukit/score/src/schedulersimpleextract.c
@@ -24,8 +24,11 @@
#include <rtems/score/thread.h>
void _Scheduler_simple_Extract(
+ Scheduler_Control *scheduler,
Thread_Control *the_thread
)
{
+ (void) scheduler;
+
_Chain_Extract_unprotected( &the_thread->Object.Node );
}
diff --git a/cpukit/score/src/schedulersimplereadyqueueenqueue.c b/cpukit/score/src/schedulersimplereadyqueueenqueue.c
index 134f6e8..3e06a26 100644
--- a/cpukit/score/src/schedulersimplereadyqueueenqueue.c
+++ b/cpukit/score/src/schedulersimplereadyqueueenqueue.c
@@ -21,11 +21,12 @@
#include <rtems/score/schedulersimpleimpl.h>
void _Scheduler_simple_Ready_queue_enqueue(
+ Scheduler_Control *scheduler_base,
Thread_Control *the_thread
)
{
Scheduler_simple_Control *scheduler =
- _Scheduler_simple_Instance();
+ _Scheduler_simple_Self_from_base( scheduler_base );
_Scheduler_simple_Insert_priority_fifo( &scheduler->Ready, the_thread );
}
diff --git a/cpukit/score/src/schedulersimplereadyqueueenqueuefirst.c b/cpukit/score/src/schedulersimplereadyqueueenqueuefirst.c
index 841bcd1..dd3379f 100644
--- a/cpukit/score/src/schedulersimplereadyqueueenqueuefirst.c
+++ b/cpukit/score/src/schedulersimplereadyqueueenqueuefirst.c
@@ -21,11 +21,12 @@
#include <rtems/score/schedulersimpleimpl.h>
void _Scheduler_simple_Ready_queue_enqueue_first(
+ Scheduler_Control *scheduler_base,
Thread_Control *the_thread
)
{
Scheduler_simple_Control *scheduler =
- _Scheduler_simple_Instance();
+ _Scheduler_simple_Self_from_base( scheduler_base );
_Scheduler_simple_Insert_priority_lifo( &scheduler->Ready, the_thread );
}
diff --git a/cpukit/score/src/schedulersimpleschedule.c b/cpukit/score/src/schedulersimpleschedule.c
index bf9372b..d3574b0 100644
--- a/cpukit/score/src/schedulersimpleschedule.c
+++ b/cpukit/score/src/schedulersimpleschedule.c
@@ -20,7 +20,10 @@
#include <rtems/score/schedulersimpleimpl.h>
-void _Scheduler_simple_Schedule( Thread_Control *thread )
+void _Scheduler_simple_Schedule(
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
+)
{
- _Scheduler_simple_Schedule_body( thread, false );
+ _Scheduler_simple_Schedule_body( scheduler, the_thread, false );
}
diff --git a/cpukit/score/src/schedulersimplesmp.c b/cpukit/score/src/schedulersimplesmp.c
index d222d02..20a35af 100644
--- a/cpukit/score/src/schedulersimplesmp.c
+++ b/cpukit/score/src/schedulersimplesmp.c
@@ -22,16 +22,17 @@
#include <rtems/score/schedulersmpimpl.h>
#include <rtems/score/wkspace.h>
-static Scheduler_simple_SMP_Control *_Scheduler_simple_SMP_Instance( void )
+static Scheduler_simple_SMP_Control *
+_Scheduler_simple_SMP_Self_from_base( Scheduler_Control *base )
{
- return _Scheduler.information;
+ return (Scheduler_simple_SMP_Control *) base->information;
}
static Scheduler_simple_SMP_Control *
-_Scheduler_simple_SMP_Self_from_SMP_base( Scheduler_SMP_Control *base )
+_Scheduler_simple_SMP_Self_from_SMP_base( Scheduler_SMP_Control *smp_base )
{
return (Scheduler_simple_SMP_Control *)
- ( (char *) base - offsetof( Scheduler_simple_SMP_Control, Base ) );
+ ( (char *) smp_base - offsetof( Scheduler_simple_SMP_Control, Base ) );
}
void _Scheduler_simple_smp_Initialize( void )
@@ -46,11 +47,11 @@ void _Scheduler_simple_smp_Initialize( void )
}
static Thread_Control *_Scheduler_simple_smp_Get_highest_ready(
- Scheduler_SMP_Control *base
+ Scheduler_SMP_Control *smp_base
)
{
Scheduler_simple_SMP_Control *self =
- _Scheduler_simple_SMP_Self_from_SMP_base( base );
+ _Scheduler_simple_SMP_Self_from_SMP_base( smp_base );
Thread_Control *highest_ready = NULL;
Chain_Control *ready = &self->Ready;
@@ -62,12 +63,12 @@ static Thread_Control *_Scheduler_simple_smp_Get_highest_ready(
}
static void _Scheduler_simple_smp_Move_from_scheduled_to_ready(
- Scheduler_SMP_Control *base,
+ Scheduler_SMP_Control *smp_base,
Thread_Control *scheduled_to_ready
)
{
Scheduler_simple_SMP_Control *self =
- _Scheduler_simple_SMP_Self_from_SMP_base( base );
+ _Scheduler_simple_SMP_Self_from_SMP_base( smp_base );
_Chain_Extract_unprotected( &scheduled_to_ready->Object.Node );
_Scheduler_simple_Insert_priority_lifo(
@@ -77,24 +78,24 @@ static void _Scheduler_simple_smp_Move_from_scheduled_to_ready(
}
static void _Scheduler_simple_smp_Move_from_ready_to_scheduled(
- Scheduler_SMP_Control *base,
+ Scheduler_SMP_Control *smp_base,
Thread_Control *ready_to_scheduled
)
{
_Chain_Extract_unprotected( &ready_to_scheduled->Object.Node );
_Scheduler_simple_Insert_priority_fifo(
- &base->Scheduled,
+ &smp_base->Scheduled,
ready_to_scheduled
);
}
static void _Scheduler_simple_smp_Insert_ready_lifo(
- Scheduler_SMP_Control *base,
+ Scheduler_SMP_Control *smp_base,
Thread_Control *thread
)
{
Scheduler_simple_SMP_Control *self =
- _Scheduler_simple_SMP_Self_from_SMP_base( base );
+ _Scheduler_simple_SMP_Self_from_SMP_base( smp_base );
_Chain_Insert_ordered_unprotected(
&self->Ready,
@@ -104,12 +105,12 @@ static void _Scheduler_simple_smp_Insert_ready_lifo(
}
static void _Scheduler_simple_smp_Insert_ready_fifo(
- Scheduler_SMP_Control *base,
+ Scheduler_SMP_Control *smp_base,
Thread_Control *thread
)
{
Scheduler_simple_SMP_Control *self =
- _Scheduler_simple_SMP_Self_from_SMP_base( base );
+ _Scheduler_simple_SMP_Self_from_SMP_base( smp_base );
_Chain_Insert_ordered_unprotected(
&self->Ready,
@@ -119,11 +120,11 @@ static void _Scheduler_simple_smp_Insert_ready_fifo(
}
static void _Scheduler_simple_smp_Do_extract(
- Scheduler_SMP_Control *base,
+ Scheduler_SMP_Control *smp_base,
Thread_Control *thread
)
{
- (void) base;
+ (void) smp_base;
thread->is_in_the_air = thread->is_scheduled;
thread->is_scheduled = false;
@@ -131,9 +132,13 @@ static void _Scheduler_simple_smp_Do_extract(
_Chain_Extract_unprotected( &thread->Object.Node );
}
-void _Scheduler_simple_smp_Block( Thread_Control *thread )
+void _Scheduler_simple_smp_Block(
+ Scheduler_Control *base,
+ Thread_Control *thread
+)
{
- Scheduler_simple_SMP_Control *self = _Scheduler_simple_SMP_Instance();
+ Scheduler_simple_SMP_Control *self =
+ _Scheduler_simple_SMP_Self_from_base( base );
_Scheduler_SMP_Block(
&self->Base,
@@ -145,7 +150,7 @@ void _Scheduler_simple_smp_Block( Thread_Control *thread )
}
static void _Scheduler_simple_smp_Enqueue_ordered(
- Scheduler_SMP_Control *base,
+ Scheduler_SMP_Control *smp_base,
Thread_Control *thread,
Chain_Node_order order,
Scheduler_SMP_Insert insert_ready,
@@ -153,7 +158,7 @@ static void _Scheduler_simple_smp_Enqueue_ordered(
)
{
_Scheduler_SMP_Enqueue_ordered(
- base,
+ smp_base,
thread,
order,
_Scheduler_simple_smp_Get_highest_ready,
@@ -164,9 +169,13 @@ static void _Scheduler_simple_smp_Enqueue_ordered(
);
}
-void _Scheduler_simple_smp_Enqueue_priority_lifo( Thread_Control *thread )
+void _Scheduler_simple_smp_Enqueue_priority_lifo(
+ Scheduler_Control *base,
+ Thread_Control *thread
+)
{
- Scheduler_simple_SMP_Control *self = _Scheduler_simple_SMP_Instance();
+ Scheduler_simple_SMP_Control *self =
+ _Scheduler_simple_SMP_Self_from_base( base );
_Scheduler_simple_smp_Enqueue_ordered(
&self->Base,
@@ -177,9 +186,13 @@ void _Scheduler_simple_smp_Enqueue_priority_lifo( Thread_Control *thread )
);
}
-void _Scheduler_simple_smp_Enqueue_priority_fifo( Thread_Control *thread )
+void _Scheduler_simple_smp_Enqueue_priority_fifo(
+ Scheduler_Control *base,
+ Thread_Control *thread
+)
{
- Scheduler_simple_SMP_Control *self = _Scheduler_simple_SMP_Instance();
+ Scheduler_simple_SMP_Control *self =
+ _Scheduler_simple_SMP_Self_from_base( base );
_Scheduler_simple_smp_Enqueue_ordered(
&self->Base,
@@ -190,9 +203,13 @@ void _Scheduler_simple_smp_Enqueue_priority_fifo( Thread_Control *thread )
);
}
-void _Scheduler_simple_smp_Extract( Thread_Control *thread )
+void _Scheduler_simple_smp_Extract(
+ Scheduler_Control *base,
+ Thread_Control *thread
+)
{
- Scheduler_simple_SMP_Control *self = _Scheduler_simple_SMP_Instance();
+ Scheduler_simple_SMP_Control *self =
+ _Scheduler_simple_SMP_Self_from_base( base );
_Scheduler_SMP_Extract(
&self->Base,
@@ -201,21 +218,28 @@ void _Scheduler_simple_smp_Extract( Thread_Control *thread )
);
}
-void _Scheduler_simple_smp_Yield( Thread_Control *thread )
+void _Scheduler_simple_smp_Yield(
+ Scheduler_Control *base,
+ Thread_Control *thread
+)
{
ISR_Level level;
_ISR_Disable( level );
- _Scheduler_simple_smp_Extract( thread );
- _Scheduler_simple_smp_Enqueue_priority_fifo( thread );
+ _Scheduler_simple_smp_Extract( base, thread );
+ _Scheduler_simple_smp_Enqueue_priority_fifo( base, thread );
_ISR_Enable( level );
}
-void _Scheduler_simple_smp_Schedule( Thread_Control *thread )
+void _Scheduler_simple_smp_Schedule(
+ Scheduler_Control *base,
+ Thread_Control *thread
+)
{
- Scheduler_simple_SMP_Control *self = _Scheduler_simple_SMP_Instance();
+ Scheduler_simple_SMP_Control *self =
+ _Scheduler_simple_SMP_Self_from_base( base );
_Scheduler_SMP_Schedule(
&self->Base,
@@ -226,11 +250,13 @@ void _Scheduler_simple_smp_Schedule( Thread_Control *thread )
}
void _Scheduler_simple_smp_Start_idle(
+ Scheduler_Control *base,
Thread_Control *thread,
Per_CPU_Control *cpu
)
{
- Scheduler_simple_SMP_Control *self = _Scheduler_simple_SMP_Instance();
+ Scheduler_simple_SMP_Control *self =
+ _Scheduler_simple_SMP_Self_from_base( base );
_Scheduler_SMP_Start_idle( &self->Base, thread, cpu );
}
diff --git a/cpukit/score/src/schedulersimpleunblock.c b/cpukit/score/src/schedulersimpleunblock.c
index 37a710d..c669a9b 100644
--- a/cpukit/score/src/schedulersimpleunblock.c
+++ b/cpukit/score/src/schedulersimpleunblock.c
@@ -24,10 +24,11 @@
#include <rtems/score/thread.h>
void _Scheduler_simple_Unblock(
+ Scheduler_Control *scheduler,
Thread_Control *the_thread
)
{
- _Scheduler_simple_Ready_queue_enqueue(the_thread);
+ _Scheduler_simple_Ready_queue_enqueue( scheduler, the_thread );
/*
* If the thread that was unblocked is more important than the heir,
diff --git a/cpukit/score/src/schedulersimpleyield.c b/cpukit/score/src/schedulersimpleyield.c
index 114071b..664fa31 100644
--- a/cpukit/score/src/schedulersimpleyield.c
+++ b/cpukit/score/src/schedulersimpleyield.c
@@ -22,17 +22,20 @@
#include <rtems/score/isr.h>
#include <rtems/score/threadimpl.h>
-void _Scheduler_simple_Yield( Thread_Control *thread )
+void _Scheduler_simple_Yield(
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
+)
{
ISR_Level level;
_ISR_Disable( level );
- _Scheduler_simple_Ready_queue_requeue( &_Scheduler, thread );
+ _Scheduler_simple_Ready_queue_requeue( scheduler, the_thread );
_ISR_Flash( level );
- _Scheduler_simple_Schedule_body( thread, false );
+ _Scheduler_simple_Schedule_body( scheduler, the_thread, false );
_ISR_Enable( level );
}
diff --git a/cpukit/score/src/threadchangepriority.c b/cpukit/score/src/threadchangepriority.c
index f60527a..fab0c9e 100644
--- a/cpukit/score/src/threadchangepriority.c
+++ b/cpukit/score/src/threadchangepriority.c
@@ -29,8 +29,9 @@ void _Thread_Change_priority(
bool prepend_it
)
{
- ISR_Level level;
- States_Control state, original_state;
+ Scheduler_Control *scheduler = _Scheduler_Get( the_thread );
+ ISR_Level level;
+ States_Control state, original_state;
/*
* Save original state
@@ -69,7 +70,7 @@ void _Thread_Change_priority(
* result in a _Scheduler_Block() operation. Make sure we select an heir
* now.
*/
- _Scheduler_Schedule( the_thread );
+ _Scheduler_Schedule( scheduler, the_thread );
_ISR_Enable( level );
if ( _States_Is_waiting_on_thread_queue( state ) ) {
@@ -89,9 +90,9 @@ void _Thread_Change_priority(
the_thread->current_state = _States_Clear( STATES_TRANSIENT, state );
if ( prepend_it )
- _Scheduler_Enqueue_first( the_thread );
+ _Scheduler_Enqueue_first( scheduler, the_thread );
else
- _Scheduler_Enqueue( the_thread );
+ _Scheduler_Enqueue( scheduler, the_thread );
}
_ISR_Flash( level );
@@ -100,7 +101,7 @@ 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_Schedule( the_thread );
+ _Scheduler_Schedule( scheduler, the_thread );
_ISR_Enable( level );
}
diff --git a/cpukit/score/src/threadclearstate.c b/cpukit/score/src/threadclearstate.c
index 19e41df..10bdae6 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( the_thread );
+ _Scheduler_Unblock( _Scheduler_Get( the_thread ), the_thread );
}
}
_ISR_Enable( level );
diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c
index fd52742..1e44d43 100644
--- a/cpukit/score/src/threadinitialize.c
+++ b/cpukit/score/src/threadinitialize.c
@@ -219,7 +219,7 @@ bool _Thread_Initialize(
the_thread->resource_count = 0;
the_thread->real_priority = priority;
the_thread->Start.initial_priority = priority;
- sched =_Scheduler_Allocate( the_thread );
+ sched =_Scheduler_Allocate( _Scheduler_Get( the_thread ), the_thread );
if ( !sched )
goto failed;
_Thread_Set_priority( the_thread, priority );
diff --git a/cpukit/score/src/threadready.c b/cpukit/score/src/threadready.c
index b79d8db..d50debe 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( the_thread );
+ _Scheduler_Unblock( _Scheduler_Get( the_thread ), the_thread );
_ISR_Enable( level );
}
diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c
index 02371ac..fcf9d6c 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( the_thread );
+ _Scheduler_Free( _Scheduler_Get( the_thread ), the_thread );
/*
* The thread might have been FP. So deal with that.
@@ -216,8 +216,9 @@ void _Thread_Life_action_handler(
}
static void _Thread_Start_life_change(
- Thread_Control *the_thread,
- Priority_Control priority
+ Thread_Control *the_thread,
+ Scheduler_Control *scheduler,
+ Priority_Control priority
)
{
the_thread->is_preemptible = the_thread->Start.is_preemptible;
@@ -228,7 +229,7 @@ static void _Thread_Start_life_change(
_Thread_Set_transient( the_thread );
_Thread_queue_Extract_with_proxy( the_thread );
_Watchdog_Remove( &the_thread->Timer );
- _Scheduler_Set_priority_if_higher( the_thread, priority );
+ _Scheduler_Set_priority_if_higher( scheduler, the_thread, priority );
_Thread_Add_post_switch_action( the_thread, &the_thread->Life.Action );
_Thread_Ready( the_thread );
_Thread_Request_dispatch_if_executing( the_thread );
@@ -244,29 +245,37 @@ static void _Thread_Request_life_change(
Thread_Life_state previous_life_state;
Per_CPU_Control *cpu;
ISR_Level level;
+ Scheduler_Control *scheduler;
cpu = _Thread_Action_ISR_disable_and_acquire( the_thread, &level );
previous_life_state = the_thread->Life.state;
the_thread->Life.state = previous_life_state | additional_life_state;
_Thread_Action_release_and_ISR_enable( cpu, level );
+ scheduler = _Scheduler_Get( the_thread );
if ( the_thread == executing ) {
executing->real_priority = priority;
- _Scheduler_Set_priority_if_higher( the_thread, priority );
+ _Scheduler_Set_priority_if_higher( scheduler, the_thread, priority );
_Thread_Start_life_change_for_executing( executing );
} else if ( previous_life_state == THREAD_LIFE_NORMAL ) {
- _Thread_Start_life_change( the_thread, priority );
+ _Thread_Start_life_change( the_thread, scheduler, priority );
} else {
_Thread_Clear_state( the_thread, STATES_SUSPENDED );
if ( _Thread_Is_life_terminating( additional_life_state ) ) {
the_thread->real_priority = _Scheduler_Highest_priority_of_two(
+ scheduler,
the_thread->real_priority,
priority
);
- _Scheduler_Change_priority_if_higher( the_thread, priority, false );
+ _Scheduler_Change_priority_if_higher(
+ scheduler,
+ the_thread,
+ priority,
+ false
+ );
}
}
}
diff --git a/cpukit/score/src/threadsetpriority.c b/cpukit/score/src/threadsetpriority.c
index 99d0c4a..e128648 100644
--- a/cpukit/score/src/threadsetpriority.c
+++ b/cpukit/score/src/threadsetpriority.c
@@ -28,5 +28,5 @@ void _Thread_Set_priority(
{
the_thread->current_priority = new_priority;
- _Scheduler_Update( the_thread );
+ _Scheduler_Update( _Scheduler_Get( the_thread ), the_thread );
}
diff --git a/cpukit/score/src/threadsetstate.c b/cpukit/score/src/threadsetstate.c
index a8cd38e..97da2bf 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( the_thread );
+ _Scheduler_Block( _Scheduler_Get( the_thread ), the_thread );
} else {
the_thread->current_state = _States_Set( state, current_state);
}
diff --git a/cpukit/score/src/threadsettransient.c b/cpukit/score/src/threadsettransient.c
index c0d31fe..ead3c45 100644
--- a/cpukit/score/src/threadsettransient.c
+++ b/cpukit/score/src/threadsettransient.c
@@ -36,7 +36,7 @@ void _Thread_Set_transient(
the_thread->current_state = _States_Set( STATES_TRANSIENT, old_state );
if ( _States_Is_ready( old_state ) ) {
- _Scheduler_Extract( the_thread );
+ _Scheduler_Extract( _Scheduler_Get( the_thread ), the_thread );
}
_ISR_Enable( level );
diff --git a/cpukit/score/src/threadstart.c b/cpukit/score/src/threadstart.c
index 5b9604e..b65a2c3 100644
--- a/cpukit/score/src/threadstart.c
+++ b/cpukit/score/src/threadstart.c
@@ -30,7 +30,7 @@ bool _Thread_Start(
void *entry_point,
void *pointer_argument,
Thread_Entry_numeric_type numeric_argument,
- Per_CPU_Control *processor
+ Per_CPU_Control *cpu
)
{
if ( _States_Is_dormant( the_thread->current_state ) ) {
@@ -43,11 +43,11 @@ bool _Thread_Start(
_Thread_Load_environment( the_thread );
- if ( processor == NULL ) {
+ if ( cpu == NULL ) {
_Thread_Ready( the_thread );
} else {
the_thread->current_state = STATES_READY;
- _Scheduler_Start_idle( the_thread, processor );
+ _Scheduler_Start_idle( _Scheduler_Get( the_thread ), the_thread, cpu );
}
_User_extensions_Thread_start( the_thread );
diff --git a/testsuites/tmtests/tm26/task1.c b/testsuites/tmtests/tm26/task1.c
index 925c2f5..6325516 100644
--- a/testsuites/tmtests/tm26/task1.c
+++ b/testsuites/tmtests/tm26/task1.c
@@ -371,7 +371,8 @@ rtems_task Middle_task(
rtems_task_argument argument
)
{
- Scheduler_priority_Control *scheduler = _Scheduler_priority_Instance();
+ Scheduler_priority_Control *scheduler =
+ _Scheduler_priority_Self_from_base( _Scheduler_Get( NULL ) );
thread_dispatch_no_fp_time = benchmark_timer_read();
@@ -403,7 +404,8 @@ rtems_task Low_task(
rtems_task_argument argument
)
{
- Scheduler_priority_Control *scheduler = _Scheduler_priority_Instance();
+ Scheduler_priority_Control *scheduler =
+ _Scheduler_priority_Self_from_base( _Scheduler_Get( NULL ) );
Thread_Control *executing;
context_switch_no_fp_time = benchmark_timer_read();
@@ -445,7 +447,8 @@ rtems_task Floating_point_task_1(
rtems_task_argument argument
)
{
- Scheduler_priority_Control *scheduler = _Scheduler_priority_Instance();
+ Scheduler_priority_Control *scheduler =
+ _Scheduler_priority_Self_from_base( _Scheduler_Get( NULL ) );
Thread_Control *executing;
FP_DECLARE;
@@ -500,7 +503,8 @@ rtems_task Floating_point_task_2(
rtems_task_argument argument
)
{
- Scheduler_priority_Control *scheduler = _Scheduler_priority_Instance();
+ Scheduler_priority_Control *scheduler =
+ _Scheduler_priority_Self_from_base( _Scheduler_Get( NULL ) );
Thread_Control *executing;
FP_DECLARE;
diff --git a/testsuites/tmtests/tm27/task1.c b/testsuites/tmtests/tm27/task1.c
index d7ebfbe..a639327 100644
--- a/testsuites/tmtests/tm27/task1.c
+++ b/testsuites/tmtests/tm27/task1.c
@@ -102,7 +102,8 @@ rtems_task Task_1(
rtems_task_argument argument
)
{
- Scheduler_priority_Control *scheduler = _Scheduler_priority_Instance();
+ Scheduler_priority_Control *scheduler =
+ _Scheduler_priority_Self_from_base( _Scheduler_Get( NULL ) );
#if defined(RTEMS_SMP)
rtems_interrupt_level level;
#endif
@@ -219,7 +220,8 @@ rtems_task Task_2(
rtems_task_argument argument
)
{
- Scheduler_priority_Control *scheduler = _Scheduler_priority_Instance();
+ Scheduler_priority_Control *scheduler =
+ _Scheduler_priority_Self_from_base( _Scheduler_Get( NULL ) );
#if defined(RTEMS_SMP)
rtems_interrupt_level level;
#endif
--
1.7.7
More information about the devel
mailing list