diff options
author | Jennifer Averett <jennifer.averett@oarcorp.com> | 2014-05-09 08:35:58 -0500 |
---|---|---|
committer | Jennifer Averett <jennifer.averett@oarcorp.com> | 2014-05-09 08:37:18 -0500 |
commit | 2d51251192aac8527e773c98047d8597a7f02b8a (patch) | |
tree | f0098e58a37b434d4e8fcecc550e3b810da41379 /schedsim/shell/schedsim_smpsimple | |
parent | schedsim_priority: Remove scenario output files. (diff) | |
download | rtems-schedsim-2d51251192aac8527e773c98047d8597a7f02b8a.tar.bz2 |
schedsim: Add smp support.
Diffstat (limited to 'schedsim/shell/schedsim_smpsimple')
6 files changed, 75 insertions, 49 deletions
diff --git a/schedsim/shell/schedsim_smpsimple/Makefile.am b/schedsim/shell/schedsim_smpsimple/Makefile.am index 19cf617..f4f0404 100644 --- a/schedsim/shell/schedsim_smpsimple/Makefile.am +++ b/schedsim/shell/schedsim_smpsimple/Makefile.am @@ -24,8 +24,15 @@ if HAS_PTHREADS schedsim_smpsimple_CPPFLAGS += -I$(cpukitdir)/posix/include schedsim_smpsimple_CPPFLAGS += -I$(cpukitdir)/posix/inline endif +## Ensure all linker provided symbols are available +schedsim_smpsimple_LDFLAGS = +schedsim_smpsimple_LDFLAGS += -Wl,--defsym=_TLS_Data_begin=0 +schedsim_smpsimple_LDFLAGS += -Wl,--defsym=_TLS_BSS_end=0 +schedsim_smpsimple_LDFLAGS += -Wl,--defsym=_TLS_Alignment=4 + +## Wrap _Thread_Dispatch so we can see context switches +schedsim_smpsimple_LDFLAGS +=-Wl,--wrap=_Thread_Dispatch -schedsim_smpsimple_LDFLAGS =-Wl,--wrap=_Thread_Dispatch ## schedsim_smpsimple_LDADD +=-Wl,--start-group schedsim_smpsimple_LDADD = ../shared/libschedsim.a schedsim_smpsimple_LDADD += ../../rtems/librtems.a diff --git a/schedsim/shell/schedsim_smpsimple/main_current_cpu.c b/schedsim/shell/schedsim_smpsimple/main_current_cpu.c index 73edd3e..5a93a5f 100644 --- a/schedsim/shell/schedsim_smpsimple/main_current_cpu.c +++ b/schedsim/shell/schedsim_smpsimple/main_current_cpu.c @@ -17,7 +17,6 @@ #include "rtems_sched.h" #include <rtems.h> -#include <rtems/bspsmp.h> #include <rtems/score/percpu.h> #include <rtems/score/schedulerpriority.h> diff --git a/schedsim/shell/schedsim_smpsimple/main_dispatch.c b/schedsim/shell/schedsim_smpsimple/main_dispatch.c index 4c1461f..f742a75 100644 --- a/schedsim/shell/schedsim_smpsimple/main_dispatch.c +++ b/schedsim/shell/schedsim_smpsimple/main_dispatch.c @@ -17,7 +17,6 @@ #include "rtems_sched.h" #include <rtems.h> -#include <rtems/bspsmp.h> #include <rtems/score/percpu.h> #include <rtems/score/smp.h> #include <rtems/score/schedulersimplesmp.h> diff --git a/schedsim/shell/schedsim_smpsimple/main_dump_ready_tasks.c b/schedsim/shell/schedsim_smpsimple/main_dump_ready_tasks.c index ba9a9cd..f9edf80 100644 --- a/schedsim/shell/schedsim_smpsimple/main_dump_ready_tasks.c +++ b/schedsim/shell/schedsim_smpsimple/main_dump_ready_tasks.c @@ -17,8 +17,13 @@ #include "rtems_sched.h" #include <rtems/score/chainimpl.h> #include <rtems/score/thread.h> +#include <rtems/score/assert.h> -#include <rtems/score/schedulerpriority.h> +/* + * Note: This source depends upon the scheduler being + * tested. + */ +#include <rtems/score/schedulersimplesmp.h> int main_dump_ready_tasks(int argc, char **argv) { @@ -26,8 +31,14 @@ int main_dump_ready_tasks(int argc, char **argv) Chain_Node *n; Thread_Control *t; + Scheduler_simple_SMP_Context * self = + (Scheduler_simple_SMP_Context *) _Scheduler_Table[0].context; + + /* We don't support this yet */ + _Assert( _Scheduler_Count != 1 ); + printf( "=== Ready Set of Threads\n" ); - chain = (Chain_Control *)_Scheduler.information; + chain = &self->Ready; for (n = _Chain_First( chain ); !_Chain_Is_tail(chain, n); n = n->next) { t = (Thread_Control *)n; printf( diff --git a/schedsim/shell/schedsim_smpsimple/smp_stub.c b/schedsim/shell/schedsim_smpsimple/smp_stub.c index fc9c1dd..7f8f2d4 100644 --- a/schedsim/shell/schedsim_smpsimple/smp_stub.c +++ b/schedsim/shell/schedsim_smpsimple/smp_stub.c @@ -11,25 +11,12 @@ #include <rtems.h> #include <rtems/bspIo.h> -#include <rtems/bspsmp.h> #include <stdlib.h> uint32_t Schedsim_Current_cpu; extern uint32_t Schedsim_Maximum_CPUs_From_Command_Line; -void bsp_smp_secondary_cpu_initialize(int cpu) -{ - Schedsim_Current_cpu = 0; -} - -int bsp_smp_processor_id(void) -{ - return Schedsim_Current_cpu; -} - -uint32_t bsp_smp_initialize( - uint32_t configured_cpu_count -) +uint32_t _CPU_SMP_Initialize( void ) { if ( configured_cpu_count < Schedsim_Maximum_CPUs_From_Command_Line ) { printf( @@ -43,39 +30,42 @@ uint32_t bsp_smp_initialize( return Schedsim_Maximum_CPUs_From_Command_Line; } -void bsp_smp_broadcast_interrupt(void) +bool _CPU_SMP_Start_processor( uint32_t cpu_index ) { + return true; } -void bsp_smp_broadcast_message( - uint32_t message -) +void _CPU_SMP_Finalize_initialization( uint32_t cpu_count ) { } -void bsp_smp_interrupt_cpu( - int cpu -) +void _CPU_SMP_Send_interrupt( uint32_t target_processor_index ) { -} +} -void bsp_smp_delay( int max ) +void _CPU_SMP_Processor_event_broadcast( void ) { + Per_CPU_Control *cpu = _Per_CPU_Get(); + uint32_t cpu_count = _SMP_Get_processor_count(); + uint32_t cpu_index; + Per_CPU_State state = cpu->state; + + if (state == PER_CPU_STATE_REQUEST_START_MULTITASKING) { + for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) { + cpu = _Per_CPU_Get_by_index( cpu_index ); + state = cpu->state; + if (state == PER_CPU_STATE_INITIAL ) + cpu->state = PER_CPU_STATE_READY_TO_START_MULTITASKING; + } + } } -void bsp_smp_wait_for( - volatile unsigned int *address, - unsigned int desired, - int maximum_usecs -) -{ - int iterations; - volatile int i; - volatile unsigned int *p = address; - for (iterations=0 ; iterations < maximum_usecs ; iterations++ ) { - *p = desired; - /* XXX hack to make simulator happy */ - } +void _CPU_SMP_Processor_event_receive( void ) +{ } +uint32_t _CPU_SMP_Get_current_processor( void ) +{ + return Schedsim_Current_cpu; +} diff --git a/schedsim/shell/schedsim_smpsimple/wrap_thread_dispatch.c b/schedsim/shell/schedsim_smpsimple/wrap_thread_dispatch.c index f9f29ee..0edefd1 100644 --- a/schedsim/shell/schedsim_smpsimple/wrap_thread_dispatch.c +++ b/schedsim/shell/schedsim_smpsimple/wrap_thread_dispatch.c @@ -12,29 +12,49 @@ #include "shell.h" #include <schedsim_shell.h> +#include <stdlib.h> #include <stdio.h> #include <rtems.h> -Thread_Control *last_heir = NULL; -Thread_Control *last_executing = NULL; +typedef Thread_Control * Thread_Control_ptr; +extern uint32_t Schedsim_Current_cpu; + +Thread_Control_ptr *last_heir = NULL; +Thread_Control_ptr *last_executing = NULL; extern void __real__Thread_Dispatch(void); +void Init__wrap__Thread_Dispatch() +{ + last_heir = (Thread_Control_ptr *) calloc( sizeof( Thread_Control_ptr ), _SMP_Processor_count ); + last_executing = (Thread_Control_ptr *) calloc( sizeof( Thread_Control_ptr ), _SMP_Processor_count ); +} + void check_heir_and_executing(void) { - if ( last_heir != _Thread_Heir ) + if ( last_heir[Schedsim_Current_cpu] != _Thread_Heir ) PRINT_HEIR(); - if ( last_executing != _Thread_Executing ) + if ( last_executing[Schedsim_Current_cpu] != _Thread_Executing ) PRINT_EXECUTING(); - last_heir = _Thread_Heir; - last_executing = _Thread_Executing; + last_heir[Schedsim_Current_cpu] = _Thread_Heir; + last_executing[Schedsim_Current_cpu] = _Thread_Executing; } void __wrap__Thread_Dispatch(void) { - check_heir_and_executing(); + uint32_t cpu; + uint32_t current_cpu; + + current_cpu = Schedsim_Current_cpu; + for ( cpu=0 ; cpu < _SMP_Processor_count ; cpu++ ) { + Schedsim_Current_cpu = cpu; + check_heir_and_executing(); __real__Thread_Dispatch(); - check_heir_and_executing(); + check_heir_and_executing(); + } + + Schedsim_Current_cpu = current_cpu; } + |