summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@oarcorp.com>2014-04-30 13:24:50 -0500
committerJoel Sherrill <joel.sherrill@oarcorp.com>2014-04-30 13:24:50 -0500
commit187d93cac4446f906c3f9df57705361a6bcf48ff (patch)
tree25bb064df4699381c772c9faef533fdf473ef0ce
parent8703c130e4eedacfbdb54eb779123fad2726421b (diff)
downloadrtems-schedsim-187d93cac4446f906c3f9df57705361a6bcf48ff.tar.bz2
Allow Scheduler Simulator to "defer dispatch" until controlled
This is needed to prevent a semaphore delete from triggering a preempt and breaking the mutex is owner debug check. Technically we are running the same thread until the API call returns. But from an RTEMS internals perspective, it was preempted at the _Object_Put(). When understanding this patch, it is important to remember that the Scheduler Simulator is single threaded and faking out RTEMS. This is one place where RTEMS would have preempted to a thread and when we returned to rtems_semaphore_delete(), the _Object_Put() call would have been made by the correct thread.
-rw-r--r--schedsim/shell/shared/main_semdelete.c17
-rw-r--r--schedsim/shell/shared/schedsim_shell.h14
2 files changed, 24 insertions, 7 deletions
diff --git a/schedsim/shell/shared/main_semdelete.c b/schedsim/shell/shared/main_semdelete.c
index ed227b3..4a706b8 100644
--- a/schedsim/shell/shared/main_semdelete.c
+++ b/schedsim/shell/shared/main_semdelete.c
@@ -1,7 +1,10 @@
+/**
+ * @file
+ * @brief Task Delete Shell Command Implmentation
+ */
+
/*
- * Task Delete Shell Command Implmentation
- *
- * COPYRIGHT (c) 1989-2013.
+ * COPYRIGHT (c) 1989-2014.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -44,7 +47,13 @@ int rtems_shell_main_semaphore_delete(
*/
printf("Deleting semaphore (0x%08x)\n", id );
- status = rtems_semaphore_delete( id );
+ /*
+ * This wraps the allocator mutex and should defer any context switching
+ */
+ schedsim_set_allow_dispatch(false);
+ status = rtems_semaphore_delete( id );
+ schedsim_set_allow_dispatch(true);
+
if ( status != RTEMS_SUCCESSFUL ) {
fprintf(
stderr,
diff --git a/schedsim/shell/shared/schedsim_shell.h b/schedsim/shell/shared/schedsim_shell.h
index d1f2406..15685bc 100644
--- a/schedsim/shell/shared/schedsim_shell.h
+++ b/schedsim/shell/shared/schedsim_shell.h
@@ -1,7 +1,12 @@
-/*
- * BASED UPON SOURCE IN RTEMS, MODIFIED FOR SIMULATOR
+/**
+ * @file
+ * @brief Scheduler Simulator Internals
*
- * COPYRIGHT (c) 1989-2013.
+ * @note BASED UPON SOURCE IN RTEMS, MODIFIED FOR SIMULATOR
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2014.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -30,6 +35,9 @@ extern "C" {
void PRINT_EXECUTING(void);
void PRINT_HEIR(void);
+void schedsim_set_allow_dispatch(bool value);
+bool schedsim_is_dispatch_allowed(void);
+
struct rtems_shell_topic_tt;
typedef struct rtems_shell_topic_tt rtems_shell_topic_t;