forked from Imagelibrary/rtems
score: Introduce Thread_Scheduler_control::home
Replace Thread_Scheduler_control::control and Thread_Scheduler_control::own_control with new Thread_Scheduler_control::home. Update #2556.
This commit is contained in:
@@ -872,7 +872,7 @@ rtems_capture_task_control_flags (rtems_tcb* tcb)
|
||||
static inline rtems_task_priority
|
||||
rtems_capture_task_start_priority (rtems_tcb* tcb)
|
||||
{
|
||||
return _RTEMS_Priority_From_core (_Scheduler_Get_own( tcb ),
|
||||
return _RTEMS_Priority_From_core (_Thread_Scheduler_get_home( tcb ),
|
||||
tcb->Start.initial_priority);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ static bool CPU_usage_Per_thread_handler(
|
||||
ISR_lock_Context scheduler_lock_context;
|
||||
|
||||
_Thread_State_acquire( the_thread, &state_lock_context );
|
||||
scheduler = _Scheduler_Get( the_thread );
|
||||
scheduler = _Thread_Scheduler_get_home( the_thread );
|
||||
_Scheduler_Acquire_critical( scheduler, &scheduler_lock_context );
|
||||
|
||||
_Timestamp_Set_to_zero( &the_thread->cpu_time_used );
|
||||
|
||||
@@ -110,7 +110,7 @@ int pthread_mutex_init(
|
||||
int prio_ceiling;
|
||||
bool valid;
|
||||
|
||||
scheduler = _Scheduler_Get_own( _Thread_Get_executing() );
|
||||
scheduler = _Thread_Scheduler_get_home( _Thread_Get_executing() );
|
||||
prio_ceiling = the_attr->prio_ceiling;
|
||||
|
||||
if ( prio_ceiling == INT_MAX ) {
|
||||
|
||||
@@ -168,7 +168,7 @@ static bool _POSIX_Threads_Create_extension(
|
||||
api->thread = created;
|
||||
_POSIX_Threads_Initialize_attributes( &api->Attributes );
|
||||
api->Attributes.schedparam.sched_priority = _POSIX_Priority_From_core(
|
||||
_Scheduler_Get_own( created ),
|
||||
_Thread_Scheduler_get_home( created ),
|
||||
_Thread_Get_priority( created )
|
||||
);
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ int pthread_create(
|
||||
|
||||
normal_prio = schedparam.sched_priority;
|
||||
|
||||
scheduler = _Scheduler_Get_own( executing );
|
||||
scheduler = _Thread_Scheduler_get_home( executing );
|
||||
|
||||
core_normal_prio = _POSIX_Priority_To_core( scheduler, normal_prio, &valid );
|
||||
if ( !valid ) {
|
||||
|
||||
@@ -58,7 +58,7 @@ int pthread_getschedparam(
|
||||
*policy = api->Attributes.schedpolicy;
|
||||
*param = api->Attributes.schedparam;
|
||||
|
||||
scheduler = _Scheduler_Get_own( the_thread );
|
||||
scheduler = _Thread_Scheduler_get_home( the_thread );
|
||||
priority = the_thread->Real_priority.priority;
|
||||
|
||||
_Thread_Wait_release( the_thread, &queue_context );
|
||||
|
||||
@@ -55,7 +55,7 @@ static int _POSIX_Set_sched_param(
|
||||
high_prio = low_prio;
|
||||
}
|
||||
|
||||
scheduler = _Scheduler_Get_own( the_thread );
|
||||
scheduler = _Thread_Scheduler_get_home( the_thread );
|
||||
|
||||
core_normal_prio = _POSIX_Priority_To_core( scheduler, low_prio, &valid );
|
||||
if ( !valid ) {
|
||||
|
||||
@@ -36,7 +36,7 @@ int pthread_setschedprio( pthread_t thread, int prio )
|
||||
_Thread_queue_Context_clear_priority_updates( &queue_context );
|
||||
_Thread_Wait_acquire_critical( the_thread, &queue_context );
|
||||
|
||||
scheduler = _Scheduler_Get_own( the_thread );
|
||||
scheduler = _Thread_Scheduler_get_home( the_thread );
|
||||
|
||||
new_priority = _POSIX_Priority_To_core( scheduler, prio, &valid );
|
||||
if ( !valid ) {
|
||||
|
||||
@@ -43,6 +43,6 @@ int sched_get_priority_max(
|
||||
rtems_set_errno_and_return_minus_one( EINVAL );
|
||||
}
|
||||
|
||||
scheduler = _Scheduler_Get_own( _Thread_Get_executing() );
|
||||
scheduler = _Thread_Scheduler_get_home( _Thread_Get_executing() );
|
||||
return _POSIX_Priority_Get_maximum( scheduler );
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ rtems_status_code rtems_semaphore_create(
|
||||
status = STATUS_SUCCESSFUL;
|
||||
break;
|
||||
case SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING:
|
||||
scheduler = _Scheduler_Get_own( executing );
|
||||
scheduler = _Thread_Scheduler_get_home( executing );
|
||||
priority = _RTEMS_Priority_To_core( scheduler, priority_ceiling, &valid );
|
||||
|
||||
if ( valid ) {
|
||||
@@ -195,7 +195,7 @@ rtems_status_code rtems_semaphore_create(
|
||||
break;
|
||||
#if defined(RTEMS_SMP)
|
||||
case SEMAPHORE_VARIANT_MRSP:
|
||||
scheduler = _Scheduler_Get_own( executing );
|
||||
scheduler = _Thread_Scheduler_get_home( executing );
|
||||
priority = _RTEMS_Priority_To_core( scheduler, priority_ceiling, &valid );
|
||||
|
||||
if ( valid ) {
|
||||
|
||||
@@ -46,7 +46,7 @@ rtems_status_code rtems_task_get_scheduler(
|
||||
|
||||
_Thread_State_acquire_critical( the_thread, &lock_context );
|
||||
|
||||
scheduler = _Scheduler_Get( the_thread );
|
||||
scheduler = _Thread_Scheduler_get_home( the_thread );
|
||||
*scheduler_id = _Scheduler_Build_id( _Scheduler_Get_index( scheduler ) );
|
||||
|
||||
_Thread_State_release( the_thread, &lock_context );
|
||||
|
||||
@@ -90,7 +90,7 @@ rtems_status_code rtems_task_set_priority(
|
||||
|
||||
_Thread_Wait_acquire_critical( the_thread, &queue_context );
|
||||
|
||||
scheduler = _Scheduler_Get_own( the_thread );
|
||||
scheduler = _Thread_Scheduler_get_home( the_thread );
|
||||
old_priority = _Thread_Get_priority( the_thread );
|
||||
|
||||
if ( new_priority != RTEMS_CURRENT_PRIORITY ) {
|
||||
|
||||
@@ -332,7 +332,7 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Seize(
|
||||
if ( owner == NULL ) {
|
||||
#if defined(RTEMS_SMP)
|
||||
if (
|
||||
_Scheduler_Get_own( executing )
|
||||
_Thread_Scheduler_get_home( executing )
|
||||
!= _CORE_ceiling_mutex_Get_scheduler( the_mutex )
|
||||
) {
|
||||
_CORE_mutex_Release( &the_mutex->Recursive.Mutex, queue_context );
|
||||
|
||||
@@ -105,7 +105,7 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Raise_priority(
|
||||
_Thread_queue_Context_clear_priority_updates( queue_context );
|
||||
_Thread_Wait_acquire_default_critical( thread, &lock_context );
|
||||
|
||||
scheduler = _Scheduler_Get_own( thread );
|
||||
scheduler = _Thread_Scheduler_get_home( thread );
|
||||
scheduler_node = _Thread_Scheduler_get_home_node( thread );
|
||||
ceiling_priority = _MRSP_Get_priority( mrsp, scheduler );
|
||||
|
||||
|
||||
@@ -53,32 +53,6 @@ RTEMS_INLINE_ROUTINE Scheduler_Context *_Scheduler_Get_context(
|
||||
return scheduler->context;
|
||||
}
|
||||
|
||||
RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Get(
|
||||
const Thread_Control *the_thread
|
||||
)
|
||||
{
|
||||
#if defined(RTEMS_SMP)
|
||||
return the_thread->Scheduler.control;
|
||||
#else
|
||||
(void) the_thread;
|
||||
|
||||
return &_Scheduler_Table[ 0 ];
|
||||
#endif
|
||||
}
|
||||
|
||||
RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Get_own(
|
||||
const Thread_Control *the_thread
|
||||
)
|
||||
{
|
||||
#if defined(RTEMS_SMP)
|
||||
return the_thread->Scheduler.own_control;
|
||||
#else
|
||||
(void) the_thread;
|
||||
|
||||
return &_Scheduler_Table[ 0 ];
|
||||
#endif
|
||||
}
|
||||
|
||||
RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Get_by_CPU_index(
|
||||
uint32_t cpu_index
|
||||
)
|
||||
@@ -177,7 +151,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Schedule( Thread_Control *the_thread )
|
||||
const Scheduler_Control *scheduler;
|
||||
ISR_lock_Context lock_context;
|
||||
|
||||
scheduler = _Scheduler_Get( the_thread );
|
||||
scheduler = _Thread_Scheduler_get_home( the_thread );
|
||||
_Scheduler_Acquire_critical( scheduler, &lock_context );
|
||||
|
||||
( *scheduler->Operations.schedule )( scheduler, the_thread );
|
||||
@@ -246,7 +220,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Yield( Thread_Control *the_thread )
|
||||
#else
|
||||
const Scheduler_Control *scheduler;
|
||||
|
||||
scheduler = _Scheduler_Get( the_thread );
|
||||
scheduler = _Thread_Scheduler_get_home( the_thread );
|
||||
( *scheduler->Operations.yield )(
|
||||
scheduler,
|
||||
the_thread,
|
||||
@@ -308,7 +282,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Block( Thread_Control *the_thread )
|
||||
#else
|
||||
const Scheduler_Control *scheduler;
|
||||
|
||||
scheduler = _Scheduler_Get( the_thread );
|
||||
scheduler = _Thread_Scheduler_get_home( the_thread );
|
||||
( *scheduler->Operations.block )(
|
||||
scheduler,
|
||||
the_thread,
|
||||
@@ -380,7 +354,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Unblock( Thread_Control *the_thread )
|
||||
#else
|
||||
const Scheduler_Control *scheduler;
|
||||
|
||||
scheduler = _Scheduler_Get( the_thread );
|
||||
scheduler = _Thread_Scheduler_get_home( the_thread );
|
||||
( *scheduler->Operations.unblock )(
|
||||
scheduler,
|
||||
the_thread,
|
||||
@@ -435,7 +409,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Update_priority( Thread_Control *the_thread
|
||||
#else
|
||||
const Scheduler_Control *scheduler;
|
||||
|
||||
scheduler = _Scheduler_Get( the_thread );
|
||||
scheduler = _Thread_Scheduler_get_home( the_thread );
|
||||
( *scheduler->Operations.update_priority )(
|
||||
scheduler,
|
||||
the_thread,
|
||||
@@ -601,7 +575,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Release_job(
|
||||
Thread_queue_Context *queue_context
|
||||
)
|
||||
{
|
||||
const Scheduler_Control *scheduler = _Scheduler_Get( the_thread );
|
||||
const Scheduler_Control *scheduler = _Thread_Scheduler_get_home( the_thread );
|
||||
|
||||
_Thread_queue_Context_clear_priority_updates( queue_context );
|
||||
( *scheduler->Operations.release_job )(
|
||||
@@ -627,7 +601,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Cancel_job(
|
||||
Thread_queue_Context *queue_context
|
||||
)
|
||||
{
|
||||
const Scheduler_Control *scheduler = _Scheduler_Get( the_thread );
|
||||
const Scheduler_Control *scheduler = _Thread_Scheduler_get_home( the_thread );
|
||||
|
||||
_Thread_queue_Context_clear_priority_updates( queue_context );
|
||||
( *scheduler->Operations.cancel_job )(
|
||||
@@ -1283,7 +1257,7 @@ RTEMS_INLINE_ROUTINE Status_Control _Scheduler_Set(
|
||||
{
|
||||
const Scheduler_Control *old_scheduler;
|
||||
|
||||
old_scheduler = _Scheduler_Get( the_thread );
|
||||
old_scheduler = _Thread_Scheduler_get_home( the_thread );
|
||||
|
||||
if ( old_scheduler != new_scheduler ) {
|
||||
States_Control current_state;
|
||||
@@ -1312,8 +1286,7 @@ RTEMS_INLINE_ROUTINE Status_Control _Scheduler_Set(
|
||||
&new_scheduler_node->Thread.Scheduler_node.Chain
|
||||
);
|
||||
|
||||
the_thread->Scheduler.own_control = new_scheduler;
|
||||
the_thread->Scheduler.control = new_scheduler;
|
||||
the_thread->Scheduler.home = new_scheduler;
|
||||
_Scheduler_Node_set_priority( new_scheduler_node, priority, false );
|
||||
|
||||
if ( _States_Is_ready( current_state ) ) {
|
||||
|
||||
@@ -255,18 +255,9 @@ typedef struct {
|
||||
Thread_Scheduler_state state;
|
||||
|
||||
/**
|
||||
* @brief The own scheduler control of this thread.
|
||||
*
|
||||
* This field is constant after initialization.
|
||||
* @brief The home scheduler control of this thread.
|
||||
*/
|
||||
const struct Scheduler_Control *own_control;
|
||||
|
||||
/**
|
||||
* @brief The scheduler control of this thread.
|
||||
*
|
||||
* The scheduler helping protocol may change this field.
|
||||
*/
|
||||
const struct Scheduler_Control *control;
|
||||
const struct Scheduler_Control *home;
|
||||
|
||||
/**
|
||||
* @brief The processor assigned by the current scheduler.
|
||||
|
||||
@@ -1005,6 +1005,18 @@ RTEMS_INLINE_ROUTINE void _Thread_Scheduler_cancel_need_for_help(
|
||||
}
|
||||
#endif
|
||||
|
||||
RTEMS_INLINE_ROUTINE const Scheduler_Control *_Thread_Scheduler_get_home(
|
||||
const Thread_Control *the_thread
|
||||
)
|
||||
{
|
||||
#if defined(RTEMS_SMP)
|
||||
return the_thread->Scheduler.home;
|
||||
#else
|
||||
(void) the_thread;
|
||||
return &_Scheduler_Table[ 0 ];
|
||||
#endif
|
||||
}
|
||||
|
||||
RTEMS_INLINE_ROUTINE Scheduler_Node *_Thread_Scheduler_get_home_node(
|
||||
const Thread_Control *the_thread
|
||||
)
|
||||
|
||||
@@ -31,7 +31,7 @@ int _Sched_Index( void )
|
||||
{
|
||||
Thread_Control *executing = _Thread_Get_executing();
|
||||
|
||||
return (int) _Scheduler_Get_index( _Scheduler_Get( executing ) );
|
||||
return (int) _Scheduler_Get_index( _Thread_Scheduler_get_home( executing ) );
|
||||
}
|
||||
|
||||
int _Sched_Name_to_index( const char *name, size_t len )
|
||||
|
||||
@@ -34,7 +34,7 @@ bool _Scheduler_Get_affinity(
|
||||
return false;
|
||||
}
|
||||
|
||||
scheduler = _Scheduler_Get( the_thread );
|
||||
scheduler = _Thread_Scheduler_get_home( the_thread );
|
||||
_Scheduler_Acquire_critical( scheduler, &lock_context );
|
||||
|
||||
#if defined(RTEMS_SMP)
|
||||
|
||||
@@ -34,7 +34,7 @@ bool _Scheduler_Set_affinity(
|
||||
return false;
|
||||
}
|
||||
|
||||
scheduler = _Scheduler_Get( the_thread );
|
||||
scheduler = _Thread_Scheduler_get_home( the_thread );
|
||||
_Scheduler_Acquire_critical( scheduler, &lock_context );
|
||||
|
||||
#if defined(RTEMS_SMP)
|
||||
|
||||
@@ -38,7 +38,7 @@ void _Thread_Get_CPU_time_used(
|
||||
ISR_lock_Context scheduler_lock_context;
|
||||
|
||||
_Thread_State_acquire( the_thread, &state_lock_context );
|
||||
scheduler = _Scheduler_Get( the_thread );
|
||||
scheduler = _Thread_Scheduler_get_home( the_thread );
|
||||
_Scheduler_Acquire_critical( scheduler, &scheduler_lock_context );
|
||||
|
||||
if ( _Thread_Is_scheduled( the_thread ) ) {
|
||||
|
||||
@@ -232,8 +232,7 @@ bool _Thread_Initialize(
|
||||
|
||||
#if defined(RTEMS_SMP)
|
||||
RTEMS_STATIC_ASSERT( THREAD_SCHEDULER_BLOCKED == 0, Scheduler_state );
|
||||
the_thread->Scheduler.own_control = scheduler;
|
||||
the_thread->Scheduler.control = scheduler;
|
||||
the_thread->Scheduler.home = scheduler;
|
||||
_ISR_lock_Initialize( &the_thread->Scheduler.Lock, "Thread Scheduler" );
|
||||
_ISR_lock_Initialize( &the_thread->Wait.Lock.Default, "Thread Wait Default" );
|
||||
_Thread_queue_Gate_open( &the_thread->Wait.Lock.Tranquilizer );
|
||||
|
||||
@@ -169,7 +169,7 @@ static void _Thread_Free( Thread_Control *the_thread )
|
||||
_User_extensions_Destroy_iterators( the_thread );
|
||||
_ISR_lock_Destroy( &the_thread->Keys.Lock );
|
||||
_Scheduler_Node_destroy(
|
||||
_Scheduler_Get( the_thread ),
|
||||
_Thread_Scheduler_get_home( the_thread ),
|
||||
_Thread_Scheduler_get_home_node( the_thread )
|
||||
);
|
||||
_ISR_lock_Destroy( &the_thread->Timer.Lock );
|
||||
|
||||
@@ -214,7 +214,7 @@ static void update_priority_op(
|
||||
apply_priority(thread, new_priority, prepend_it, &queue_context);
|
||||
|
||||
_Thread_State_acquire( thread, &state_lock_context );
|
||||
scheduler = _Scheduler_Get( thread );
|
||||
scheduler = _Thread_Scheduler_get_home( thread );
|
||||
_Scheduler_Acquire_critical( scheduler, &scheduler_lock_context );
|
||||
|
||||
(*scheduler->Operations.update_priority)(
|
||||
@@ -325,7 +325,7 @@ static Thread_Control *yield_op(
|
||||
Thread_Control *needs_help;
|
||||
|
||||
_Thread_State_acquire( thread, &state_lock_context );
|
||||
scheduler = _Scheduler_Get( thread );
|
||||
scheduler = _Thread_Scheduler_get_home( thread );
|
||||
_Scheduler_Acquire_critical( scheduler, &scheduler_lock_context );
|
||||
|
||||
needs_help = (*scheduler->Operations.yield)(
|
||||
@@ -464,7 +464,7 @@ static void block_op(
|
||||
ISR_lock_Context scheduler_lock_context;
|
||||
|
||||
_Thread_State_acquire( thread, &state_lock_context );
|
||||
scheduler = _Scheduler_Get( thread );
|
||||
scheduler = _Thread_Scheduler_get_home( thread );
|
||||
_Scheduler_Acquire_critical( scheduler, &scheduler_lock_context );
|
||||
|
||||
(*scheduler->Operations.block)(scheduler, thread, &scheduler_node->Base);
|
||||
@@ -484,7 +484,7 @@ static Thread_Control *unblock_op(
|
||||
Thread_Control *needs_help;
|
||||
|
||||
_Thread_State_acquire( thread, &state_lock_context );
|
||||
scheduler = _Scheduler_Get( thread );
|
||||
scheduler = _Thread_Scheduler_get_home( thread );
|
||||
_Scheduler_Acquire_critical( scheduler, &scheduler_lock_context );
|
||||
|
||||
needs_help = (*scheduler->Operations.unblock)(
|
||||
|
||||
@@ -316,7 +316,7 @@ rtems_task Middle_task(
|
||||
)
|
||||
{
|
||||
Scheduler_priority_Context *scheduler_context =
|
||||
_Scheduler_priority_Get_context( _Scheduler_Get( _Thread_Get_executing() ) );
|
||||
_Scheduler_priority_Get_context( _Thread_Scheduler_get_home( _Thread_Get_executing() ) );
|
||||
|
||||
thread_dispatch_no_fp_time = benchmark_timer_read();
|
||||
|
||||
@@ -349,7 +349,7 @@ rtems_task Low_task(
|
||||
)
|
||||
{
|
||||
Scheduler_priority_Context *scheduler_context =
|
||||
_Scheduler_priority_Get_context( _Scheduler_Get( _Thread_Get_executing() ) );
|
||||
_Scheduler_priority_Get_context( _Thread_Scheduler_get_home( _Thread_Get_executing() ) );
|
||||
Thread_Control *executing;
|
||||
|
||||
context_switch_no_fp_time = benchmark_timer_read();
|
||||
@@ -389,7 +389,7 @@ rtems_task Floating_point_task_1(
|
||||
)
|
||||
{
|
||||
Scheduler_priority_Context *scheduler_context =
|
||||
_Scheduler_priority_Get_context( _Scheduler_Get( _Thread_Get_executing() ) );
|
||||
_Scheduler_priority_Get_context( _Thread_Scheduler_get_home( _Thread_Get_executing() ) );
|
||||
Thread_Control *executing;
|
||||
FP_DECLARE;
|
||||
|
||||
@@ -445,7 +445,7 @@ rtems_task Floating_point_task_2(
|
||||
)
|
||||
{
|
||||
Scheduler_priority_Context *scheduler_context =
|
||||
_Scheduler_priority_Get_context( _Scheduler_Get( _Thread_Get_executing() ) );
|
||||
_Scheduler_priority_Get_context( _Thread_Scheduler_get_home( _Thread_Get_executing() ) );
|
||||
Thread_Control *executing;
|
||||
FP_DECLARE;
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ rtems_task Task_1(
|
||||
)
|
||||
{
|
||||
Scheduler_priority_Context *scheduler_context =
|
||||
_Scheduler_priority_Get_context( _Scheduler_Get( _Thread_Get_executing() ) );
|
||||
_Scheduler_priority_Get_context( _Thread_Scheduler_get_home( _Thread_Get_executing() ) );
|
||||
#if defined(RTEMS_SMP)
|
||||
rtems_interrupt_level level;
|
||||
#endif
|
||||
@@ -231,7 +231,7 @@ rtems_task Task_2(
|
||||
ISR_lock_Context scheduler_lock_context;
|
||||
|
||||
_Thread_State_acquire( executing, &state_lock_context );
|
||||
scheduler = _Scheduler_Get( executing );
|
||||
scheduler = _Thread_Scheduler_get_home( executing );
|
||||
scheduler_context = _Scheduler_priority_Get_context( scheduler );
|
||||
_Thread_State_release( executing, &state_lock_context );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user