summaryrefslogtreecommitdiffstats
path: root/cpukit/score/include/rtems/score
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-04-03 15:03:35 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-04-04 11:01:18 +0200
commit24934e36e2513f972510d7c746103be1f766dc6a (patch)
tree66e3c8840cec6c1262f142e25ec545926140dbf9 /cpukit/score/include/rtems/score
parentscore: Add and use Scheduler_simple_Control (diff)
downloadrtems-24934e36e2513f972510d7c746103be1f766dc6a.tar.bz2
score: Add scheduler control to scheduler ops
Scheduler operations must be free of a global scheduler context to enable partitioned/clustered scheduling.
Diffstat (limited to 'cpukit/score/include/rtems/score')
-rw-r--r--cpukit/score/include/rtems/score/scheduler.h112
-rw-r--r--cpukit/score/include/rtems/score/schedulercbs.h9
-rw-r--r--cpukit/score/include/rtems/score/scheduleredf.h31
-rw-r--r--cpukit/score/include/rtems/score/scheduleredfimpl.h12
-rw-r--r--cpukit/score/include/rtems/score/schedulerimpl.h154
-rw-r--r--cpukit/score/include/rtems/score/schedulerpriority.h30
-rw-r--r--cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h16
-rw-r--r--cpukit/score/include/rtems/score/schedulerpriorityimpl.h20
-rw-r--r--cpukit/score/include/rtems/score/schedulerprioritysmp.h36
-rw-r--r--cpukit/score/include/rtems/score/schedulersimple.h27
-rw-r--r--cpukit/score/include/rtems/score/schedulersimpleimpl.h19
-rw-r--r--cpukit/score/include/rtems/score/schedulersimplesmp.h31
-rw-r--r--cpukit/score/include/rtems/score/threadimpl.h4
13 files changed, 335 insertions, 166 deletions
diff --git a/cpukit/score/include/rtems/score/scheduler.h b/cpukit/score/include/rtems/score/scheduler.h
index 1890caf491..b975fc4a3e 100644
--- a/cpukit/score/include/rtems/score/scheduler.h
+++ b/cpukit/score/include/rtems/score/scheduler.h
@@ -40,6 +40,8 @@ extern "C" {
*/
/**@{*/
+typedef struct Scheduler_Control Scheduler_Control;
+
/**
* function jump table that holds pointers to the functions that
* implement specific schedulers.
@@ -49,58 +51,65 @@ 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 *
+ );
#if defined(__RTEMS_HAVE_SYS_CPUSET_H__) && defined(RTEMS_SMP)
/**
@@ -108,7 +117,12 @@ typedef struct {
*
* @see _Scheduler_Get_affinity().
*/
- bool ( *get_affinity )( Thread_Control *thread, size_t cpusetsize, cpu_set_t *cpuset );
+ bool ( *get_affinity )(
+ Scheduler_Control *,
+ Thread_Control *,
+ size_t,
+ cpu_set_t *
+ );
/**
* @brief Set the processor affinity for a thread.
@@ -116,18 +130,18 @@ typedef struct {
* @see _Scheduler_Set_affinity().
*/
bool ( *set_affinity )(
- Thread_Control *thread,
- size_t cpusetsize,
- const cpu_set_t *cpuset
+ Scheduler_Control *,
+ Thread_Control *,
+ size_t,
+ const cpu_set_t *
);
#endif
-
} 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
@@ -137,7 +151,7 @@ typedef struct {
/** The jump table for scheduler-specific functions */
Scheduler_Operations Operations;
-} Scheduler_Control;
+};
/**
* The _Scheduler holds the structures used to manage the
@@ -152,41 +166,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
);
/**
@@ -194,18 +216,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
);
#if defined(__RTEMS_HAVE_SYS_CPUSET_H__) && defined(RTEMS_SMP)
@@ -220,9 +246,10 @@ void _Scheduler_default_Start_idle(
* @retval -1 The cpusetsize is invalid for the system
*/
bool _Scheduler_default_Get_affinity(
- Thread_Control *thread,
- size_t cpusetsize,
- cpu_set_t *cpuset
+ Scheduler_Control *scheduler,
+ Thread_Control *thread,
+ size_t cpusetsize,
+ cpu_set_t *cpuset
);
/**
@@ -238,9 +265,10 @@ void _Scheduler_default_Start_idle(
* the cpuset.
*/
bool _Scheduler_default_Set_affinity(
- Thread_Control *thread,
- size_t cpusetsize,
- const cpu_set_t *cpuset
+ Scheduler_Control *scheduler,
+ Thread_Control *thread,
+ size_t cpusetsize,
+ const cpu_set_t *cpuset
);
#endif
diff --git a/cpukit/score/include/rtems/score/schedulercbs.h b/cpukit/score/include/rtems/score/schedulercbs.h
index d4ed7efb74..f654225f58 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 2d5f537c59..16d46a4928 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 aa1d21591f..bfeff639dd 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 72f239fd6b..6687fcf2e4 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 );
}
#if defined(__RTEMS_HAVE_SYS_CPUSET_H__) && defined(RTEMS_SMP)
@@ -248,12 +263,18 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Start_idle(
* @parma[out] cpuset The processor affinity for this thread
*/
RTEMS_INLINE_ROUTINE int _Scheduler_Get_affinity(
- Thread_Control *thread,
- size_t cpusetsize,
- cpu_set_t *cpuset
+ Scheduler_Control *scheduler,
+ Thread_Control *thread,
+ size_t cpusetsize,
+ cpu_set_t *cpuset
)
{
- return (*_Scheduler.Operations.get_affinity)( thread, cpusetsize, cpuset );
+ return ( *scheduler->Operations.get_affinity )(
+ scheduler,
+ thread,
+ cpusetsize,
+ cpuset
+ );
}
/**
@@ -263,12 +284,18 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Start_idle(
* @parma[in] cpuset The processor affinity for this thread
*/
RTEMS_INLINE_ROUTINE int _Scheduler_Set_affinity(
- Thread_Control *thread,
- size_t cpusetsize,
- const cpu_set_t *cpuset
+ Scheduler_Control *scheduler,
+ Thread_Control *thread,
+ size_t cpusetsize,
+ const cpu_set_t *cpuset
)
{
- return (*_Scheduler.Operations.set_affinity)( thread, cpusetsize, cpuset );
+ return ( *scheduler->Operations.set_affinity )(
+ scheduler,
+ thread,
+ cpusetsize,
+ cpuset
+ );
}
#endif
@@ -286,17 +313,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 );
}
}
@@ -305,11 +333,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;
}
/**
@@ -317,11 +346,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;
}
/**
@@ -329,11 +359,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;
}
/**
@@ -341,13 +372,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 );
}
}
@@ -357,18 +389,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 0bc455293c..1e4e91ba32 100644
--- a/cpukit/score/include/rtems/score/schedulerpriority.h
+++ b/cpukit/score/include/rtems/score/schedulerpriority.h
@@ -105,6 +105,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
);
@@ -114,7 +115,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.
@@ -125,7 +129,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
);
/**
@@ -137,7 +142,8 @@ void * _Scheduler_priority_Allocate(
* will be deallocated.
*/
void _Scheduler_priority_Free(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
);
/**
@@ -149,7 +155,8 @@ void _Scheduler_priority_Free(
* structure updated.
*/
void _Scheduler_priority_Update(
- Thread_Control *the_thread
+ Scheduler_Control *scheduler,
+ Thread_Control *the_thread
);
/**
@@ -162,6 +169,7 @@ void _Scheduler_priority_Update(
* @param[in] the_thread will be unblocked
*/
void _Scheduler_priority_Unblock(
+ Scheduler_Control *scheduler,
Thread_Control *the_thread
);
@@ -184,7 +192,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.
@@ -194,6 +205,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
);
@@ -207,6 +219,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
);
@@ -219,7 +232,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
);
/**
@@ -228,8 +242,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/schedulerpriorityaffinitysmp.h b/cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h
index fe1978176f..8f9d0818b1 100644
--- a/cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h
+++ b/cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h
@@ -81,6 +81,7 @@ void * _Scheduler_priority_affinity_SMP_Allocate( Thread_Control *the_thread );
/**
* @brief Get affinity for the priority affinity smp scheduler.
*
+ * @param[in] scheduler The scheduler of the thread.
* @param[in] thread The associated thread.
* @param[in] cpusetsize The size of the cpuset.
* @param[in,out] cpuset The associated affinity set.
@@ -89,14 +90,16 @@ void * _Scheduler_priority_affinity_SMP_Allocate( Thread_Control *the_thread );
* @retval -1 The cpusetsize is invalid for the system
*/
bool _Scheduler_priority_affinity_SMP_Get_affinity(
- Thread_Control *thread,
- size_t cpusetsize,
- cpu_set_t *cpuset
+ Scheduler_Control *scheduler,
+ Thread_Control *thread,
+ size_t cpusetsize,
+ cpu_set_t *cpuset
);
/**
* @brief Set affinity for the priority affinity smp scheduler.
*
+ * @param[in] scheduler The scheduler of the thread.
* @param[in] thread The associated thread.
* @param[in] cpusetsize The size of the cpuset.
* @param[in] cpuset Affinity new affinity set.
@@ -104,9 +107,10 @@ bool _Scheduler_priority_affinity_SMP_Get_affinity(
* @retval 0 Successful
*/
bool _Scheduler_priority_affinity_SMP_Set_affinity(
- Thread_Control *thread,
- size_t cpusetsize,
- cpu_set_t *cpuset
+ Scheduler_Control *scheduler,
+ Thread_Control *thread,
+ size_t cpusetsize,
+ cpu_set_t *cpuset
);
/**
diff --git a/cpukit/score/include/rtems/score/schedulerpriorityimpl.h b/cpukit/score/include/rtems/score/schedulerpriorityimpl.h
index ebcc3f1762..7861df5c90 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 409d9febfa..905549d125 100644
--- a/cpukit/score/include/rtems/score/schedulerprioritysmp.h
+++ b/cpukit/score/include/rtems/score/schedulerprioritysmp.h
@@ -73,21 +73,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 54b0801872..889c5a79c6 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 c51c6c3f0e..8ad142f0b4 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 000a975c93..a6d826208d 100644
--- a/cpukit/score/include/rtems/score/schedulersimplesmp.h
+++ b/cpukit/score/include/rtems/score/schedulersimplesmp.h
@@ -75,19 +75,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 2ac8344577..6d4ca9f898 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(