summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@oarcorp.com>2014-05-23 16:26:28 -0500
committerJoel Sherrill <joel.sherrill@oarcorp.com>2014-05-23 16:46:49 -0500
commit718b2b6be887f56aad102be7378dff9947f84039 (patch)
tree7f4b73dc9f435fbbe5cf84e80d26a7e3bc47a217
parentschedsim_smpsimple: Add cpus4_inherit_priority. (diff)
downloadrtems-schedsim-718b2b6be887f56aad102be7378dff9947f84039.tar.bz2
main_semobtain.c: Locked access to executing
-rw-r--r--schedsim/shell/shared/main_semobtain.c14
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,