score: Fix _Debug_Is_owner_of_allocator()

This commit is contained in:
Sebastian Huber
2015-03-19 08:55:01 +01:00
parent da30417b24
commit faf3ff8f5e
+11 -2
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014 embedded brains GmbH. All rights reserved.
* Copyright (c) 2014-2015 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Dornierstr. 4
@@ -19,6 +19,7 @@
#include <rtems/score/assert.h>
#include <rtems/score/apimutex.h>
#include <rtems/score/thread.h>
#include <rtems/score/threaddispatch.h>
#if defined( RTEMS_DEBUG )
bool _Debug_Is_owner_of_allocator( void )
@@ -26,12 +27,20 @@
API_Mutex_Control *mutex = _RTEMS_Allocator_Mutex;
bool owner;
/*
* We have to synchronize with the _CORE_mutex_Surrender() operation,
* otherwise we may observe an outdated mutex holder.
*/
_Thread_Disable_dispatch();
if ( mutex != NULL ) {
owner = mutex->Mutex.holder == _Thread_Get_executing();
owner = mutex->Mutex.holder == _Thread_Executing;
} else {
owner = false;
}
_Thread_Enable_dispatch();
return owner;
}
#endif