From e1598a616db1e9dadfd74abeb20b1f1ec5daaa7f Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 4 Apr 2014 10:56:36 +0200 Subject: score: Static scheduler configuration Do not allocate the scheduler control structures from the workspace. This is a preparation step for configuration of clustered/partitioned schedulers on SMP. --- cpukit/score/src/schedulersimplesmp.c | 86 +++++++++++++++++------------------ 1 file changed, 42 insertions(+), 44 deletions(-) (limited to 'cpukit/score/src/schedulersimplesmp.c') diff --git a/cpukit/score/src/schedulersimplesmp.c b/cpukit/score/src/schedulersimplesmp.c index 20a35af07a..5448d5d3de 100644 --- a/cpukit/score/src/schedulersimplesmp.c +++ b/cpukit/score/src/schedulersimplesmp.c @@ -22,35 +22,33 @@ #include #include -static Scheduler_simple_SMP_Control * -_Scheduler_simple_SMP_Self_from_base( Scheduler_Control *base ) +static Scheduler_simple_SMP_Context * +_Scheduler_simple_SMP_Get_context( const Scheduler_Control *scheduler ) { - return (Scheduler_simple_SMP_Control *) base->information; + return (Scheduler_simple_SMP_Context *) scheduler->context; } -static Scheduler_simple_SMP_Control * -_Scheduler_simple_SMP_Self_from_SMP_base( Scheduler_SMP_Control *smp_base ) +static Scheduler_simple_SMP_Context * +_Scheduler_simple_SMP_Self_from_SMP_base( Scheduler_SMP_Context *smp_base ) { - return (Scheduler_simple_SMP_Control *) - ( (char *) smp_base - offsetof( Scheduler_simple_SMP_Control, Base ) ); + return (Scheduler_simple_SMP_Context *) + ( (char *) smp_base - offsetof( Scheduler_simple_SMP_Context, Base ) ); } -void _Scheduler_simple_smp_Initialize( void ) +void _Scheduler_simple_smp_Initialize( const Scheduler_Control *scheduler ) { - Scheduler_simple_SMP_Control *self = - _Workspace_Allocate_or_fatal_error( sizeof( *self ) ); + Scheduler_simple_SMP_Context *self = + _Scheduler_simple_SMP_Get_context( scheduler ); _Scheduler_SMP_Initialize( &self->Base ); _Chain_Initialize_empty( &self->Ready ); - - _Scheduler.information = self; } static Thread_Control *_Scheduler_simple_smp_Get_highest_ready( - Scheduler_SMP_Control *smp_base + Scheduler_SMP_Context *smp_base ) { - Scheduler_simple_SMP_Control *self = + Scheduler_simple_SMP_Context *self = _Scheduler_simple_SMP_Self_from_SMP_base( smp_base ); Thread_Control *highest_ready = NULL; Chain_Control *ready = &self->Ready; @@ -63,11 +61,11 @@ static Thread_Control *_Scheduler_simple_smp_Get_highest_ready( } static void _Scheduler_simple_smp_Move_from_scheduled_to_ready( - Scheduler_SMP_Control *smp_base, + Scheduler_SMP_Context *smp_base, Thread_Control *scheduled_to_ready ) { - Scheduler_simple_SMP_Control *self = + Scheduler_simple_SMP_Context *self = _Scheduler_simple_SMP_Self_from_SMP_base( smp_base ); _Chain_Extract_unprotected( &scheduled_to_ready->Object.Node ); @@ -78,7 +76,7 @@ static void _Scheduler_simple_smp_Move_from_scheduled_to_ready( } static void _Scheduler_simple_smp_Move_from_ready_to_scheduled( - Scheduler_SMP_Control *smp_base, + Scheduler_SMP_Context *smp_base, Thread_Control *ready_to_scheduled ) { @@ -90,11 +88,11 @@ static void _Scheduler_simple_smp_Move_from_ready_to_scheduled( } static void _Scheduler_simple_smp_Insert_ready_lifo( - Scheduler_SMP_Control *smp_base, + Scheduler_SMP_Context *smp_base, Thread_Control *thread ) { - Scheduler_simple_SMP_Control *self = + Scheduler_simple_SMP_Context *self = _Scheduler_simple_SMP_Self_from_SMP_base( smp_base ); _Chain_Insert_ordered_unprotected( @@ -105,11 +103,11 @@ static void _Scheduler_simple_smp_Insert_ready_lifo( } static void _Scheduler_simple_smp_Insert_ready_fifo( - Scheduler_SMP_Control *smp_base, + Scheduler_SMP_Context *smp_base, Thread_Control *thread ) { - Scheduler_simple_SMP_Control *self = + Scheduler_simple_SMP_Context *self = _Scheduler_simple_SMP_Self_from_SMP_base( smp_base ); _Chain_Insert_ordered_unprotected( @@ -120,7 +118,7 @@ static void _Scheduler_simple_smp_Insert_ready_fifo( } static void _Scheduler_simple_smp_Do_extract( - Scheduler_SMP_Control *smp_base, + Scheduler_SMP_Context *smp_base, Thread_Control *thread ) { @@ -133,12 +131,12 @@ static void _Scheduler_simple_smp_Do_extract( } void _Scheduler_simple_smp_Block( - Scheduler_Control *base, + const Scheduler_Control *scheduler, Thread_Control *thread ) { - Scheduler_simple_SMP_Control *self = - _Scheduler_simple_SMP_Self_from_base( base ); + Scheduler_simple_SMP_Context *self = + _Scheduler_simple_SMP_Get_context( scheduler ); _Scheduler_SMP_Block( &self->Base, @@ -150,7 +148,7 @@ void _Scheduler_simple_smp_Block( } static void _Scheduler_simple_smp_Enqueue_ordered( - Scheduler_SMP_Control *smp_base, + Scheduler_SMP_Context *smp_base, Thread_Control *thread, Chain_Node_order order, Scheduler_SMP_Insert insert_ready, @@ -170,12 +168,12 @@ static void _Scheduler_simple_smp_Enqueue_ordered( } void _Scheduler_simple_smp_Enqueue_priority_lifo( - Scheduler_Control *base, + const Scheduler_Control *scheduler, Thread_Control *thread ) { - Scheduler_simple_SMP_Control *self = - _Scheduler_simple_SMP_Self_from_base( base ); + Scheduler_simple_SMP_Context *self = + _Scheduler_simple_SMP_Get_context( scheduler ); _Scheduler_simple_smp_Enqueue_ordered( &self->Base, @@ -187,12 +185,12 @@ void _Scheduler_simple_smp_Enqueue_priority_lifo( } void _Scheduler_simple_smp_Enqueue_priority_fifo( - Scheduler_Control *base, + const Scheduler_Control *scheduler, Thread_Control *thread ) { - Scheduler_simple_SMP_Control *self = - _Scheduler_simple_SMP_Self_from_base( base ); + Scheduler_simple_SMP_Context *self = + _Scheduler_simple_SMP_Get_context( scheduler ); _Scheduler_simple_smp_Enqueue_ordered( &self->Base, @@ -204,12 +202,12 @@ void _Scheduler_simple_smp_Enqueue_priority_fifo( } void _Scheduler_simple_smp_Extract( - Scheduler_Control *base, + const Scheduler_Control *scheduler, Thread_Control *thread ) { - Scheduler_simple_SMP_Control *self = - _Scheduler_simple_SMP_Self_from_base( base ); + Scheduler_simple_SMP_Context *self = + _Scheduler_simple_SMP_Get_context( scheduler ); _Scheduler_SMP_Extract( &self->Base, @@ -219,7 +217,7 @@ void _Scheduler_simple_smp_Extract( } void _Scheduler_simple_smp_Yield( - Scheduler_Control *base, + const Scheduler_Control *scheduler, Thread_Control *thread ) { @@ -227,19 +225,19 @@ void _Scheduler_simple_smp_Yield( _ISR_Disable( level ); - _Scheduler_simple_smp_Extract( base, thread ); - _Scheduler_simple_smp_Enqueue_priority_fifo( base, thread ); + _Scheduler_simple_smp_Extract( scheduler, thread ); + _Scheduler_simple_smp_Enqueue_priority_fifo( scheduler, thread ); _ISR_Enable( level ); } void _Scheduler_simple_smp_Schedule( - Scheduler_Control *base, + const Scheduler_Control *scheduler, Thread_Control *thread ) { - Scheduler_simple_SMP_Control *self = - _Scheduler_simple_SMP_Self_from_base( base ); + Scheduler_simple_SMP_Context *self = + _Scheduler_simple_SMP_Get_context( scheduler ); _Scheduler_SMP_Schedule( &self->Base, @@ -250,13 +248,13 @@ void _Scheduler_simple_smp_Schedule( } void _Scheduler_simple_smp_Start_idle( - Scheduler_Control *base, + const Scheduler_Control *scheduler, Thread_Control *thread, Per_CPU_Control *cpu ) { - Scheduler_simple_SMP_Control *self = - _Scheduler_simple_SMP_Self_from_base( base ); + Scheduler_simple_SMP_Context *self = + _Scheduler_simple_SMP_Get_context( scheduler ); _Scheduler_SMP_Start_idle( &self->Base, thread, cpu ); } -- cgit v1.2.3