summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src
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/score/src
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/score/src')
-rw-r--r--cpukit/score/src/apimutexallocate.c2
-rw-r--r--cpukit/score/src/apimutexlock.c1
-rw-r--r--cpukit/score/src/coremutex.c15
-rw-r--r--cpukit/score/src/coremutexseize.c13
-rw-r--r--cpukit/score/src/coremutexseizeintr.c7
5 files changed, 26 insertions, 12 deletions
diff --git a/cpukit/score/src/apimutexallocate.c b/cpukit/score/src/apimutexallocate.c
index a736e2b14f..c57cc66e6b 100644
--- a/cpukit/score/src/apimutexallocate.c
+++ b/cpukit/score/src/apimutexallocate.c
@@ -37,7 +37,7 @@ void _API_Mutex_Allocate(
mutex = (API_Mutex_Control *) _Objects_Allocate( &_API_Mutex_Information );
- _CORE_mutex_Initialize( &mutex->Mutex, &attr, CORE_MUTEX_UNLOCKED );
+ _CORE_mutex_Initialize( &mutex->Mutex, NULL, &attr, CORE_MUTEX_UNLOCKED );
_Objects_Open_u32( &_API_Mutex_Information, &mutex->Object, 1 );
diff --git a/cpukit/score/src/apimutexlock.c b/cpukit/score/src/apimutexlock.c
index c5a2e42cc5..b6d957f84c 100644
--- a/cpukit/score/src/apimutexlock.c
+++ b/cpukit/score/src/apimutexlock.c
@@ -37,6 +37,7 @@ void _API_Mutex_Lock(
_CORE_mutex_Seize(
&the_mutex->Mutex,
+ _Thread_Executing,
the_mutex->Object.id,
true,
0,
diff --git a/cpukit/score/src/coremutex.c b/cpukit/score/src/coremutex.c
index a39b4efebf..8ea7d13a4d 100644
--- a/cpukit/score/src/coremutex.c
+++ b/cpukit/score/src/coremutex.c
@@ -27,7 +27,8 @@
CORE_mutex_Status _CORE_mutex_Initialize(
CORE_mutex_Control *the_mutex,
- CORE_mutex_Attributes *the_mutex_attributes,
+ Thread_Control *executing,
+ const CORE_mutex_Attributes *the_mutex_attributes,
uint32_t initial_lock
)
{
@@ -43,21 +44,21 @@ CORE_mutex_Status _CORE_mutex_Initialize(
if ( initial_lock == CORE_MUTEX_LOCKED ) {
the_mutex->nest_count = 1;
- the_mutex->holder = _Thread_Executing;
- the_mutex->holder_id = _Thread_Executing->Object.id;
+ the_mutex->holder = executing;
+ the_mutex->holder_id = executing->Object.id;
if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) ||
_CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) {
- if ( _Thread_Executing->current_priority <
+ if ( executing->current_priority <
the_mutex->Attributes.priority_ceiling )
return CORE_MUTEX_STATUS_CEILING_VIOLATED;
#ifdef __RTEMS_STRICT_ORDER_MUTEX__
- _Chain_Prepend_unprotected( &_Thread_Executing->lock_mutex,
+ _Chain_Prepend_unprotected( &executing->lock_mutex,
&the_mutex->queue.lock_queue );
- the_mutex->queue.priority_before = _Thread_Executing->current_priority;
+ the_mutex->queue.priority_before = executing->current_priority;
#endif
- _Thread_Executing->resource_count++;
+ executing->resource_count++;
}
} else {
the_mutex->nest_count = 0;
diff --git a/cpukit/score/src/coremutexseize.c b/cpukit/score/src/coremutexseize.c
index 098d6f2472..3da513a77b 100644
--- a/cpukit/score/src/coremutexseize.c
+++ b/cpukit/score/src/coremutexseize.c
@@ -28,24 +28,31 @@
#if defined(__RTEMS_DO_NOT_INLINE_CORE_MUTEX_SEIZE__)
void _CORE_mutex_Seize(
CORE_mutex_Control *_the_mutex,
+ Thread_Control *_executing,
Objects_Id _id,
bool _wait,
Watchdog_Interval _timeout,
ISR_Level _level
)
{
- _CORE_mutex_Seize_body( _the_mutex, _id, _wait, _timeout, _level );
+ _CORE_mutex_Seize_body(
+ _the_mutex,
+ _executing,
+ _id,
+ _wait,
+ _timeout,
+ _level
+ );
}
#endif
void _CORE_mutex_Seize_interrupt_blocking(
CORE_mutex_Control *the_mutex,
+ Thread_Control *executing,
Watchdog_Interval timeout
)
{
- Thread_Control *executing;
- executing = _Thread_Executing;
if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) ) {
if ( _Scheduler_Is_priority_higher_than(
executing->current_priority,
diff --git a/cpukit/score/src/coremutexseizeintr.c b/cpukit/score/src/coremutexseizeintr.c
index f31d2fba96..cc726b6135 100644
--- a/cpukit/score/src/coremutexseizeintr.c
+++ b/cpukit/score/src/coremutexseizeintr.c
@@ -28,9 +28,14 @@
#if defined(__RTEMS_DO_NOT_INLINE_CORE_MUTEX_SEIZE__)
int _CORE_mutex_Seize_interrupt_trylock(
CORE_mutex_Control *the_mutex,
+ Thread_Control *executing,
ISR_Level level
)
{
- return _CORE_mutex_Seize_interrupt_trylock_body( the_mutex, level );
+ return _CORE_mutex_Seize_interrupt_trylock_body(
+ the_mutex,
+ executing,
+ level
+ );
}
#endif