[rtems-schedsim commit] main_semobtain.c: Locked access to executing

Joel Sherrill joel at rtems.org
Fri May 23 21:40:59 UTC 2014


Module:    rtems-schedsim
Branch:    master
Commit:    718b2b6be887f56aad102be7378dff9947f84039
Changeset: http://git.rtems.org/rtems-schedsim/commit/?id=718b2b6be887f56aad102be7378dff9947f84039

Author:    Joel Sherrill <joel.sherrill at oarcorp.com>
Date:      Fri May 23 16:26:28 2014 -0500

main_semobtain.c: Locked access to executing

---

 schedsim/shell/shared/main_semobtain.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/schedsim/shell/shared/main_semobtain.c b/schedsim/shell/shared/main_semobtain.c
index 12ae381..d5b4388 100644
--- a/schedsim/shell/shared/main_semobtain.c
+++ b/schedsim/shell/shared/main_semobtain.c
@@ -21,6 +21,16 @@
 #include <schedsim_shell.h>
 #include <rtems/error.h>
 
+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[]
@@ -58,10 +68,10 @@ int rtems_shell_main_semaphore_obtain(
    *  a thread switch inside the semaphore obtain.  If we did, then
    *  just return successfully.
    */
-  caller = _Thread_Executing;
+  caller = get_thread_executing();
   printf("Obtain semaphore (0x%08x) with timeout %d\n", id, ticks );
   status = rtems_semaphore_obtain( id, RTEMS_DEFAULT_OPTIONS, ticks );
-  if ( caller == _Thread_Executing ) {
+  if ( caller == get_thread_executing() ) {
     if ( status != RTEMS_SUCCESSFUL ) {
       fprintf(
         stderr,




More information about the vc mailing list