summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/semobtain.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2013-07-17 15:53:17 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2013-07-18 09:58:58 +0200
commit95e09afa92c5d0522a0d04019ef6680796688896 (patch)
tree2c04a60ed5669b4baba5a783e1919b4b4a37d858 /cpukit/rtems/src/semobtain.c
parentscore: Convert to inline function (diff)
downloadrtems-95e09afa92c5d0522a0d04019ef6680796688896.tar.bz2
score: Avoid direct usage of _Thread_Executing
Pass the executing thread as a function parameter. Obtain the executing thread inside a thread dispatch critical section to avoid problems on SMP.
Diffstat (limited to 'cpukit/rtems/src/semobtain.c')
-rw-r--r--cpukit/rtems/src/semobtain.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/cpukit/rtems/src/semobtain.c b/cpukit/rtems/src/semobtain.c
index 719749662c..08ccb80549 100644
--- a/cpukit/rtems/src/semobtain.c
+++ b/cpukit/rtems/src/semobtain.c
@@ -47,14 +47,17 @@ rtems_status_code rtems_semaphore_obtain(
register Semaphore_Control *the_semaphore;
Objects_Locations location;
ISR_Level level;
+ Thread_Control *executing;
the_semaphore = _Semaphore_Get_interrupt_disable( id, &location, &level );
switch ( location ) {
case OBJECTS_LOCAL:
+ executing = _Thread_Executing;
if ( !_Attributes_Is_counting_semaphore(the_semaphore->attribute_set) ) {
_CORE_mutex_Seize(
&the_semaphore->Core_control.mutex,
+ executing,
id,
((_Options_Is_no_wait( option_set )) ? false : true),
timeout,
@@ -62,7 +65,7 @@ rtems_status_code rtems_semaphore_obtain(
);
_Objects_Put_for_get_isr_disable( &the_semaphore->Object );
return _Semaphore_Translate_core_mutex_return_code(
- _Thread_Executing->Wait.return_code );
+ executing->Wait.return_code );
}
/* must be a counting semaphore */
@@ -75,7 +78,7 @@ rtems_status_code rtems_semaphore_obtain(
);
_Objects_Put_for_get_isr_disable( &the_semaphore->Object );
return _Semaphore_Translate_core_semaphore_return_code(
- _Thread_Executing->Wait.return_code );
+ executing->Wait.return_code );
#if defined(RTEMS_MULTIPROCESSING)
case OBJECTS_REMOTE: