diff options
author | Jennifer Averett <jennifer.averett@oarcorp.com> | 2014-06-17 12:03:25 -0500 |
---|---|---|
committer | Jennifer Averett <jennifer.averett@oarcorp.com> | 2014-06-17 12:03:25 -0500 |
commit | 6f48a61527f4fad2244d7d8bfa67795d042c7fef (patch) | |
tree | ecda4c9713a6fbaf0d1af8dbce438f8cd67b23d9 /schedsim/shell/shared | |
parent | rtems: Add _Thread_Yield support. (diff) | |
download | rtems-schedsim-6f48a61527f4fad2244d7d8bfa67795d042c7fef.tar.bz2 |
Add remainder of schedulers and cluster scheduler support.
Diffstat (limited to 'schedsim/shell/shared')
-rw-r--r-- | schedsim/shell/shared/Makefile.am | 1 | ||||
-rw-r--r-- | schedsim/shell/shared/commands.c | 2 | ||||
-rw-r--r-- | schedsim/shell/shared/main_rtemsinit.c | 7 | ||||
-rw-r--r-- | schedsim/shell/shared/main_taskscheduler.c | 105 | ||||
-rw-r--r-- | schedsim/shell/shared/schedsim_shell.h | 5 |
5 files changed, 120 insertions, 0 deletions
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 <sys/cpuset.h> +#endif + +#include <stdio.h> + +#define __need_getopt_newlib +#include <newlib/getopt.h> + +#include <rtems.h> +#include "shell.h" +#include <rtems/stringto.h> +#include <schedsim_shell.h> +#include <rtems/error.h> + +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); |