From 246b81f0202b684d5e2b4278fbbe364fee10edcf Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 26 May 2014 12:55:18 -0500 Subject: dispatch is now a shared SMP command --- schedsim/shell/schedsim_smppriority/Makefile.am | 1 - .../schedsim_smppriority_affinity/Makefile.am | 1 - schedsim/shell/schedsim_smpsimple/Makefile.am | 1 - schedsim/shell/schedsim_smpsimple/add_commands.c | 10 ---- schedsim/shell/schedsim_smpsimple/main_dispatch.c | 43 ---------------- schedsim/shell/shared/Makefile.am | 1 + schedsim/shell/shared/commands.c | 3 ++ schedsim/shell/shared/main_dispatch.c | 57 ++++++++++++++++++++++ 8 files changed, 61 insertions(+), 56 deletions(-) delete mode 100644 schedsim/shell/schedsim_smpsimple/main_dispatch.c create mode 100644 schedsim/shell/shared/main_dispatch.c diff --git a/schedsim/shell/schedsim_smppriority/Makefile.am b/schedsim/shell/schedsim_smppriority/Makefile.am index 16bba41..d4197a4 100644 --- a/schedsim/shell/schedsim_smppriority/Makefile.am +++ b/schedsim/shell/schedsim_smppriority/Makefile.am @@ -2,7 +2,6 @@ bin_PROGRAMS = schedsim_smppriority SOURCES = config.c SOURCES += $(srcdir)/../schedsim_smpsimple/add_commands.c -SOURCES += $(srcdir)/../schedsim_smpsimple/main_dispatch.c SOURCES += $(srcdir)/../schedsim_smpsimple/main_dump_ready_tasks.c SOURCES += $(srcdir)/../schedsim_smpsimple/printheir_executing.c SOURCES += $(srcdir)/../schedsim_smpsimple/wrap_thread_dispatch.c diff --git a/schedsim/shell/schedsim_smppriority_affinity/Makefile.am b/schedsim/shell/schedsim_smppriority_affinity/Makefile.am index 839d9d4..2a9a2b3 100644 --- a/schedsim/shell/schedsim_smppriority_affinity/Makefile.am +++ b/schedsim/shell/schedsim_smppriority_affinity/Makefile.am @@ -2,7 +2,6 @@ bin_PROGRAMS = schedsim_smppriority_affinity SOURCES = config.c SOURCES += $(srcdir)/../schedsim_smpsimple/add_commands.c -SOURCES += $(srcdir)/../schedsim_smpsimple/main_dispatch.c SOURCES += $(srcdir)/../schedsim_smpsimple/main_dump_ready_tasks.c SOURCES += $(srcdir)/../schedsim_smpsimple/printheir_executing.c SOURCES += $(srcdir)/../schedsim_smpsimple/wrap_thread_dispatch.c diff --git a/schedsim/shell/schedsim_smpsimple/Makefile.am b/schedsim/shell/schedsim_smpsimple/Makefile.am index a7c7237..b0f9bb1 100644 --- a/schedsim/shell/schedsim_smpsimple/Makefile.am +++ b/schedsim/shell/schedsim_smpsimple/Makefile.am @@ -2,7 +2,6 @@ bin_PROGRAMS = schedsim_smpsimple schedsim_smpsimple_SOURCES = schedsim_smpsimple_SOURCES += add_commands.c schedsim_smpsimple_SOURCES += config.c -schedsim_smpsimple_SOURCES += main_dispatch.c schedsim_smpsimple_SOURCES += main_dump_ready_tasks.c schedsim_smpsimple_SOURCES += printheir_executing.c schedsim_smpsimple_SOURCES += wrap_thread_dispatch.c diff --git a/schedsim/shell/schedsim_smpsimple/add_commands.c b/schedsim/shell/schedsim_smpsimple/add_commands.c index f975da7..1221df5 100644 --- a/schedsim/shell/schedsim_smpsimple/add_commands.c +++ b/schedsim/shell/schedsim_smpsimple/add_commands.c @@ -18,7 +18,6 @@ #include "rtems_sched.h" extern int main_dump_ready_tasks(int argc, char **argv); -extern int main_dispatch(int argc, char **argv); void add_commands(void) { @@ -31,13 +30,4 @@ void add_commands(void) main_dump_ready_tasks ); assert( cmd ); - - cmd = rtems_shell_add_cmd( - "dispatch", - "rtems", - "", - main_dispatch - ); - assert( cmd ); - } diff --git a/schedsim/shell/schedsim_smpsimple/main_dispatch.c b/schedsim/shell/schedsim_smpsimple/main_dispatch.c deleted file mode 100644 index 88c3856..0000000 --- a/schedsim/shell/schedsim_smpsimple/main_dispatch.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * COPYRIGHT (c) 1989-2013. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.com/license/LICENSE. - */ - -#include -#include -#include -#include -#include - -#include "shell.h" -#include "rtems_sched.h" - -#include -#include -#include -#include -#include - -extern uint32_t Schedsim_Current_cpu; - -int main_dispatch(int argc, char **argv) -{ - uint32_t cpu; - uint32_t current_cpu; - - current_cpu = Schedsim_Current_cpu; - for ( cpu=0 ; cpu < _SMP_Processor_count ; cpu++ ) { - if ( _Per_CPU_Information[cpu].per_cpu.dispatch_necessary ) { - printf( "=== Invoke Thread Dispatch on CPU %d\n", cpu ); - Schedsim_Current_cpu = cpu; - _Thread_Dispatch(); - } - } - - Schedsim_Current_cpu = current_cpu; - return 0; -} diff --git a/schedsim/shell/shared/Makefile.am b/schedsim/shell/shared/Makefile.am index c90824e..6940f41 100644 --- a/schedsim/shell/shared/Makefile.am +++ b/schedsim/shell/shared/Makefile.am @@ -54,6 +54,7 @@ libschedsim_a_SOURCES += shell_makeargs.c if HAS_SMP libschedsim_a_SOURCES += smp_stub.c libschedsim_a_SOURCES += main_currentcpu.c +libschedsim_a_SOURCES += main_dispatch.c libschedsim_a_SOURCES += main_taskgetaffinity.c libschedsim_a_SOURCES += main_tasksetaffinity.c endif diff --git a/schedsim/shell/shared/commands.c b/schedsim/shell/shared/commands.c index 483c7ef..5a75181 100644 --- a/schedsim/shell/shared/commands.c +++ b/schedsim/shell/shared/commands.c @@ -35,6 +35,7 @@ extern rtems_shell_cmd_t rtems_shell_TASK_WAKE_AFTER_Command; extern rtems_shell_cmd_t rtems_shell_TASK_GET_AFFINITY_Command; extern rtems_shell_cmd_t rtems_shell_TASK_SET_AFFINITY_Command; extern rtems_shell_cmd_t rtems_shell_CURRENT_CPU_Command; + extern rtems_shell_cmd_t rtems_shell_DISPATCH_Command; #endif extern rtems_shell_cmd_t rtems_shell_CLOCK_TICK_Command; @@ -49,6 +50,7 @@ extern rtems_shell_cmd_t rtems_shell_TASK_EXECUTING_Command; extern rtems_shell_cmd_t rtems_shell_TASK_HEIR_Command; extern rtems_shell_cmd_t rtems_shell_CPUS_Command; + rtems_shell_cmd_t *rtems_shell_Initial_commands[] = { /* Generic Commands */ &rtems_shell_ECHO_Command, @@ -67,6 +69,7 @@ rtems_shell_cmd_t *rtems_shell_Initial_commands[] = { &rtems_shell_TASK_GET_AFFINITY_Command, &rtems_shell_TASK_SET_AFFINITY_Command, &rtems_shell_CURRENT_CPU_Command, + &rtems_shell_DISPATCH_Command, #endif &rtems_shell_CLOCK_TICK_Command, diff --git a/schedsim/shell/shared/main_dispatch.c b/schedsim/shell/shared/main_dispatch.c new file mode 100644 index 0000000..abb7050 --- /dev/null +++ b/schedsim/shell/shared/main_dispatch.c @@ -0,0 +1,57 @@ +/** + * @file + * @brief Invoke Dispatch on all Cores Command + */ + +/* + * COPYRIGHT (c) 1989-2014. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#include +#include +#include +#include +#include + +#include "shell.h" +#include "rtems_sched.h" + +#include +#include +#include +#include +#include + +extern uint32_t Schedsim_Current_cpu; + +int rtems_shell_main_dispatch(int argc, char **argv) +{ + uint32_t cpu; + uint32_t current_cpu; + + current_cpu = Schedsim_Current_cpu; + for ( cpu=0 ; cpu < _SMP_Processor_count ; cpu++ ) { + if ( _Per_CPU_Information[cpu].per_cpu.dispatch_necessary ) { + printf( "=== Invoke Thread Dispatch on CPU %d\n", cpu ); + Schedsim_Current_cpu = cpu; + _Thread_Dispatch(); + } + } + + Schedsim_Current_cpu = current_cpu; + return 0; +} + +rtems_shell_cmd_t rtems_shell_DISPATCH_Command = { + "dispatch", /* name */ + "dispatch", /* usage */ + "rtems", /* topic */ + rtems_shell_main_dispatch, /* command */ + NULL, /* alias */ + NULL /* next */ +}; -- cgit v1.2.3