From 6f48a61527f4fad2244d7d8bfa67795d042c7fef Mon Sep 17 00:00:00 2001 From: Jennifer Averett Date: Tue, 17 Jun 2014 12:03:25 -0500 Subject: Add remainder of schedulers and cluster scheduler support. --- schedsim/UsingTheSchedulerSimulator.txt | 26 ++++- schedsim/configure.ac | 4 + schedsim/rtems/Makefile.am | 33 +++++++ schedsim/shell/Makefile.am | 23 ++++- schedsim/shell/schedsim_cbs/Makefile.am | 49 ++++++++++ schedsim/shell/schedsim_cbs/config.c | 14 +++ schedsim/shell/schedsim_cluster01/Makefile.am | 61 ++++++++++++ schedsim/shell/schedsim_cluster01/config.c | 47 +++++++++ schedsim/shell/schedsim_cluster02/Makefile.am | 61 ++++++++++++ schedsim/shell/schedsim_cluster02/config.c | 49 ++++++++++ schedsim/shell/schedsim_edf/Makefile.am | 49 ++++++++++ schedsim/shell/schedsim_edf/config.c | 14 +++ schedsim/shell/schedsim_priority/config.c | 5 + schedsim/shell/schedsim_simple/config.c | 5 + schedsim/shell/schedsim_smppriority/config.c | 5 + .../shell/schedsim_smppriority_affinity/config.c | 5 + schedsim/shell/schedsim_smpsimple/config.c | 5 + schedsim/shell/shared/Makefile.am | 1 + schedsim/shell/shared/commands.c | 2 + schedsim/shell/shared/main_rtemsinit.c | 7 ++ schedsim/shell/shared/main_taskscheduler.c | 105 +++++++++++++++++++++ schedsim/shell/shared/schedsim_shell.h | 5 + 22 files changed, 569 insertions(+), 6 deletions(-) create mode 100644 schedsim/shell/schedsim_cbs/Makefile.am create mode 100644 schedsim/shell/schedsim_cbs/config.c create mode 100644 schedsim/shell/schedsim_cluster01/Makefile.am create mode 100644 schedsim/shell/schedsim_cluster01/config.c create mode 100644 schedsim/shell/schedsim_cluster02/Makefile.am create mode 100644 schedsim/shell/schedsim_cluster02/config.c create mode 100644 schedsim/shell/schedsim_edf/Makefile.am create mode 100644 schedsim/shell/schedsim_edf/config.c create mode 100644 schedsim/shell/shared/main_taskscheduler.c diff --git a/schedsim/UsingTheSchedulerSimulator.txt b/schedsim/UsingTheSchedulerSimulator.txt index ca63df8..f4d4630 100644 --- a/schedsim/UsingTheSchedulerSimulator.txt +++ b/schedsim/UsingTheSchedulerSimulator.txt @@ -245,8 +245,30 @@ task_resume Command ^^^^^^^^^^^^^^^^^^^ *Usage*: task_resume name|id -This command is used to suspend the specified task. It is the equivalent -of the rtems_task_suspend directive in the Classic API. +This command is used to resume the specified task. It is the equivalent +of the rtems_task_resume directive in the Classic API. + +task_set_scheduler +^^^^^^^^^^^^^^^^^^ +*Usage*: task_set_scheduler Task name|id Scheduler number + +This command is used to modified the select a scheduler cluster. + +For example on a system configured with scheduler 0 being a +Priority SMP Scheduler and scheduler 1 configured as Priority +Affinity SMP Scheduler + +The following is the output from the invocation task_set_scheduler TA1 1 + +------------------------------------------------------------- +Task (0x0a010001) on Priority Affinity SMP Scheduler +------------------------------------------------------------- + +The following is the output from the invocation task_set_scheduler TA1 0 + +------------------------------------------------------------- +Task (0x0a010001) on Priority SMP Scheduler +------------------------------------------------------------- task_suspend Command ^^^^^^^^^^^^^^^^^^^^ diff --git a/schedsim/configure.ac b/schedsim/configure.ac index bd1f41e..ff9ed7a 100644 --- a/schedsim/configure.ac +++ b/schedsim/configure.ac @@ -189,8 +189,12 @@ shell/Makefile shell/shared/Makefile shell/schedsim_priority/Makefile shell/schedsim_simple/Makefile +shell/schedsim_cbs/Makefile +shell/schedsim_edf/Makefile shell/schedsim_smpsimple/Makefile shell/schedsim_smppriority/Makefile shell/schedsim_smppriority_affinity/Makefile +shell/schedsim_cluster01/Makefile +shell/schedsim_cluster02/Makefile ]) AC_OUTPUT diff --git a/schedsim/rtems/Makefile.am b/schedsim/rtems/Makefile.am index eacf2e6..9db8293 100644 --- a/schedsim/rtems/Makefile.am +++ b/schedsim/rtems/Makefile.am @@ -111,6 +111,36 @@ librtems_a_SOURCES += $(cpukitdir)/score/src/schedulersimpleschedule.c librtems_a_SOURCES += $(cpukitdir)/score/src/schedulersimpleunblock.c librtems_a_SOURCES += $(cpukitdir)/score/src/schedulersimpleyield.c +# Uniprocessor Scheduler CBS +librtems_a_SOURCES += $(cpukitdir)/score/src +librtems_a_SOURCES += $(cpukitdir)/score/src/schedulercbsattachthread.c +librtems_a_SOURCES += $(cpukitdir)/score/src/schedulercbscreateserver.c +librtems_a_SOURCES += $(cpukitdir)/score/src/schedulercbsgetapprovedbudget.c +librtems_a_SOURCES += $(cpukitdir)/score/src/schedulercbsgetremainingbudget.c +librtems_a_SOURCES += $(cpukitdir)/score/src/schedulercbsreleasejob.c +librtems_a_SOURCES += $(cpukitdir)/score/src/schedulercbs.c +librtems_a_SOURCES += $(cpukitdir)/score/src/schedulercbsdestroyserver.c +librtems_a_SOURCES += $(cpukitdir)/score/src/schedulercbsgetexecutiontime.c +librtems_a_SOURCES += $(cpukitdir)/score/src/schedulercbsgetserverid.c +librtems_a_SOURCES += $(cpukitdir)/score/src/schedulercbssetparameters.c +librtems_a_SOURCES += $(cpukitdir)/score/src/schedulercbscleanup.c +librtems_a_SOURCES += $(cpukitdir)/score/src/schedulercbsdetachthread.c +librtems_a_SOURCES += $(cpukitdir)/score/src/schedulercbsgetparameters.c +librtems_a_SOURCES += $(cpukitdir)/score/src/schedulercbsnodeinit.c +librtems_a_SOURCES += $(cpukitdir)/score/src/schedulercbsunblock.c + +# Uniprocessor Scheduler EDF +librtems_a_SOURCES += $(cpukitdir)/score/src/scheduleredfblock.c +librtems_a_SOURCES += $(cpukitdir)/score/src/scheduleredfchangepriority.c +librtems_a_SOURCES += $(cpukitdir)/score/src/scheduleredfprioritycompare.c +librtems_a_SOURCES += $(cpukitdir)/score/src/scheduleredfschedule.c +librtems_a_SOURCES += $(cpukitdir)/score/src/scheduleredfupdate.c +librtems_a_SOURCES += $(cpukitdir)/score/src/scheduleredf.c +librtems_a_SOURCES += $(cpukitdir)/score/src/scheduleredfnodeinit.c +librtems_a_SOURCES += $(cpukitdir)/score/src/scheduleredfreleasejob.c +librtems_a_SOURCES += $(cpukitdir)/score/src/scheduleredfunblock.c +librtems_a_SOURCES += $(cpukitdir)/score/src/scheduleredfyield.c + librtems_a_SOURCES += $(cpukitdir)/score/src/thread.c librtems_a_SOURCES += $(cpukitdir)/score/src/threadchangepriority.c librtems_a_SOURCES += $(cpukitdir)/score/src/threadclearstate.c @@ -255,6 +285,9 @@ librtems_a_SOURCES += $(cpukitdir)/score/src/schedulersmpstartidle.c librtems_a_SOURCES += $(cpukitdir)/score/src/cpuset.c librtems_a_SOURCES += $(cpukitdir)/rtems/src/taskgetaffinity.c librtems_a_SOURCES += $(cpukitdir)/rtems/src/tasksetaffinity.c +librtems_a_SOURCES += $(cpukitdir)/rtems/src/schedulerident.c +librtems_a_SOURCES += $(cpukitdir)/rtems/src/schedulergetprocessorset.c +librtems_a_SOURCES += $(cpukitdir)/rtems/src/tasksetscheduler.c endif schedsim_includedir = $(includedir)/schedsim diff --git a/schedsim/shell/Makefile.am b/schedsim/shell/Makefile.am index d920e37..46a8ddd 100644 --- a/schedsim/shell/Makefile.am +++ b/schedsim/shell/Makefile.am @@ -1,15 +1,30 @@ ACLOCAL_AMFLAGS = -I ./../aclocal -SUBDIRS = shared schedsim_priority schedsim_simple -DIST_SUBDIRS = shared schedsim_priority schedsim_simple +SUBDIRS = shared +SUBDIRS += schedsim_priority +SUBDIRS += schedsim_simple +SUBDIRS += schedsim_cbs +SUBDIRS += schedsim_edf + +DIST_SUBDIRS = shared +DIST_SUBDIRS += shared +DIST_SUBDIRS += schedsim_priority +DIST_SUBDIRS += schedsim_simple +DIST_SUBDIRS += schedsim_cbs +DIST_SUBDIRS += schedsim_edf if HAS_SMP SUBDIRS += schedsim_smpsimple -DIST_SUBDIRS += schedsim_smpsimple SUBDIRS += schedsim_smppriority -DIST_SUBDIRS += schedsim_smppriority SUBDIRS += schedsim_smppriority_affinity +SUBDIRS += schedsim_cluster01 +SUBDIRS += schedsim_cluster02 + +DIST_SUBDIRS += schedsim_smpsimple +DIST_SUBDIRS += schedsim_smppriority DIST_SUBDIRS += schedsim_smppriority_affinity +DIST_SUBDIRS += schedsim_cluster01 +DIST_SUBDIRS += schedsim_cluster02 endif include $(top_srcdir)/../automake/subdirs.am diff --git a/schedsim/shell/schedsim_cbs/Makefile.am b/schedsim/shell/schedsim_cbs/Makefile.am new file mode 100644 index 0000000..bd7f08e --- /dev/null +++ b/schedsim/shell/schedsim_cbs/Makefile.am @@ -0,0 +1,49 @@ +bin_PROGRAMS = schedsim_cbs +schedsim_cbs_SOURCES = config.c +schedsim_cbs_SOURCES += $(srcdir)/../shared/add_commands_stub.c + +cpukitdir=@rtems_srcdir@/cpukit +schedsim_cbs_CPPFLAGS = -I$(top_builddir)/score/include +schedsim_cbs_CPPFLAGS += -I$(srcdir)/sched_cpu +schedsim_cbs_CPPFLAGS += -I$(srcdir)/../../rtems +schedsim_cbs_CPPFLAGS += -I$(cpukitdir)/include +schedsim_cbs_CPPFLAGS += -I$(cpukitdir)/score/include +schedsim_cbs_CPPFLAGS += -I$(cpukitdir)/score/inline +schedsim_cbs_CPPFLAGS += -I$(cpukitdir)/rtems/include +schedsim_cbs_CPPFLAGS += -I$(cpukitdir)/rtems/inline +schedsim_cbs_CPPFLAGS += -I$(cpukitdir)/sapi/include +schedsim_cbs_CPPFLAGS += -I$(cpukitdir)/sapi/inline +schedsim_cbs_CPPFLAGS += -I$(cpukitdir)/libcsupport/include +schedsim_cbs_CPPFLAGS += -I$(cpukitdir)/libmisc/stringto +schedsim_cbs_CPPFLAGS += -I$(srcdir)/../../rtems/sched_cpu +schedsim_cbs_CPPFLAGS += -I$(srcdir)/../shared/include +schedsim_cbs_CPPFLAGS += -I$(srcdir)/../shared +if HAS_PTHREADS +schedsim_cbs_CPPFLAGS += -I$(cpukitdir)/posix/include +schedsim_cbs_CPPFLAGS += -I$(cpukitdir)/posix/inline +endif + +## Ensure all linker provided symbols are available +schedsim_cbs_LDFLAGS = +schedsim_cbs_LDFLAGS += -Wl,--defsym=_TLS_Data_begin=0 +schedsim_cbs_LDFLAGS += -Wl,--defsym=_TLS_BSS_end=0 +schedsim_cbs_LDFLAGS += -Wl,--defsym=_TLS_Alignment=4 + +## Wrap _Thread_Dispatch so we can see context switches +schedsim_cbs_LDFLAGS += -Wl,--wrap=_Thread_Dispatch + +## Link in all support libraries +## schedsim_cbsLDADD +=-Wl,--start-group +schedsim_cbs_LDADD = ../shared/libschedsim.a +schedsim_cbs_LDADD += ../../rtems/librtems.a +schedsim_cbs_LDADD += ../shared/libschedsim.a +## schedsim_cbs_LDADD +=-Wl,--end-group + +check-local: + @echo Running tests from Uniprocessor Deterministic Priority + $(srcdir)/../run_scenarios \ + -s $(builddir)/schedsim_cbs \ + -S $(srcdir)/../schedsim_priority \ + -A + +include $(top_srcdir)/../automake/host.am diff --git a/schedsim/shell/schedsim_cbs/config.c b/schedsim/shell/schedsim_cbs/config.c new file mode 100644 index 0000000..d6425ed --- /dev/null +++ b/schedsim/shell/schedsim_cbs/config.c @@ -0,0 +1,14 @@ +#include +#include + +shell_scheduler_name shell_scheduler_list[] = { +"" +}; + +#define CONFIGURE_INIT +#define CONFIGURE_MAXIMUM_TASKS 1000 +#define CONFIGURE_MAXIMUM_SEMAPHORES 1000 + +#define CONFIGURE_SCHEDULER_CBS +#define CONFIGURE_DISABLE_BSP_SETTINGS +#include diff --git a/schedsim/shell/schedsim_cluster01/Makefile.am b/schedsim/shell/schedsim_cluster01/Makefile.am new file mode 100644 index 0000000..9b70554 --- /dev/null +++ b/schedsim/shell/schedsim_cluster01/Makefile.am @@ -0,0 +1,61 @@ +bin_PROGRAMS = schedsim_cluster01 + +SOURCES = config.c +SOURCES += $(srcdir)/../schedsim_smpsimple/add_commands.c +SOURCES += $(srcdir)/../schedsim_smpsimple/main_dump_ready_tasks.c +schedsim_cluster01_SOURCES = $(SOURCES) + +cpukitdir=@rtems_srcdir@/cpukit +schedsim_cluster01_CPPFLAGS = -I$(top_builddir)/score/include +schedsim_cluster01_CPPFLAGS += -I$(srcdir)/sched_cpu +schedsim_cluster01_CPPFLAGS += -I$(srcdir)/../../rtems +schedsim_cluster01_CPPFLAGS += -I$(cpukitdir)/include +schedsim_cluster01_CPPFLAGS += -I$(cpukitdir)/score/include +schedsim_cluster01_CPPFLAGS += -I$(cpukitdir)/score/inline +schedsim_cluster01_CPPFLAGS += -I$(cpukitdir)/rtems/include +schedsim_cluster01_CPPFLAGS += -I$(cpukitdir)/rtems/inline +schedsim_cluster01_CPPFLAGS += -I$(cpukitdir)/sapi/include +schedsim_cluster01_CPPFLAGS += -I$(cpukitdir)/sapi/inline +schedsim_cluster01_CPPFLAGS += -I$(cpukitdir)/libcsupport/include +schedsim_cluster01_CPPFLAGS += -I$(cpukitdir)/libmisc/stringto +schedsim_cluster01_CPPFLAGS += -I$(srcdir)/../../rtems/sched_cpu +schedsim_cluster01_CPPFLAGS += -I$(srcdir)/../shared/include +schedsim_cluster01_CPPFLAGS += -I$(srcdir)/../shared +if HAS_PTHREADS +schedsim_cluster01_CPPFLAGS += -I$(cpukitdir)/posix/include +schedsim_cluster01_CPPFLAGS += -I$(cpukitdir)/posix/inline +endif +## Ensure all linker provided symbols are available +schedsim_cluster01_LDFLAGS = +schedsim_cluster01_LDFLAGS += -Wl,--defsym=_TLS_Data_begin=0 +schedsim_cluster01_LDFLAGS += -Wl,--defsym=_TLS_BSS_end=0 +schedsim_cluster01_LDFLAGS += -Wl,--defsym=_TLS_Alignment=4 + +## Wrap _Thread_Dispatch so we can see context switches +schedsim_cluster01_LDFLAGS +=-Wl,--wrap=_Thread_Dispatch + +## schedsim_cluster01_LDADD +=-Wl,--start-group +schedsim_cluster01_LDADD = ../shared/libschedsim.a +schedsim_cluster01_LDADD += ../../rtems/librtems.a +schedsim_cluster01_LDADD += ../shared/libschedsim.a +## schedsim_cluster01_LDADD +=-Wl,--end-group + +check-local: + @echo Running tests from SMP Priority Affinity + $(srcdir)/../run_scenarios \ + -s $(builddir)/schedsim_cluster01 \ + -S $(srcdir) \ + -A + @echo Running tests from SMP Simple Priority + $(srcdir)/../run_scenarios \ + -s $(builddir)/schedsim_cluster01 \ + -S $(srcdir)/../schedsim_smpsimple \ + -A + @echo Running tests from Uniprocessor Deterministic Priority + $(srcdir)/../run_scenarios \ + -s $(builddir)/schedsim_cluster01 \ + -S $(srcdir)/../schedsim_priority \ + script02.scen script04.scen script05.scen script06.scen + + +include $(top_srcdir)/../automake/host.am diff --git a/schedsim/shell/schedsim_cluster01/config.c b/schedsim/shell/schedsim_cluster01/config.c new file mode 100644 index 0000000..ab1bcbc --- /dev/null +++ b/schedsim/shell/schedsim_cluster01/config.c @@ -0,0 +1,47 @@ +/** + * @file + * + * Configuration file for Scheduler Simulator using Priority SMP + */ + +#include + +#define CONFIGURE_INIT +#define CONFIGURE_MAXIMUM_TASKS 1000 +#define CONFIGURE_MAXIMUM_SEMAPHORES 1000 + +#define CONFIGURE_MAXIMUM_PRIORITY 255 + +#define CONFIGURE_SMP_APPLICATION +#define CONFIGURE_SMP_MAXIMUM_PROCESSORS 4 +#define CONFIGURE_SCHEDULER_PRIORITY_SMP +#define CONFIGURE_SCHEDULER_PRIORITY_AFFINITY_SMP + +#include +#include + +shell_scheduler_name shell_scheduler_list[] = { +"Priority SMP Scheduler", +"Priority Affinity SMP Scheduler", +"" +}; + +RTEMS_SCHEDULER_CONTEXT_PRIORITY_SMP(a, CONFIGURE_MAXIMUM_PRIORITY + 1); +RTEMS_SCHEDULER_CONTEXT_PRIORITY_AFFINITY_SMP( + b, + CONFIGURE_MAXIMUM_PRIORITY + 1 +); + +#define CONFIGURE_SCHEDULER_CONTROLS \ + RTEMS_SCHEDULER_CONTROL_PRIORITY_SMP(a, SCHED_NAME(0)), \ + RTEMS_SCHEDULER_CONTROL_PRIORITY_AFFINITY_SMP(b, SCHED_NAME(1)) + +#define CONFIGURE_SMP_SCHEDULER_ASSIGNMENTS \ + RTEMS_SCHEDULER_ASSIGN(0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY), \ + RTEMS_SCHEDULER_ASSIGN(0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL), \ + RTEMS_SCHEDULER_ASSIGN(1, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL), \ + RTEMS_SCHEDULER_ASSIGN(1, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL) + + +#define CONFIGURE_DISABLE_BSP_SETTINGS +#include diff --git a/schedsim/shell/schedsim_cluster02/Makefile.am b/schedsim/shell/schedsim_cluster02/Makefile.am new file mode 100644 index 0000000..3038a35 --- /dev/null +++ b/schedsim/shell/schedsim_cluster02/Makefile.am @@ -0,0 +1,61 @@ +bin_PROGRAMS = schedsim_cluster02 + +SOURCES = config.c +SOURCES += $(srcdir)/../schedsim_smpsimple/add_commands.c +SOURCES += $(srcdir)/../schedsim_smpsimple/main_dump_ready_tasks.c +schedsim_cluster02_SOURCES = $(SOURCES) + +cpukitdir=@rtems_srcdir@/cpukit +schedsim_cluster02_CPPFLAGS = -I$(top_builddir)/score/include +schedsim_cluster02_CPPFLAGS += -I$(srcdir)/sched_cpu +schedsim_cluster02_CPPFLAGS += -I$(srcdir)/../../rtems +schedsim_cluster02_CPPFLAGS += -I$(cpukitdir)/include +schedsim_cluster02_CPPFLAGS += -I$(cpukitdir)/score/include +schedsim_cluster02_CPPFLAGS += -I$(cpukitdir)/score/inline +schedsim_cluster02_CPPFLAGS += -I$(cpukitdir)/rtems/include +schedsim_cluster02_CPPFLAGS += -I$(cpukitdir)/rtems/inline +schedsim_cluster02_CPPFLAGS += -I$(cpukitdir)/sapi/include +schedsim_cluster02_CPPFLAGS += -I$(cpukitdir)/sapi/inline +schedsim_cluster02_CPPFLAGS += -I$(cpukitdir)/libcsupport/include +schedsim_cluster02_CPPFLAGS += -I$(cpukitdir)/libmisc/stringto +schedsim_cluster02_CPPFLAGS += -I$(srcdir)/../../rtems/sched_cpu +schedsim_cluster02_CPPFLAGS += -I$(srcdir)/../shared/include +schedsim_cluster02_CPPFLAGS += -I$(srcdir)/../shared +if HAS_PTHREADS +schedsim_cluster02_CPPFLAGS += -I$(cpukitdir)/posix/include +schedsim_cluster02_CPPFLAGS += -I$(cpukitdir)/posix/inline +endif +## Ensure all linker provided symbols are available +schedsim_cluster02_LDFLAGS = +schedsim_cluster02_LDFLAGS += -Wl,--defsym=_TLS_Data_begin=0 +schedsim_cluster02_LDFLAGS += -Wl,--defsym=_TLS_BSS_end=0 +schedsim_cluster02_LDFLAGS += -Wl,--defsym=_TLS_Alignment=4 + +## Wrap _Thread_Dispatch so we can see context switches +schedsim_cluster02_LDFLAGS +=-Wl,--wrap=_Thread_Dispatch + +## schedsim_cluster02_LDADD +=-Wl,--start-group +schedsim_cluster02_LDADD = ../shared/libschedsim.a +schedsim_cluster02_LDADD += ../../rtems/librtems.a +schedsim_cluster02_LDADD += ../shared/libschedsim.a +## schedsim_cluster02_LDADD +=-Wl,--end-group + +check-local: + @echo Running tests from SMP Priority Affinity + $(srcdir)/../run_scenarios \ + -s $(builddir)/schedsim_cluster02 \ + -S $(srcdir) \ + -A + @echo Running tests from SMP Simple Priority + $(srcdir)/../run_scenarios \ + -s $(builddir)/schedsim_cluster02 \ + -S $(srcdir)/../schedsim_smpsimple \ + -A + @echo Running tests from Uniprocessor Deterministic Priority + $(srcdir)/../run_scenarios \ + -s $(builddir)/schedsim_cluster02 \ + -S $(srcdir)/../schedsim_priority \ + script02.scen script04.scen script05.scen script06.scen + + +include $(top_srcdir)/../automake/host.am diff --git a/schedsim/shell/schedsim_cluster02/config.c b/schedsim/shell/schedsim_cluster02/config.c new file mode 100644 index 0000000..67f62c0 --- /dev/null +++ b/schedsim/shell/schedsim_cluster02/config.c @@ -0,0 +1,49 @@ +/** + * @file + * + * Configuration file for Scheduler Simulator using Priority SMP + */ + +#include + +#define CONFIGURE_INIT +#define CONFIGURE_MAXIMUM_TASKS 1000 +#define CONFIGURE_MAXIMUM_SEMAPHORES 1000 + +#define CONFIGURE_MAXIMUM_PRIORITY 255 + +#define CONFIGURE_SMP_APPLICATION +#define CONFIGURE_SMP_MAXIMUM_PROCESSORS 4 +#define CONFIGURE_SCHEDULER_PRIORITY +// #define CONFIGURE_SCHEDULER_PRIORITY_SMP +#define CONFIGURE_SCHEDULER_PRIORITY_AFFINITY_SMP + +#include + +#include + +shell_scheduler_name shell_scheduler_list[] = { +"Priority Scheduler", +"Priority Affinity SMP Scheduler", +"" +}; + +RTEMS_SCHEDULER_CONTEXT_PRIORITY(a, CONFIGURE_MAXIMUM_PRIORITY + 1); +RTEMS_SCHEDULER_CONTEXT_PRIORITY_AFFINITY_SMP( + b, + CONFIGURE_MAXIMUM_PRIORITY + 1 +); + +#define CONFIGURE_SCHEDULER_CONTROLS \ + RTEMS_SCHEDULER_CONTROL_PRIORITY(a, SCHED_NAME(0)), \ + RTEMS_SCHEDULER_CONTROL_PRIORITY_AFFINITY_SMP(b, SCHED_NAME(1)) + +#define CONFIGURE_SMP_SCHEDULER_ASSIGNMENTS \ + RTEMS_SCHEDULER_ASSIGN(0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY), \ + RTEMS_SCHEDULER_ASSIGN(1, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL), \ + RTEMS_SCHEDULER_ASSIGN(1, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL), \ + RTEMS_SCHEDULER_ASSIGN(1, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL) + + +#define CONFIGURE_DISABLE_BSP_SETTINGS +#include diff --git a/schedsim/shell/schedsim_edf/Makefile.am b/schedsim/shell/schedsim_edf/Makefile.am new file mode 100644 index 0000000..7555ee6 --- /dev/null +++ b/schedsim/shell/schedsim_edf/Makefile.am @@ -0,0 +1,49 @@ +bin_PROGRAMS = schedsim_edf +schedsim_edf_SOURCES = config.c +schedsim_edf_SOURCES += $(srcdir)/../shared/add_commands_stub.c + +cpukitdir=@rtems_srcdir@/cpukit +schedsim_edf_CPPFLAGS = -I$(top_builddir)/score/include +schedsim_edf_CPPFLAGS += -I$(srcdir)/sched_cpu +schedsim_edf_CPPFLAGS += -I$(srcdir)/../../rtems +schedsim_edf_CPPFLAGS += -I$(cpukitdir)/include +schedsim_edf_CPPFLAGS += -I$(cpukitdir)/score/include +schedsim_edf_CPPFLAGS += -I$(cpukitdir)/score/inline +schedsim_edf_CPPFLAGS += -I$(cpukitdir)/rtems/include +schedsim_edf_CPPFLAGS += -I$(cpukitdir)/rtems/inline +schedsim_edf_CPPFLAGS += -I$(cpukitdir)/sapi/include +schedsim_edf_CPPFLAGS += -I$(cpukitdir)/sapi/inline +schedsim_edf_CPPFLAGS += -I$(cpukitdir)/libcsupport/include +schedsim_edf_CPPFLAGS += -I$(cpukitdir)/libmisc/stringto +schedsim_edf_CPPFLAGS += -I$(srcdir)/../../rtems/sched_cpu +schedsim_edf_CPPFLAGS += -I$(srcdir)/../shared/include +schedsim_edf_CPPFLAGS += -I$(srcdir)/../shared +if HAS_PTHREADS +schedsim_edf_CPPFLAGS += -I$(cpukitdir)/posix/include +schedsim_edf_CPPFLAGS += -I$(cpukitdir)/posix/inline +endif + +## Ensure all linker provided symbols are available +schedsim_edf_LDFLAGS = +schedsim_edf_LDFLAGS += -Wl,--defsym=_TLS_Data_begin=0 +schedsim_edf_LDFLAGS += -Wl,--defsym=_TLS_BSS_end=0 +schedsim_edf_LDFLAGS += -Wl,--defsym=_TLS_Alignment=4 + +## Wrap _Thread_Dispatch so we can see context switches +schedsim_edf_LDFLAGS += -Wl,--wrap=_Thread_Dispatch + +## Link in all support libraries +## schedsim_edfLDADD +=-Wl,--start-group +schedsim_edf_LDADD = ../shared/libschedsim.a +schedsim_edf_LDADD += ../../rtems/librtems.a +schedsim_edf_LDADD += ../shared/libschedsim.a +## schedsim_edf_LDADD +=-Wl,--end-group + +check-local: + @echo Running tests from Uniprocessor Deterministic Priority + $(srcdir)/../run_scenarios \ + -s $(builddir)/schedsim_edf \ + -S $(srcdir)/../schedsim_priority \ + -A + +include $(top_srcdir)/../automake/host.am diff --git a/schedsim/shell/schedsim_edf/config.c b/schedsim/shell/schedsim_edf/config.c new file mode 100644 index 0000000..ac1e415 --- /dev/null +++ b/schedsim/shell/schedsim_edf/config.c @@ -0,0 +1,14 @@ +#include +#include + +shell_scheduler_name shell_scheduler_list[] = { +"" +}; + +#define CONFIGURE_INIT +#define CONFIGURE_MAXIMUM_TASKS 1000 +#define CONFIGURE_MAXIMUM_SEMAPHORES 1000 + +#define CONFIGURE_SCHEDULER_EDF +#define CONFIGURE_DISABLE_BSP_SETTINGS +#include diff --git a/schedsim/shell/schedsim_priority/config.c b/schedsim/shell/schedsim_priority/config.c index 332b326..378c37b 100644 --- a/schedsim/shell/schedsim_priority/config.c +++ b/schedsim/shell/schedsim_priority/config.c @@ -1,4 +1,9 @@ #include +#include + +shell_scheduler_name shell_scheduler_list[] = { +"" +}; #define CONFIGURE_INIT #define CONFIGURE_MAXIMUM_TASKS 1000 diff --git a/schedsim/shell/schedsim_simple/config.c b/schedsim/shell/schedsim_simple/config.c index 5322dc1..e20abd5 100644 --- a/schedsim/shell/schedsim_simple/config.c +++ b/schedsim/shell/schedsim_simple/config.c @@ -1,4 +1,9 @@ #include +#include + +shell_scheduler_name shell_scheduler_list[] = { +"" +}; #define CONFIGURE_INIT #define CONFIGURE_MAXIMUM_TASKS 1000 diff --git a/schedsim/shell/schedsim_smppriority/config.c b/schedsim/shell/schedsim_smppriority/config.c index 04d00d2..10ce775 100644 --- a/schedsim/shell/schedsim_smppriority/config.c +++ b/schedsim/shell/schedsim_smppriority/config.c @@ -5,6 +5,11 @@ */ #include +#include + +shell_scheduler_name shell_scheduler_list[] = { +"" +}; #define CONFIGURE_INIT #define CONFIGURE_MAXIMUM_TASKS 1000 diff --git a/schedsim/shell/schedsim_smppriority_affinity/config.c b/schedsim/shell/schedsim_smppriority_affinity/config.c index 25395df..4311e71 100644 --- a/schedsim/shell/schedsim_smppriority_affinity/config.c +++ b/schedsim/shell/schedsim_smppriority_affinity/config.c @@ -5,6 +5,11 @@ */ #include +#include + +shell_scheduler_name shell_scheduler_list[] = { +"" +}; #define CONFIGURE_INIT #define CONFIGURE_MAXIMUM_TASKS 1000 diff --git a/schedsim/shell/schedsim_smpsimple/config.c b/schedsim/shell/schedsim_smpsimple/config.c index 49516bc..8f7b8c8 100644 --- a/schedsim/shell/schedsim_smpsimple/config.c +++ b/schedsim/shell/schedsim_smpsimple/config.c @@ -5,6 +5,11 @@ */ #include +#include + +shell_scheduler_name shell_scheduler_list[] = { +"" +}; #define CONFIGURE_INIT #define CONFIGURE_MAXIMUM_TASKS 1000 diff --git a/schedsim/shell/shared/Makefile.am b/schedsim/shell/shared/Makefile.am index d999816..ed5b99f 100644 --- a/schedsim/shell/shared/Makefile.am +++ b/schedsim/shell/shared/Makefile.am @@ -48,6 +48,7 @@ libschedsim_a_SOURCES += main_taskdelete.c libschedsim_a_SOURCES += main_taskmode.c libschedsim_a_SOURCES += main_taskpriority.c libschedsim_a_SOURCES += main_taskresume.c +libschedsim_a_SOURCES += main_taskscheduler.c libschedsim_a_SOURCES += main_tasksuspend.c libschedsim_a_SOURCES += main_taskwakeafter.c libschedsim_a_SOURCES += printheir_executing.c diff --git a/schedsim/shell/shared/commands.c b/schedsim/shell/shared/commands.c index 5a75181..f61227e 100644 --- a/schedsim/shell/shared/commands.c +++ b/schedsim/shell/shared/commands.c @@ -28,6 +28,7 @@ extern rtems_shell_cmd_t rtems_shell_TASK_CREATE_Command; extern rtems_shell_cmd_t rtems_shell_TASK_DELETE_Command; extern rtems_shell_cmd_t rtems_shell_TASK_MODE_Command; extern rtems_shell_cmd_t rtems_shell_TASK_PRIORITY_Command; +extern rtems_shell_cmd_t rtems_shell_TASK_SET_SCHEDULER_Command; extern rtems_shell_cmd_t rtems_shell_TASK_SUSPEND_Command; extern rtems_shell_cmd_t rtems_shell_TASK_RESUME_Command; extern rtems_shell_cmd_t rtems_shell_TASK_WAKE_AFTER_Command; @@ -62,6 +63,7 @@ rtems_shell_cmd_t *rtems_shell_Initial_commands[] = { &rtems_shell_TASK_DELETE_Command, &rtems_shell_TASK_MODE_Command, &rtems_shell_TASK_PRIORITY_Command, + &rtems_shell_TASK_SET_SCHEDULER_Command, &rtems_shell_TASK_SUSPEND_Command, &rtems_shell_TASK_RESUME_Command, &rtems_shell_TASK_WAKE_AFTER_Command, diff --git a/schedsim/shell/shared/main_rtemsinit.c b/schedsim/shell/shared/main_rtemsinit.c index ad2b14f..a1afcb6 100644 --- a/schedsim/shell/shared/main_rtemsinit.c +++ b/schedsim/shell/shared/main_rtemsinit.c @@ -32,6 +32,8 @@ int rtems_shell_main_rtems_init( char *argv[] ) { + int i; + #if defined(RTEMS_SMP) long cpus = 1; @@ -44,6 +46,11 @@ int rtems_shell_main_rtems_init( Schedsim_Maximum_CPUs_From_Command_Line = cpus; #endif + for (i=0; strcmp("", shell_scheduler_list[i]) != 0; i++) + { + printf("Scheduler %d: %s\n", i, shell_scheduler_list[i]); + } + // // Initialize RTEMS // diff --git a/schedsim/shell/shared/main_taskscheduler.c b/schedsim/shell/shared/main_taskscheduler.c new file mode 100644 index 0000000..6adc215 --- /dev/null +++ b/schedsim/shell/shared/main_taskscheduler.c @@ -0,0 +1,105 @@ +/* + * Task Create Shell Command Implmentation + * + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#if defined(RTEMS_SMP) +#define _GNU_SOURCE +#include +#endif + +#include + +#define __need_getopt_newlib +#include + +#include +#include "shell.h" +#include +#include +#include + +int rtems_shell_main_task_set_scheduler( + int argc, + char *argv[] +) +{ + rtems_id task_id; + rtems_id scheduler_id; + rtems_status_code status; + rtems_name name; + long sched; + bool ok = true; + + CHECK_RTEMS_IS_UP(); + + if (strcmp("", shell_scheduler_list[0]) == 0) + { + fprintf(stderr, "Cluster Scheduling not configured\n"); + return -1; + } + + if (argc != 3) + ok = false; + + if ( lookup_task( argv[1], &task_id ) ) + ok = false; + + if (!ok) + { + fprintf( stderr, "%s: Usage [task name|id] [sheduler number] \n", argv[0] ); + return -1; + } + + if ( rtems_string_to_long(argv[2], &sched, NULL, 0) ) { + fprintf( stderr, "Schedule argument (%s) is not a number\n", argv[2] ); + return -1; + } + + name = SCHED_NAME(sched); + + status = rtems_scheduler_ident( name, &scheduler_id ); + if ( status != RTEMS_SUCCESSFUL ) { + fprintf( + stderr, + "Task scheduler id (%d) returned %s\n", + sched, + rtems_status_text( status ) + ); + return -1; + } + + printf("Task (0x%08x) on %s\n", task_id, shell_scheduler_list[sched] ); + + status = rtems_task_set_scheduler(task_id, scheduler_id ); + if ( status != RTEMS_SUCCESSFUL ) { + fprintf( + stderr, + "Task set scheduler(%s) returned %s\n", + argv[1], + rtems_status_text( status ) + ); + return -1; + } + + return 0; +} + +rtems_shell_cmd_t rtems_shell_TASK_SET_SCHEDULER_Command = { + "task_set_scheduler", /* name */ + "task_set_scheduler task_name scheduler_name", /* usage */ + "rtems", /* topic */ + rtems_shell_main_task_set_scheduler, /* command */ + NULL, /* alias */ + NULL /* next */ +}; diff --git a/schedsim/shell/shared/schedsim_shell.h b/schedsim/shell/shared/schedsim_shell.h index d9bdb84..08345c9 100644 --- a/schedsim/shell/shared/schedsim_shell.h +++ b/schedsim/shell/shared/schedsim_shell.h @@ -25,6 +25,11 @@ extern "C" { #endif +#define SCHED_NAME(i) rtems_build_name(' ', ' ', ' ', (char) ('A' + (i))) + +typedef char * shell_scheduler_name; +extern shell_scheduler_name shell_scheduler_list[]; + Thread_Control *get_thread_executing(void); Thread_Control *get_thread_heir(void); -- cgit v1.2.3