2011-10-17 Daniel Hellstrom <daniel@gaisler.com>

PR 1935/cpukit
	* score/include/rtems/score/smplock.h, score/src/smplock.c: SMP nested
	count variable was being overritten when nested lock was taken more
	than once.
This commit is contained in:
Jennifer Averett
2011-10-17 18:51:44 +00:00
parent d63f1c9243
commit 35453000cc
3 changed files with 13 additions and 2 deletions

View File

@@ -1,3 +1,10 @@
2011-10-17 Daniel Hellstrom <daniel@gaisler.com>
PR 1935/cpukit
* score/include/rtems/score/smplock.h, score/src/smplock.c: SMP nested
count variable was being overritten when nested lock was taken more
than once.
2011-10-17 Sebastian Huber <sebastian.huber@embedded-brains.de>
PR 1938/cpukit

View File

@@ -50,6 +50,7 @@ typedef uint32_t SMP_lock_spinlock_simple_Control;
* times.
*/
typedef struct {
SMP_lock_spinlock_simple_Control lock;
uint32_t count;
int cpu_id;
} SMP_lock_spinlock_nested_Control;

View File

@@ -114,6 +114,7 @@ void _SMP_lock_spinlock_nested_Initialize(
SMP_lock_spinlock_nested_Control *lock
)
{
lock->lock = 0;
lock->count = 0;
lock->cpu_id = -1;
}
@@ -143,8 +144,9 @@ void _SMP_lock_spinlock_nested_Release(
if (lock->count == 1) {
lock->cpu_id = -1;
debug_logit( 'U', lock );
RTEMS_COMPILER_MEMORY_BARRIER();
lock->count = 0;
RTEMS_COMPILER_MEMORY_BARRIER();
lock->lock = 0;
} else {
debug_logit( 'u', lock );
lock->count--;
@@ -174,7 +176,7 @@ ISR_Level _SMP_lock_spinlock_nested_Obtain(
*/
while (1) {
RTEMS_COMPILER_MEMORY_BARRIER();
SMP_CPU_SWAP( &lock->count, value, previous );
SMP_CPU_SWAP( &lock->lock, value, previous );
RTEMS_COMPILER_MEMORY_BARRIER();
if ( previous == 0 ) {
/* was not locked */
@@ -190,6 +192,7 @@ ISR_Level _SMP_lock_spinlock_nested_Obtain(
}
lock->cpu_id = cpu_id;
lock->count = 1;
debug_logit( 'L', lock );
return level;