From d8918c153c114330cf52d8d40585d7a9b6209056 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 26 May 2014 14:01:06 -0500 Subject: Misc so more scenarios run --- schedsim/shell/shared/Makefile.am | 2 ++ schedsim/shell/shared/getthreadexecuting.c | 31 ++++++++++++++++++++++++++++ schedsim/shell/shared/getthreadheir.c | 31 ++++++++++++++++++++++++++++ schedsim/shell/shared/lookup_task.c | 16 ++++++++------ schedsim/shell/shared/main_semobtain.c | 10 --------- schedsim/shell/shared/main_taskwakeafter.c | 2 +- schedsim/shell/shared/schedsim_shell.h | 4 ++++ schedsim/shell/shared/wrap_thread_dispatch.c | 3 +++ 8 files changed, 82 insertions(+), 17 deletions(-) create mode 100644 schedsim/shell/shared/getthreadexecuting.c create mode 100644 schedsim/shell/shared/getthreadheir.c diff --git a/schedsim/shell/shared/Makefile.am b/schedsim/shell/shared/Makefile.am index c6ba74f..d999816 100644 --- a/schedsim/shell/shared/Makefile.am +++ b/schedsim/shell/shared/Makefile.am @@ -27,6 +27,8 @@ libschedsim_a_SOURCES = libschedsim_a_SOURCES += schedsim.c libschedsim_a_SOURCES += commands.c libschedsim_a_SOURCES += getopt.c +libschedsim_a_SOURCES += getthreadexecuting.c +libschedsim_a_SOURCES += getthreadheir.c libschedsim_a_SOURCES += lookup_semaphore.c libschedsim_a_SOURCES += lookup_task.c libschedsim_a_SOURCES += main_dump_all_cpus.c diff --git a/schedsim/shell/shared/getthreadexecuting.c b/schedsim/shell/shared/getthreadexecuting.c new file mode 100644 index 0000000..8a05871 --- /dev/null +++ b/schedsim/shell/shared/getthreadexecuting.c @@ -0,0 +1,31 @@ +/** + * @file + * @brief Get Thread Executing Helper + */ + +/* + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "shell.h" +#include +#include + +Thread_Control *get_thread_executing(void) +{ + Thread_Control *e; + + _Thread_Disable_dispatch(); + e = _Thread_Executing; + _Thread_Enable_dispatch(); + return e; +} diff --git a/schedsim/shell/shared/getthreadheir.c b/schedsim/shell/shared/getthreadheir.c new file mode 100644 index 0000000..61b9f9b --- /dev/null +++ b/schedsim/shell/shared/getthreadheir.c @@ -0,0 +1,31 @@ +/** + * @file + * @brief Get Thread Heir Helper + */ + +/* + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "shell.h" +#include +#include + +Thread_Control *get_thread_heir(void) +{ + Thread_Control *e; + + _Thread_Disable_dispatch(); + e = _Thread_Heir; + _Thread_Enable_dispatch(); + return e; +} diff --git a/schedsim/shell/shared/lookup_task.c b/schedsim/shell/shared/lookup_task.c index 264ffa8..b471e9b 100644 --- a/schedsim/shell/shared/lookup_task.c +++ b/schedsim/shell/shared/lookup_task.c @@ -1,7 +1,10 @@ +/** + * @file + * @brief Given Name or ID String, give Id + */ + /* - * Given Name or ID String, give Id - * - * COPYRIGHT (c) 1989-2013. + * COPYRIGHT (c) 1989-2014. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -18,6 +21,7 @@ #include #include #include +#include "schedsim_shell.h" #ifndef METHOD_NAME #define METHOD_NAME lookup_task @@ -39,15 +43,15 @@ int METHOD_NAME( if ( string[0] != '0' ) { #ifdef DOING_TASKS if ( !strcmp( string, "SELF" ) ) { - _Thread_Disable_dispatch(); - *id = _Thread_Executing->Object.id; - _Thread_Enable_dispatch(); + *id = get_thread_executing()->Object.id; return 0; } #endif +#if 0 if ( strlen( string ) != 4 ) { return -1; } +#endif memset( name, '\0', sizeof(name) ); strncpy( name, string, 4 ); status = RTEMS_IDENT_NAME( diff --git a/schedsim/shell/shared/main_semobtain.c b/schedsim/shell/shared/main_semobtain.c index 5033ba5..a9e05d0 100644 --- a/schedsim/shell/shared/main_semobtain.c +++ b/schedsim/shell/shared/main_semobtain.c @@ -22,16 +22,6 @@ #include #include -static Thread_Control *get_thread_executing(void) -{ - Thread_Control *e; - - _Thread_Disable_dispatch(); - e = _Thread_Executing; - _Thread_Enable_dispatch(); - return e; -} - int rtems_shell_main_semaphore_obtain( int argc, char *argv[] diff --git a/schedsim/shell/shared/main_taskwakeafter.c b/schedsim/shell/shared/main_taskwakeafter.c index 7173d12..7b5b900 100644 --- a/schedsim/shell/shared/main_taskwakeafter.c +++ b/schedsim/shell/shared/main_taskwakeafter.c @@ -44,7 +44,7 @@ int rtems_shell_main_task_wake_after( } ticks = (rtems_interval) tmp; - self = _Thread_Executing->Object.id, + self = get_thread_executing()->Object.id, /* * Now sleep diff --git a/schedsim/shell/shared/schedsim_shell.h b/schedsim/shell/shared/schedsim_shell.h index f094a52..d9bdb84 100644 --- a/schedsim/shell/shared/schedsim_shell.h +++ b/schedsim/shell/shared/schedsim_shell.h @@ -19,11 +19,15 @@ #include #include +#include "shell.h" #ifdef __cplusplus extern "C" { #endif +Thread_Control *get_thread_executing(void); +Thread_Control *get_thread_heir(void); + void add_commands(void); #define CHECK_RTEMS_IS_UP() \ diff --git a/schedsim/shell/shared/wrap_thread_dispatch.c b/schedsim/shell/shared/wrap_thread_dispatch.c index fae4f9f..32ec08f 100644 --- a/schedsim/shell/shared/wrap_thread_dispatch.c +++ b/schedsim/shell/shared/wrap_thread_dispatch.c @@ -63,6 +63,9 @@ void __wrap__Thread_Dispatch(void) uint32_t cpu; uint32_t current_cpu; + if ( !schedsim_is_dispatch_allowed() ) + return; + current_cpu = Schedsim_Current_cpu; for ( cpu=0 ; cpu < MAX_CPUS ; cpu++ ) { Schedsim_Current_cpu = cpu; -- cgit v1.2.3