From 718b2b6be887f56aad102be7378dff9947f84039 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 23 May 2014 16:26:28 -0500 Subject: main_semobtain.c: Locked access to executing --- schedsim/shell/shared/main_semobtain.c | 14 ++++++++++++-- 1 file 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 #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[] @@ -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, -- cgit v1.2.3