summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2013-07-19 11:07:37 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2013-07-22 16:57:21 +0200
commit0444947e63715829d484b411f63244585ad6f449 (patch)
tree298f07f8b6a08ae743f94d7609cf79d36e8908b6 /cpukit
parentscore: Create barrier implementation header (diff)
downloadrtems-0444947e63715829d484b411f63244585ad6f449.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')
-rw-r--r--cpukit/posix/src/pbarrierwait.c5
-rw-r--r--cpukit/rtems/src/barrierwait.c5
-rw-r--r--cpukit/score/include/rtems/score/corebarrierimpl.h2
-rw-r--r--cpukit/score/src/corebarrierwait.c3
4 files changed, 11 insertions, 4 deletions
diff --git a/cpukit/posix/src/pbarrierwait.c b/cpukit/posix/src/pbarrierwait.c
index 036932ed96..1d7b9811c5 100644
--- a/cpukit/posix/src/pbarrierwait.c
+++ b/cpukit/posix/src/pbarrierwait.c
@@ -40,6 +40,7 @@ int pthread_barrier_wait(
{
POSIX_Barrier_Control *the_barrier = NULL;
Objects_Locations location;
+ Thread_Control *executing;
if ( !barrier )
return EINVAL;
@@ -48,8 +49,10 @@ int pthread_barrier_wait(
switch ( location ) {
case OBJECTS_LOCAL:
+ executing = _Thread_Executing;
_CORE_barrier_Wait(
&the_barrier->Barrier,
+ executing,
the_barrier->Object.id,
true,
0,
@@ -57,7 +60,7 @@ int pthread_barrier_wait(
);
_Objects_Put( &the_barrier->Object );
return _POSIX_Barrier_Translate_core_barrier_return_code(
- _Thread_Executing->Wait.return_code );
+ executing->Wait.return_code );
#if defined(RTEMS_MULTIPROCESSING)
case OBJECTS_REMOTE:
diff --git a/cpukit/rtems/src/barrierwait.c b/cpukit/rtems/src/barrierwait.c
index 515f9352c7..a233908bf1 100644
--- a/cpukit/rtems/src/barrierwait.c
+++ b/cpukit/rtems/src/barrierwait.c
@@ -32,13 +32,16 @@ rtems_status_code rtems_barrier_wait(
{
Barrier_Control *the_barrier;
Objects_Locations location;
+ Thread_Control *executing;
the_barrier = _Barrier_Get( id, &location );
switch ( location ) {
case OBJECTS_LOCAL:
+ executing = _Thread_Executing;
_CORE_barrier_Wait(
&the_barrier->Barrier,
+ executing,
id,
true,
timeout,
@@ -46,7 +49,7 @@ rtems_status_code rtems_barrier_wait(
);
_Objects_Put( &the_barrier->Object );
return _Barrier_Translate_core_barrier_return_code(
- _Thread_Executing->Wait.return_code );
+ executing->Wait.return_code );
#if defined(RTEMS_MULTIPROCESSING)
case OBJECTS_REMOTE:
diff --git a/cpukit/score/include/rtems/score/corebarrierimpl.h b/cpukit/score/include/rtems/score/corebarrierimpl.h
index cc225537af..0353efb67d 100644
--- a/cpukit/score/include/rtems/score/corebarrierimpl.h
+++ b/cpukit/score/include/rtems/score/corebarrierimpl.h
@@ -92,6 +92,7 @@ void _CORE_barrier_Initialize(
* is released.
*
* @param[in] the_barrier is the barrier to wait for
+ * @param[in,out] executing The currently executing thread.
* @param[in] id is the id of the object being waited upon
* @param[in] wait is true if the calling thread is willing to wait
* @param[in] timeout is the number of ticks the calling thread is willing
@@ -103,6 +104,7 @@ void _CORE_barrier_Initialize(
*/
void _CORE_barrier_Wait(
CORE_barrier_Control *the_barrier,
+ Thread_Control *executing,
Objects_Id id,
bool wait,
Watchdog_Interval timeout,
diff --git a/cpukit/score/src/corebarrierwait.c b/cpukit/score/src/corebarrierwait.c
index a5b685a779..465402ab82 100644
--- a/cpukit/score/src/corebarrierwait.c
+++ b/cpukit/score/src/corebarrierwait.c
@@ -27,16 +27,15 @@
void _CORE_barrier_Wait(
CORE_barrier_Control *the_barrier,
+ Thread_Control *executing,
Objects_Id id,
bool wait,
Watchdog_Interval timeout,
CORE_barrier_API_mp_support_callout api_barrier_mp_support
)
{
- Thread_Control *executing;
ISR_Level level;
- executing = _Thread_Executing;
executing->Wait.return_code = CORE_BARRIER_STATUS_SUCCESSFUL;
_ISR_Disable( level );
the_barrier->number_of_waiting_threads++;