mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-21 09:05:06 +08:00
score: Collect scheduler related fields in TCB
Add Thread_Scheduler_control to collect scheduler related fields of the TCB.
This commit is contained in:
@@ -2581,7 +2581,7 @@ const rtems_libio_helper rtems_fs_init_helper =
|
||||
|
||||
const Thread_Control_add_on _Thread_Control_add_ons[] = {
|
||||
{
|
||||
offsetof( Configuration_Thread_control, Control.scheduler_node ),
|
||||
offsetof( Configuration_Thread_control, Control.Scheduler.node ),
|
||||
offsetof( Configuration_Thread_control, Scheduler )
|
||||
}, {
|
||||
offsetof(
|
||||
|
||||
@@ -47,7 +47,7 @@ RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Get(
|
||||
)
|
||||
{
|
||||
#if defined(RTEMS_SMP)
|
||||
return the_thread->scheduler;
|
||||
return the_thread->Scheduler.control;
|
||||
#else
|
||||
(void) the_thread;
|
||||
|
||||
@@ -375,7 +375,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Set(
|
||||
if ( current_scheduler != scheduler ) {
|
||||
_Thread_Set_state( the_thread, STATES_MIGRATING );
|
||||
_Scheduler_Node_destroy( current_scheduler, the_thread );
|
||||
the_thread->scheduler = scheduler;
|
||||
the_thread->Scheduler.control = scheduler;
|
||||
_Scheduler_Node_initialize( scheduler, the_thread );
|
||||
_Scheduler_Update_priority( the_thread, the_thread->current_priority );
|
||||
_Thread_Clear_state( the_thread, STATES_MIGRATING );
|
||||
@@ -649,7 +649,7 @@ RTEMS_INLINE_ROUTINE Scheduler_Node *_Scheduler_Node_get(
|
||||
Thread_Control *the_thread
|
||||
)
|
||||
{
|
||||
return the_thread->scheduler_node;
|
||||
return the_thread->Scheduler.node;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
||||
@@ -420,7 +420,7 @@ static inline void _Scheduler_SMP_Allocate_processor(
|
||||
_Scheduler_SMP_Update_heir( cpu_self, cpu_of_scheduled, scheduled );
|
||||
} else {
|
||||
/* We have to force a migration to our processor set */
|
||||
_Assert( scheduled->debug_real_cpu->heir != scheduled );
|
||||
_Assert( scheduled->Scheduler.debug_real_cpu->heir != scheduled );
|
||||
heir = scheduled;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -445,6 +445,38 @@ typedef struct {
|
||||
Thread_Control *terminator;
|
||||
} Thread_Life_control;
|
||||
|
||||
/**
|
||||
* @brief Thread scheduler control.
|
||||
*/
|
||||
typedef struct {
|
||||
#if defined(RTEMS_SMP)
|
||||
/**
|
||||
* @brief The current scheduler control of this thread.
|
||||
*/
|
||||
const struct Scheduler_Control *control;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The current scheduler node of this thread.
|
||||
*/
|
||||
struct Scheduler_Node *node;
|
||||
|
||||
#if defined(RTEMS_SMP)
|
||||
/**
|
||||
* @brief The processor assigned by the current scheduler.
|
||||
*/
|
||||
Per_CPU_Control *cpu;
|
||||
|
||||
#if defined(RTEMS_DEBUG)
|
||||
/**
|
||||
* @brief The processor on which this thread executed the last time or is
|
||||
* executing.
|
||||
*/
|
||||
Per_CPU_Control *debug_real_cpu;
|
||||
#endif
|
||||
#endif
|
||||
} Thread_Scheduler_control;
|
||||
|
||||
/**
|
||||
* This structure defines the Thread Control Block (TCB).
|
||||
*/
|
||||
@@ -487,12 +519,11 @@ struct Thread_Control_struct {
|
||||
#endif
|
||||
/** This field is true if the thread is preemptible. */
|
||||
bool is_preemptible;
|
||||
#if defined(RTEMS_SMP)
|
||||
|
||||
/**
|
||||
* @brief The scheduler of this thread.
|
||||
* @brief Scheduler related control.
|
||||
*/
|
||||
const struct Scheduler_Control *scheduler;
|
||||
#endif
|
||||
Thread_Scheduler_control Scheduler;
|
||||
|
||||
#if __RTEMS_ADA__
|
||||
/** This field is the GNAT self context pointer. */
|
||||
@@ -515,26 +546,6 @@ struct Thread_Control_struct {
|
||||
*/
|
||||
Thread_CPU_usage_t cpu_time_used;
|
||||
|
||||
/**
|
||||
* @brief The scheduler node of this thread for the real scheduler.
|
||||
*/
|
||||
struct Scheduler_Node *scheduler_node;
|
||||
|
||||
#ifdef RTEMS_SMP
|
||||
/**
|
||||
* @brief The processor assigned by the scheduler.
|
||||
*/
|
||||
Per_CPU_Control *cpu;
|
||||
|
||||
#ifdef RTEMS_DEBUG
|
||||
/**
|
||||
* @brief The processor on which this thread executed the last time or is
|
||||
* executing.
|
||||
*/
|
||||
Per_CPU_Control *debug_real_cpu;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/** This field contains information about the starting state of
|
||||
* this thread.
|
||||
*/
|
||||
|
||||
@@ -408,7 +408,7 @@ RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_Get_CPU(
|
||||
)
|
||||
{
|
||||
#if defined(RTEMS_SMP)
|
||||
return thread->cpu;
|
||||
return thread->Scheduler.cpu;
|
||||
#else
|
||||
(void) thread;
|
||||
|
||||
@@ -422,7 +422,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Set_CPU(
|
||||
)
|
||||
{
|
||||
#if defined(RTEMS_SMP)
|
||||
thread->cpu = cpu;
|
||||
thread->Scheduler.cpu = cpu;
|
||||
#else
|
||||
(void) thread;
|
||||
(void) cpu;
|
||||
@@ -804,7 +804,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Debug_set_real_processor(
|
||||
)
|
||||
{
|
||||
#if defined(RTEMS_SMP) && defined(RTEMS_DEBUG)
|
||||
the_thread->debug_real_cpu = cpu;
|
||||
the_thread->Scheduler.debug_real_cpu = cpu;
|
||||
#else
|
||||
(void) the_thread;
|
||||
(void) cpu;
|
||||
|
||||
@@ -159,6 +159,7 @@ bool _Thread_Initialize(
|
||||
* General initialization
|
||||
*/
|
||||
|
||||
the_thread->Start.isr_level = isr_level;
|
||||
the_thread->Start.is_preemptible = is_preemptible;
|
||||
the_thread->Start.budget_algorithm = budget_algorithm;
|
||||
the_thread->Start.budget_callout = budget_callout;
|
||||
@@ -179,10 +180,8 @@ bool _Thread_Initialize(
|
||||
#endif
|
||||
}
|
||||
|
||||
the_thread->Start.isr_level = isr_level;
|
||||
|
||||
#if defined(RTEMS_SMP)
|
||||
the_thread->scheduler = scheduler;
|
||||
the_thread->Scheduler.control = scheduler;
|
||||
_Resource_Node_initialize( &the_thread->Resource_node );
|
||||
_CPU_Context_Set_is_executing( &the_thread->Registers, false );
|
||||
#endif
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#endif
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/score/threadimpl.h>
|
||||
|
||||
#include "tmacros.h"
|
||||
|
||||
@@ -89,8 +90,8 @@ static bool is_per_cpu_state_ok(void)
|
||||
++count;
|
||||
}
|
||||
|
||||
ok = ok && executing->cpu == cpu;
|
||||
ok = ok && heir->cpu == cpu;
|
||||
ok = ok && _Thread_Get_CPU( executing ) == cpu;
|
||||
ok = ok && _Thread_Get_CPU( heir ) == cpu;
|
||||
}
|
||||
|
||||
ok = ok && (count == 1);
|
||||
|
||||
Reference in New Issue
Block a user