[rtems commit] score: Fix _Debug_Is_owner_of_allocator()
Sebastian Huber
sebh at rtems.org
Thu Mar 19 07:55:25 UTC 2015
Module: rtems
Branch: master
Commit: faf3ff8f5ecdf9aa00c7bd28474c7fde55db9d33
Changeset: http://git.rtems.org/rtems/commit/?id=faf3ff8f5ecdf9aa00c7bd28474c7fde55db9d33
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Thu Mar 19 08:55:01 2015 +0100
score: Fix _Debug_Is_owner_of_allocator()
---
cpukit/score/src/debugisownerofallocator.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/cpukit/score/src/debugisownerofallocator.c b/cpukit/score/src/debugisownerofallocator.c
index 42b7730..7879902 100644
--- a/cpukit/score/src/debugisownerofallocator.c
+++ b/cpukit/score/src/debugisownerofallocator.c
@@ -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
More information about the vc
mailing list