From faf3ff8f5ecdf9aa00c7bd28474c7fde55db9d33 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 19 Mar 2015 08:55:01 +0100 Subject: 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 42b773033c..7879902025 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 #include #include +#include #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 -- cgit v1.2.3