diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-03-27 13:38:04 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-03-31 08:29:43 +0200 |
commit | 346845730cb7cdd3f2a1e9231cced7cdfd046ce1 (patch) | |
tree | 3764fe70bfaea1d230d5052982b3bff6b1322e13 /cpukit/score/src/apimutexlock.c | |
parent | score: Relax Giant lock usage for API mutexes (diff) | |
download | rtems-346845730cb7cdd3f2a1e9231cced7cdfd046ce1.tar.bz2 |
score: Use thread life protection for API mutexes
This prevents that asynchronous thread deletion can lead to an unusable
allocator or once mutex.
Diffstat (limited to 'cpukit/score/src/apimutexlock.c')
-rw-r--r-- | cpukit/score/src/apimutexlock.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/cpukit/score/src/apimutexlock.c b/cpukit/score/src/apimutexlock.c index d943bddf5d..07e5159987 100644 --- a/cpukit/score/src/apimutexlock.c +++ b/cpukit/score/src/apimutexlock.c @@ -19,16 +19,17 @@ #include "config.h" #endif -#include <rtems/system.h> #include <rtems/score/apimutex.h> #include <rtems/score/coremuteximpl.h> +#include <rtems/score/threadimpl.h> -void _API_Mutex_Lock( - API_Mutex_Control *the_mutex -) +void _API_Mutex_Lock( API_Mutex_Control *the_mutex ) { + bool previous_thread_life_protection; ISR_Level level; + previous_thread_life_protection = _Thread_Set_life_protection( true ); + #if defined(RTEMS_SMP) _Thread_Disable_dispatch(); #endif @@ -44,6 +45,11 @@ void _API_Mutex_Lock( level ); + if ( the_mutex->Mutex.nest_count == 1 ) { + the_mutex->previous_thread_life_protection = + previous_thread_life_protection; + } + #if defined(RTEMS_SMP) _Thread_Enable_dispatch(); #endif |