score: Add scheduler control to scheduler ops

Scheduler operations must be free of a global scheduler context to
enable partitioned/clustered scheduling.
This commit is contained in:
Sebastian Huber
2014-04-04 11:01:18 +02:00
parent 439c494fe2
commit 24934e36e2
82 changed files with 768 additions and 386 deletions
+1 -1
View File
@@ -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;
+1
View File
@@ -194,6 +194,7 @@ int pthread_create(
#if defined(RTEMS_SMP) && __RTEMS_HAVE_SYS_CPUSET_H__
status = _Scheduler_Set_affinity(
_Scheduler_Get( the_thread ),
the_thread,
the_attr->affinitysetsize,
the_attr->affinityset
+7 -5
View File
@@ -47,12 +47,14 @@ int pthread_getaffinity_np(
switch ( location ) {
case OBJECTS_LOCAL:
ok = _Scheduler_Get_affinity( the_thread, cpusetsize, cpuset );
ok = _Scheduler_Get_affinity(
_Scheduler_Get( the_thread ),
the_thread,
cpusetsize,
cpuset
);
_Objects_Put( &the_thread->Object );
if (!ok)
return EINVAL;
return 0;
break;
return ok ? 0 : EINVAL;
#if defined(RTEMS_MULTIPROCESSING)
case OBJECTS_REMOTE:
+10 -7
View File
@@ -47,15 +47,18 @@ int pthread_setaffinity_np(
switch ( location ) {
case OBJECTS_LOCAL:
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
ok = _Scheduler_Set_affinity( the_thread, cpusetsize, cpuset );
if (ok)
ok = _Scheduler_Set_affinity(
_Scheduler_Get( the_thread ),
the_thread,
cpusetsize,
cpuset
);
if ( ok ) {
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
CPU_COPY( api->Attributes.affinityset, cpuset );
}
_Objects_Put( &the_thread->Object );
if (!ok)
return EINVAL;
return 0;
break;
return ok ? 0 : EINVAL;
#if defined(RTEMS_MULTIPROCESSING)
case OBJECTS_REMOTE:
+4 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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();
+5 -1
View File
@@ -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;
+5 -1
View File
@@ -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;
+10 -2
View File
@@ -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;
}
+8 -5
View File
@@ -34,7 +34,7 @@ rtems_status_code rtems_task_get_affinity(
{
Thread_Control *the_thread;
Objects_Locations location;
rtems_status_code status = RTEMS_SUCCESSFUL;
bool ok;
if ( !cpuset )
return RTEMS_INVALID_ADDRESS;
@@ -44,11 +44,14 @@ rtems_status_code rtems_task_get_affinity(
switch ( location ) {
case OBJECTS_LOCAL:
if ( ! _Scheduler_Get_affinity( the_thread, cpusetsize, cpuset )) {
status = RTEMS_INVALID_NUMBER;
}
ok = _Scheduler_Get_affinity(
_Scheduler_Get( the_thread ),
the_thread,
cpusetsize,
cpuset
);
_Objects_Put( &the_thread->Object );
return status;
return ok ? RTEMS_SUCCESSFUL : RTEMS_INVALID_NUMBER;
#if defined(RTEMS_MULTIPROCESSING)
case OBJECTS_REMOTE:
+7 -5
View File
@@ -42,12 +42,14 @@ rtems_status_code rtems_task_set_affinity(
switch ( location ) {
case OBJECTS_LOCAL:
ok = _Scheduler_Set_affinity( the_thread, cpusetsize, cpuset );
ok = _Scheduler_Set_affinity(
_Scheduler_Get( the_thread ),
the_thread,
cpusetsize,
cpuset
);
_Objects_Put( &the_thread->Object );
if (! ok) {
return RTEMS_INVALID_NUMBER;
}
return RTEMS_SUCCESSFUL;
return ok ? RTEMS_SUCCESSFUL : RTEMS_INVALID_NUMBER;
#if defined(RTEMS_MULTIPROCESSING)
case OBJECTS_REMOTE:
+1 -1
View File
@@ -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(
+70 -42
View File
@@ -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
@@ -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
}
@@ -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
@@ -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 );
}
@@ -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
@@ -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
);
/**@}*/
@@ -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
);
/**
@@ -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 );
}
@@ -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
);
@@ -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
);
@@ -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 );
}
@@ -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
);
@@ -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(
+4 -1
View File
@@ -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
);
+4 -1
View File
@@ -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;
@@ -24,6 +24,7 @@
#include <rtems/score/watchdogimpl.h>
void _Scheduler_CBS_Release_job(
Scheduler_Control *scheduler,
Thread_Control *the_thread,
uint32_t deadline
)
+9 -3
View File
@@ -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 )
@@ -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;
}
@@ -23,19 +23,23 @@
#include <rtems/score/cpusetimpl.h>
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
)
{
const CPU_set_Control *ctl;
(void) scheduler;
(void) thread;
ctl = _CPU_set_Default();
if ( cpusetsize != ctl->setsize ) {
return false;
}
CPU_COPY( cpuset, ctl->set );
return true;
return true;
}
@@ -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;
}
@@ -23,10 +23,14 @@
#include <rtems/score/cpusetimpl.h>
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
)
{
(void) scheduler;
(void) thread;
return _CPU_set_Is_valid( cpuset, cpusetsize );
}
+6 -5
View File
@@ -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 );
}
+7 -4
View File
@@ -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 );
}
}
+4 -2
View File
@@ -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;
}
+1 -1
View File
@@ -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)
+4 -1
View File
@@ -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 ) {
+4 -2
View File
@@ -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
);
}
+2 -1
View File
@@ -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);
+2 -1
View File
@@ -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 );
}
+3 -2
View File
@@ -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);
+4 -1
View File
@@ -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 );
}
@@ -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)
+5 -2
View File
@@ -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 );
}
+3 -1
View File
@@ -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;
+4 -1
View File
@@ -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);
+7 -4
View File
@@ -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 );
}
@@ -31,7 +31,10 @@ _Scheduler_priority_affinity_Get_scheduler_info( Thread_Control *thread )
return ( Scheduler_priority_affinity_SMP_Per_thread * ) thread->scheduler_info;
}
void * _Scheduler_priority_affinity_SMP_Allocate( Thread_Control *the_thread )
void * _Scheduler_priority_affinity_SMP_Allocate(
Scheduler_Control *scheduler,
Thread_Control *the_thread
)
{
Scheduler_priority_affinity_SMP_Per_thread *info =
_Workspace_Allocate( sizeof( *info ) );
@@ -45,14 +48,17 @@ void * _Scheduler_priority_affinity_SMP_Allocate( Thread_Control *the_thread )
}
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
)
{
Scheduler_priority_affinity_SMP_Per_thread *info =
_Scheduler_priority_affinity_Get_scheduler_info(thread);
(void) scheduler;
if ( info->Affinity.setsize != cpusetsize ) {
return false;
}
@@ -62,13 +68,16 @@ bool _Scheduler_priority_affinity_SMP_Get_affinity(
}
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
)
{
Scheduler_priority_affinity_SMP_Per_thread *info =
_Scheduler_priority_affinity_Get_scheduler_info(thread);
(void) scheduler;
if ( ! _CPU_set_Is_valid( cpuset, cpusetsize ) ) {
return false;
+4 -1
View File
@@ -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;

Some files were not shown because too many files have changed in this diff Show More