summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-11-29 06:23:27 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-12-04 10:53:39 +0100
commit6c2b8a4b35536a5f99ba1ef91139485b011dafc1 (patch)
treeb1ab330104094ec83051c932c4d5cb9e653a4568
parentada/sp09: Fix timer server test case (diff)
downloadrtems-6c2b8a4b35536a5f99ba1ef91139485b011dafc1.tar.bz2
score: Use self-contained API mutex
Use a self-contained recursive mutex for API_Mutex_Control. The API mutexes are protected against asynchronous thread cancellation. Add dedicated mutexes for libatomic and TOD. Close #2629. Close #2630.
-rw-r--r--cpukit/posix/include/rtems/posix/posixapi.h2
-rw-r--r--cpukit/rtems/src/rtemsobjectgetapiclassname.c1
-rw-r--r--cpukit/rtems/src/timerserver.c2
-rwxr-xr-xcpukit/sapi/include/confdefs.h10
-rw-r--r--cpukit/sapi/src/exinit.c9
-rw-r--r--cpukit/score/Makefile.am7
-rw-r--r--cpukit/score/include/rtems/score/apimutex.h65
-rw-r--r--cpukit/score/include/rtems/score/assert.h8
-rw-r--r--cpukit/score/include/rtems/score/objectimpl.h5
-rw-r--r--cpukit/score/include/rtems/score/onceimpl.h4
-rw-r--r--cpukit/score/include/rtems/score/todimpl.h16
-rw-r--r--cpukit/score/src/allocatormutex.c37
-rw-r--r--cpukit/score/src/apimutex.c60
-rw-r--r--cpukit/score/src/apimutexisowner.c8
-rw-r--r--cpukit/score/src/apimutexlock.c18
-rw-r--r--cpukit/score/src/apimutexunlock.c18
-rw-r--r--cpukit/score/src/coretod.c20
-rw-r--r--cpukit/score/src/coretodset.c2
-rw-r--r--cpukit/score/src/debugisownerofallocator.c37
-rw-r--r--cpukit/score/src/libatomic.c10
-rw-r--r--cpukit/score/src/objectactivecount.c2
-rw-r--r--cpukit/score/src/objectallocate.c2
-rw-r--r--cpukit/score/src/objectextendinformation.c2
-rw-r--r--cpukit/score/src/objectfree.c2
-rw-r--r--cpukit/score/src/objectshrinkinformation.c2
-rw-r--r--cpukit/score/src/once.c12
-rw-r--r--testsuites/sptests/sp43/init.c4
-rw-r--r--testsuites/sptests/sp43/sp43.scn11
-rw-r--r--testsuites/sptests/spsysinit01/init.c4
29 files changed, 127 insertions, 253 deletions
diff --git a/cpukit/posix/include/rtems/posix/posixapi.h b/cpukit/posix/include/rtems/posix/posixapi.h
index 2441a2ee6f..29394ab94e 100644
--- a/cpukit/posix/include/rtems/posix/posixapi.h
+++ b/cpukit/posix/include/rtems/posix/posixapi.h
@@ -21,8 +21,8 @@
#include <rtems/config.h>
#include <rtems/score/assert.h>
-#include <rtems/score/apimutex.h>
#include <rtems/score/objectimpl.h>
+#include <rtems/score/onceimpl.h>
#include <rtems/score/threadimpl.h>
#include <rtems/seterr.h>
diff --git a/cpukit/rtems/src/rtemsobjectgetapiclassname.c b/cpukit/rtems/src/rtemsobjectgetapiclassname.c
index 73f6a3d022..b1cc161c9e 100644
--- a/cpukit/rtems/src/rtemsobjectgetapiclassname.c
+++ b/cpukit/rtems/src/rtemsobjectgetapiclassname.c
@@ -25,7 +25,6 @@
static const rtems_assoc_t rtems_object_api_internal_assoc[] = {
{ "Thread", OBJECTS_INTERNAL_THREADS, 0},
- { "Mutex", OBJECTS_INTERNAL_MUTEXES, 0},
{ NULL, 0, 0}
};
diff --git a/cpukit/rtems/src/timerserver.c b/cpukit/rtems/src/timerserver.c
index 894d50efc0..09e792aa1c 100644
--- a/cpukit/rtems/src/timerserver.c
+++ b/cpukit/rtems/src/timerserver.c
@@ -29,7 +29,7 @@
#include <rtems.h>
#include <rtems/rtems/timerimpl.h>
#include <rtems/rtems/tasksimpl.h>
-#include <rtems/score/apimutex.h>
+#include <rtems/score/onceimpl.h>
#include <rtems/score/todimpl.h>
static Timer_server_Control _Timer_server_Default;
diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h
index ca4ee47b2b..8066d9a426 100755
--- a/cpukit/sapi/include/confdefs.h
+++ b/cpukit/sapi/include/confdefs.h
@@ -2794,13 +2794,6 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
#endif
/**
- * RTEMS uses two instance of an internal mutex class. This accounts
- * for these mutexes.
- */
-#define _CONFIGURE_API_MUTEX_MEMORY \
- _Configure_Object_RAM(2, sizeof(API_Mutex_Control))
-
-/**
* This calculates the amount of memory reserved for the IDLE tasks.
* In an SMP system, each CPU core has its own idle task.
*/
@@ -2829,8 +2822,7 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
*/
#define _CONFIGURE_MEMORY_FOR_SYSTEM_OVERHEAD \
( _CONFIGURE_MEMORY_FOR_INTERNAL_TASKS + \
- _CONFIGURE_INTERRUPT_STACK_MEMORY + \
- _CONFIGURE_API_MUTEX_MEMORY \
+ _CONFIGURE_INTERRUPT_STACK_MEMORY \
)
/**
diff --git a/cpukit/sapi/src/exinit.c b/cpukit/sapi/src/exinit.c
index ed269d5566..6ec5a7662e 100644
--- a/cpukit/sapi/src/exinit.c
+++ b/cpukit/sapi/src/exinit.c
@@ -27,7 +27,6 @@
#include <rtems/sysinit.h>
#include <rtems/score/sysstate.h>
-#include <rtems/score/apimutex.h>
#include <rtems/score/copyrt.h>
#include <rtems/score/heap.h>
#include <rtems/score/interr.h>
@@ -59,10 +58,6 @@ _Objects_Information_table[ OBJECTS_APIS_LAST + 1 ] = {
&_POSIX_Objects[ 0 ]
};
-API_Mutex_Control *_RTEMS_Allocator_Mutex;
-
-API_Mutex_Control *_Once_Mutex;
-
static void rtems_initialize_data_structures(void)
{
/*
@@ -83,10 +78,6 @@ static void rtems_initialize_data_structures(void)
_ISR_Handler_initialization();
- _API_Mutex_Initialization( 2 );
- _API_Mutex_Allocate( &_RTEMS_Allocator_Mutex );
- _API_Mutex_Allocate( &_Once_Mutex );
-
_Thread_Handler_initialization();
_Scheduler_Handler_initialization();
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index 1c815b1af4..b7edf09dde 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -162,8 +162,10 @@ libscore_a_SOURCES += src/schedulersmpstartidle.c
endif
## CORE_APIMUTEX_C_FILES
-libscore_a_SOURCES += src/apimutex.c \
- src/apimutexlock.c src/apimutexisowner.c src/apimutexunlock.c
+libscore_a_SOURCES += src/allocatormutex.c
+libscore_a_SOURCES += src/apimutexisowner.c
+libscore_a_SOURCES += src/apimutexlock.c
+libscore_a_SOURCES += src/apimutexunlock.c
## CORE_BARRIER_C_FILES
libscore_a_SOURCES += src/corebarrier.c src/corebarrierrelease.c \
@@ -337,7 +339,6 @@ libscore_a_SOURCES += src/ioprintf.c
libscore_a_SOURCES += src/iovprintf.c
libscore_a_SOURCES += src/isrisinprogress.c
libscore_a_SOURCES += src/condition.c
-libscore_a_SOURCES += src/debugisownerofallocator.c
libscore_a_SOURCES += src/futex.c
libscore_a_SOURCES += src/profilingisrentryexit.c
libscore_a_SOURCES += src/mutex.c
diff --git a/cpukit/score/include/rtems/score/apimutex.h b/cpukit/score/include/rtems/score/apimutex.h
index aa08481c83..f43edf23f4 100644
--- a/cpukit/score/include/rtems/score/apimutex.h
+++ b/cpukit/score/include/rtems/score/apimutex.h
@@ -18,8 +18,9 @@
#ifndef _RTEMS_SCORE_APIMUTEX_H
#define _RTEMS_SCORE_APIMUTEX_H
-#include <rtems/score/coremutex.h>
-#include <rtems/score/object.h>
+#include <rtems/score/thread.h>
+
+#include <sys/lock.h>
/**
* @defgroup ScoreAPIMutex API Mutex Handler
@@ -39,14 +40,9 @@ extern "C" {
*/
typedef struct {
/**
- * @brief Allows each API Mutex to be a full-fledged RTEMS object.
- */
- Objects_Control Object;
-
- /**
- * Contains the SuperCore mutex information.
+ * A recursive mutex.
*/
- CORE_recursive_mutex_Control Mutex;
+ struct _Mutex_recursive_Control Mutex;
/**
* @brief The thread life protection state before the outer-most mutex
@@ -56,20 +52,10 @@ typedef struct {
} API_Mutex_Control;
/**
- * @brief Initialization for the API Mutexe Handler.
- *
- * The value @a maximum_mutexes is the maximum number of API mutexes that may
- * exist at any time.
- *
- * @param[in] maximum_mutexes is the maximum number of API mutexes.
+ * @brief Statically initialize an API mutex.
*/
-void _API_Mutex_Initialization( uint32_t maximum_mutexes );
-
-/**
- * @brief Allocates an API mutex from the inactive set and returns it in
- * @a mutex.
- */
-void _API_Mutex_Allocate( API_Mutex_Control **mutex );
+#define API_MUTEX_INITIALIZER( name ) \
+ { _MUTEX_RECURSIVE_NAMED_INITIALIZER( name ), 0 }
/**
* @brief Acquires the specified API mutex.
@@ -107,40 +93,11 @@ bool _API_Mutex_Is_owner( const API_Mutex_Control *mutex );
*/
/**@{**/
-/**
- * @brief Memory allocation mutex.
- *
- * This points to the API Mutex instance used to ensure that only
- * one thread at a time is allocating or freeing memory.
- */
-extern API_Mutex_Control *_RTEMS_Allocator_Mutex;
-
-static inline void _RTEMS_Lock_allocator( void )
-{
- _API_Mutex_Lock( _RTEMS_Allocator_Mutex );
-}
-
-static inline void _RTEMS_Unlock_allocator( void )
-{
- _API_Mutex_Unlock( _RTEMS_Allocator_Mutex );
-}
+void _RTEMS_Lock_allocator( void );
-static inline bool _RTEMS_Allocator_is_owner( void )
-{
- return _API_Mutex_Is_owner( _RTEMS_Allocator_Mutex );
-}
-
-extern API_Mutex_Control *_Once_Mutex;
+void _RTEMS_Unlock_allocator( void );
-static inline void _Once_Lock( void )
-{
- _API_Mutex_Lock( _Once_Mutex );
-}
-
-static inline void _Once_Unlock( void )
-{
- _API_Mutex_Unlock( _Once_Mutex );
-}
+bool _RTEMS_Allocator_is_owner( void );
/** @} */
diff --git a/cpukit/score/include/rtems/score/assert.h b/cpukit/score/include/rtems/score/assert.h
index c61c0a0399..d4432838ce 100644
--- a/cpukit/score/include/rtems/score/assert.h
+++ b/cpukit/score/include/rtems/score/assert.h
@@ -101,14 +101,6 @@ extern "C" {
bool _Debug_Is_thread_dispatching_allowed( void );
#endif
-/**
- * @brief Returns true if the current thread of execution owns the allocator
- * mutex.
- */
-#if defined( RTEMS_DEBUG )
- bool _Debug_Is_owner_of_allocator( void );
-#endif
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/cpukit/score/include/rtems/score/objectimpl.h b/cpukit/score/include/rtems/score/objectimpl.h
index 0338a481ea..cc5820785c 100644
--- a/cpukit/score/include/rtems/score/objectimpl.h
+++ b/cpukit/score/include/rtems/score/objectimpl.h
@@ -49,12 +49,11 @@ typedef bool (*Objects_Name_comparators)(
*/
typedef enum {
OBJECTS_INTERNAL_NO_CLASS = 0,
- OBJECTS_INTERNAL_THREADS = 1,
- OBJECTS_INTERNAL_MUTEXES = 2
+ OBJECTS_INTERNAL_THREADS = 1
} Objects_Internal_API;
/** This macro is used to generically specify the last API index. */
-#define OBJECTS_INTERNAL_CLASSES_LAST OBJECTS_INTERNAL_MUTEXES
+#define OBJECTS_INTERNAL_CLASSES_LAST OBJECTS_INTERNAL_THREADS
/**
* This enumerated type is used in the class field of the object ID
diff --git a/cpukit/score/include/rtems/score/onceimpl.h b/cpukit/score/include/rtems/score/onceimpl.h
index 21e9edade5..60f1378506 100644
--- a/cpukit/score/include/rtems/score/onceimpl.h
+++ b/cpukit/score/include/rtems/score/onceimpl.h
@@ -39,6 +39,10 @@ extern "C" {
int _Once( unsigned char *once_state, void (*init_routine)(void) );
+void _Once_Lock( void );
+
+void _Once_Unlock( void );
+
/** @} */
#ifdef __cplusplus
diff --git a/cpukit/score/include/rtems/score/todimpl.h b/cpukit/score/include/rtems/score/todimpl.h
index e3a1a8f58c..b00ab6cca2 100644
--- a/cpukit/score/include/rtems/score/todimpl.h
+++ b/cpukit/score/include/rtems/score/todimpl.h
@@ -19,7 +19,6 @@
#define _RTEMS_SCORE_TODIMPL_H
#include <rtems/score/tod.h>
-#include <rtems/score/apimutex.h>
#include <rtems/score/timestamp.h>
#include <rtems/score/timecounterimpl.h>
#include <rtems/score/watchdog.h>
@@ -143,16 +142,13 @@ typedef struct {
extern TOD_Control _TOD;
-static inline void _TOD_Lock( void )
-{
- /* FIXME: https://devel.rtems.org/ticket/2630 */
- _API_Mutex_Lock( _Once_Mutex );
-}
+void _TOD_Lock( void );
-static inline void _TOD_Unlock( void )
-{
- _API_Mutex_Unlock( _Once_Mutex );
-}
+void _TOD_Unlock( void );
+
+#if defined(RTEMS_DEBUG)
+bool _TOD_Is_owner( void );
+#endif
static inline void _TOD_Acquire( ISR_lock_Context *lock_context )
{
diff --git a/cpukit/score/src/allocatormutex.c b/cpukit/score/src/allocatormutex.c
new file mode 100644
index 0000000000..7f98a4008f
--- /dev/null
+++ b/cpukit/score/src/allocatormutex.c
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2017 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/score/apimutex.h>
+
+static API_Mutex_Control _RTEMS_Allocator_Mutex =
+ API_MUTEX_INITIALIZER( "_Allocator" );
+
+void _RTEMS_Lock_allocator( void )
+{
+ _API_Mutex_Lock( &_RTEMS_Allocator_Mutex );
+}
+
+void _RTEMS_Unlock_allocator( void )
+{
+ _API_Mutex_Unlock( &_RTEMS_Allocator_Mutex );
+}
+
+bool _RTEMS_Allocator_is_owner( void )
+{
+ return _API_Mutex_Is_owner( &_RTEMS_Allocator_Mutex );
+}
diff --git a/cpukit/score/src/apimutex.c b/cpukit/score/src/apimutex.c
deleted file mode 100644
index ed5cfd5831..0000000000
--- a/cpukit/score/src/apimutex.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * @file
- *
- * @brief Initialization and Allocation for API Mutex Handler
- *
- * @ingroup ScoreAPIMutex
- */
-
-/*
- * COPYRIGHT (c) 1989-2007.
- * On-Line Applications Research Corporation (OAR).
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rtems/score/apimutex.h>
-#include <rtems/score/coremuteximpl.h>
-#include <rtems/score/objectimpl.h>
-
-static Objects_Information _API_Mutex_Information;
-
-void _API_Mutex_Initialization(
- uint32_t maximum_mutexes
-)
-{
- _Objects_Initialize_information(
- &_API_Mutex_Information, /* object information table */
- OBJECTS_INTERNAL_API, /* object API */
- OBJECTS_INTERNAL_MUTEXES, /* object class */
- maximum_mutexes, /* maximum objects of this class */
- sizeof( API_Mutex_Control ), /* size of this object's control block */
- false, /* true if the name is a string */
- 0, /* maximum length of an object name */
- NULL /* Proxy extraction support callout */
- );
-}
-
-void _API_Mutex_Allocate(
- API_Mutex_Control **the_mutex
-)
-{
- API_Mutex_Control *mutex;
-
- mutex = (API_Mutex_Control *)
- _Objects_Allocate_unprotected( &_API_Mutex_Information );
-
- _Assert( mutex != NULL );
-
- _CORE_recursive_mutex_Initialize( &mutex->Mutex );
-
- _Objects_Open_u32( &_API_Mutex_Information, &mutex->Object, 1 );
-
- *the_mutex = mutex;
-}
diff --git a/cpukit/score/src/apimutexisowner.c b/cpukit/score/src/apimutexisowner.c
index 65b80ed5b3..3c6f2a1b21 100644
--- a/cpukit/score/src/apimutexisowner.c
+++ b/cpukit/score/src/apimutexisowner.c
@@ -18,13 +18,9 @@
#endif
#include <rtems/score/apimutex.h>
-#include <rtems/score/coremuteximpl.h>
-#include <rtems/score/threadimpl.h>
+#include <rtems/score/percpu.h>
bool _API_Mutex_Is_owner( const API_Mutex_Control *the_mutex )
{
- return _CORE_mutex_Is_owner(
- &the_mutex->Mutex.Mutex,
- _Thread_Get_executing()
- );
+ return the_mutex->Mutex._Mutex._Queue._owner == _Thread_Get_executing();
}
diff --git a/cpukit/score/src/apimutexlock.c b/cpukit/score/src/apimutexlock.c
index 312dcc2993..46a48a3e50 100644
--- a/cpukit/score/src/apimutexlock.c
+++ b/cpukit/score/src/apimutexlock.c
@@ -20,30 +20,18 @@
#endif
#include <rtems/score/apimutex.h>
-#include <rtems/score/coremuteximpl.h>
#include <rtems/score/threadimpl.h>
void _API_Mutex_Lock( API_Mutex_Control *the_mutex )
{
- Thread_Life_state previous_thread_life_state;
- Thread_queue_Context queue_context;
+ Thread_Life_state previous_thread_life_state;
previous_thread_life_state =
_Thread_Set_life_protection( THREAD_LIFE_PROTECTED );
- _Thread_queue_Context_initialize( &queue_context );
- _ISR_lock_ISR_disable( &queue_context.Lock_context.Lock_context );
- _Thread_queue_Context_set_enqueue_do_nothing_extra( &queue_context );
- _CORE_recursive_mutex_Seize(
- &the_mutex->Mutex,
- CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS,
- _Thread_Executing,
- true,
- _CORE_recursive_mutex_Seize_nested,
- &queue_context
- );
+ _Mutex_recursive_Acquire( &the_mutex->Mutex );
- if ( the_mutex->Mutex.nest_level == 0 ) {
+ if ( the_mutex->Mutex._nest_level == 0 ) {
the_mutex->previous_thread_life_state = previous_thread_life_state;
}
}
diff --git a/cpukit/score/src/apimutexunlock.c b/cpukit/score/src/apimutexunlock.c
index e1fe6459d3..b4a5592059 100644
--- a/cpukit/score/src/apimutexunlock.c
+++ b/cpukit/score/src/apimutexunlock.c
@@ -20,25 +20,17 @@
#endif
#include <rtems/score/apimutex.h>
-#include <rtems/score/coremuteximpl.h>
+#include <rtems/score/threadimpl.h>
void _API_Mutex_Unlock( API_Mutex_Control *the_mutex )
{
- Thread_queue_Context queue_context;
- Thread_Life_state previous_thread_life_state;
- bool restore_thread_life_protection;
+ Thread_Life_state previous_thread_life_state;
+ bool restore_thread_life_protection;
previous_thread_life_state = the_mutex->previous_thread_life_state;
- restore_thread_life_protection = the_mutex->Mutex.nest_level == 0;
+ restore_thread_life_protection = the_mutex->Mutex._nest_level == 0;
- _Thread_queue_Context_initialize( &queue_context );
- _ISR_lock_ISR_disable( &queue_context.Lock_context.Lock_context );
- _CORE_recursive_mutex_Surrender(
- &the_mutex->Mutex,
- CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS,
- _Thread_Executing,
- &queue_context
- );
+ _Mutex_recursive_Release( &the_mutex->Mutex );
if ( restore_thread_life_protection ) {
_Thread_Set_life_protection( previous_thread_life_state );
diff --git a/cpukit/score/src/coretod.c b/cpukit/score/src/coretod.c
index 1df1b4ed86..cd8428c15d 100644
--- a/cpukit/score/src/coretod.c
+++ b/cpukit/score/src/coretod.c
@@ -19,5 +19,25 @@
#endif
#include <rtems/score/todimpl.h>
+#include <rtems/score/apimutex.h>
TOD_Control _TOD;
+
+static API_Mutex_Control _TOD_Mutex = API_MUTEX_INITIALIZER( "_TOD" );
+
+void _TOD_Lock( void )
+{
+ _API_Mutex_Lock( &_TOD_Mutex );
+}
+
+void _TOD_Unlock( void )
+{
+ _API_Mutex_Unlock( &_TOD_Mutex );
+}
+
+#if defined(RTEMS_DEBUG)
+bool _TOD_Is_owner( void )
+{
+ return _API_Mutex_Is_owner( &_TOD_Mutex );
+}
+#endif
diff --git a/cpukit/score/src/coretodset.c b/cpukit/score/src/coretodset.c
index 1223f5c7aa..fa6407cfaf 100644
--- a/cpukit/score/src/coretodset.c
+++ b/cpukit/score/src/coretodset.c
@@ -32,7 +32,7 @@ void _TOD_Set(
uint32_t cpu_count;
uint32_t cpu_index;
- _Assert( _API_Mutex_Is_owner( _Once_Mutex ) );
+ _Assert( _TOD_Is_owner() );
timespec2bintime( tod, &tod_as_bintime );
_Timecounter_Set_clock( &tod_as_bintime, lock_context );
diff --git a/cpukit/score/src/debugisownerofallocator.c b/cpukit/score/src/debugisownerofallocator.c
deleted file mode 100644
index 6b396df4fc..0000000000
--- a/cpukit/score/src/debugisownerofallocator.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2014-2015 embedded brains GmbH. All rights reserved.
- *
- * embedded brains GmbH
- * Dornierstr. 4
- * 82178 Puchheim
- * Germany
- * <rtems@embedded-brains.de>
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
- #include "config.h"
-#endif
-
-#include <rtems/score/assert.h>
-#include <rtems/score/apimutex.h>
-#include <rtems/score/threadimpl.h>
-
-#if defined( RTEMS_DEBUG )
- bool _Debug_Is_owner_of_allocator( void )
- {
- API_Mutex_Control *mutex = _RTEMS_Allocator_Mutex;
- bool owner;
-
- if ( mutex != NULL ) {
- owner = _API_Mutex_Is_owner( mutex );
- } else {
- owner = false;
- }
-
- return owner;
- }
-#endif
diff --git a/cpukit/score/src/libatomic.c b/cpukit/score/src/libatomic.c
index bfa3e6fb25..364e38f1b3 100644
--- a/cpukit/score/src/libatomic.c
+++ b/cpukit/score/src/libatomic.c
@@ -59,21 +59,19 @@ void _Libatomic_Protect_end( void *ptr, __uint32_t isr_level )
_ISR_Local_enable( isr_level );
}
-/*
- * FIXME: The once lock should be only a temporary solution. We need a
- * dedicated internal mutex for this.
- */
+static API_Mutex_Control _Libatomic_Mutex =
+ API_MUTEX_INITIALIZER( "_Libatomic" );
void _Libatomic_Lock_n( void *ptr, __size_t n )
{
(void) ptr;
(void) n;
- _Once_Lock();
+ _API_Mutex_Lock( &_Libatomic_Mutex );
}
void _Libatomic_Unlock_n( void *ptr, __size_t n )
{
(void) ptr;
(void) n;
- _Once_Unlock();
+ _API_Mutex_Unlock( &_Libatomic_Mutex );
}
diff --git a/cpukit/score/src/objectactivecount.c b/cpukit/score/src/objectactivecount.c
index de3243afcb..376820158a 100644
--- a/cpukit/score/src/objectactivecount.c
+++ b/cpukit/score/src/objectactivecount.c
@@ -27,7 +27,7 @@ Objects_Maximum _Objects_Active_count(
size_t inactive;
size_t maximum;
- _Assert( _Debug_Is_owner_of_allocator() );
+ _Assert( _Objects_Allocator_is_owner() );
inactive = _Chain_Node_count_unprotected( &information->Inactive );
maximum = information->maximum;
diff --git a/cpukit/score/src/objectallocate.c b/cpukit/score/src/objectallocate.c
index 40a7cae82c..146b5d5976 100644
--- a/cpukit/score/src/objectallocate.c
+++ b/cpukit/score/src/objectallocate.c
@@ -43,7 +43,7 @@ Objects_Control *_Objects_Allocate_unprotected(
Objects_Control *the_object;
_Assert(
- _Debug_Is_owner_of_allocator()
+ _Objects_Allocator_is_owner()
|| !_System_state_Is_up( _System_state_Get() )
);
diff --git a/cpukit/score/src/objectextendinformation.c b/cpukit/score/src/objectextendinformation.c
index cd78a72af5..f4ac11be43 100644
--- a/cpukit/score/src/objectextendinformation.c
+++ b/cpukit/score/src/objectextendinformation.c
@@ -56,7 +56,7 @@ void _Objects_Extend_information(
bool do_extend;
_Assert(
- _Debug_Is_owner_of_allocator()
+ _Objects_Allocator_is_owner()
|| !_System_state_Is_up( _System_state_Get() )
);
diff --git a/cpukit/score/src/objectfree.c b/cpukit/score/src/objectfree.c
index f1c0ee49b2..30ea1e36e5 100644
--- a/cpukit/score/src/objectfree.c
+++ b/cpukit/score/src/objectfree.c
@@ -29,7 +29,7 @@ void _Objects_Free(
{
uint32_t allocation_size = information->allocation_size;
- _Assert( _Debug_Is_owner_of_allocator() );
+ _Assert( _Objects_Allocator_is_owner() );
_Chain_Append_unprotected( &information->Inactive, &the_object->Node );
diff --git a/cpukit/score/src/objectshrinkinformation.c b/cpukit/score/src/objectshrinkinformation.c
index 2f64cd2502..db085e1042 100644
--- a/cpukit/score/src/objectshrinkinformation.c
+++ b/cpukit/score/src/objectshrinkinformation.c
@@ -31,7 +31,7 @@ void _Objects_Shrink_information(
uint32_t block;
uint32_t index_base;
- _Assert( _Debug_Is_owner_of_allocator() );
+ _Assert( _Objects_Allocator_is_owner() );
/*
* Search the list to find block or chunk with all objects inactive.
diff --git a/cpukit/score/src/once.c b/cpukit/score/src/once.c
index 427659e173..5237c11878 100644
--- a/cpukit/score/src/once.c
+++ b/cpukit/score/src/once.c
@@ -54,3 +54,15 @@ int _Once( unsigned char *once_state, void ( *init_routine )( void ) )
return eno;
}
+
+static API_Mutex_Control _Once_Mutex = API_MUTEX_INITIALIZER( "_Once" );
+
+void _Once_Lock( void )
+{
+ _API_Mutex_Lock( &_Once_Mutex );
+}
+
+void _Once_Unlock( void )
+{
+ _API_Mutex_Unlock( &_Once_Mutex );
+}
diff --git a/testsuites/sptests/sp43/init.c b/testsuites/sptests/sp43/init.c
index a0025353ec..2f6cbfdfca 100644
--- a/testsuites/sptests/sp43/init.c
+++ b/testsuites/sptests/sp43/init.c
@@ -347,9 +347,9 @@ rtems_task Init(
rtems_object_get_api_class_name( 0, OBJECTS_RTEMS_TASKS ) );
printf( "rtems_object_get_api_class_name(CLASSIC_API, 0) = %s\n",
rtems_object_get_api_class_name( OBJECTS_CLASSIC_API, 0 ) );
- printf("rtems_object_get_api_class_name(INTERNAL_API, MUTEXES) = %s\n",
+ printf("rtems_object_get_api_class_name(INTERNAL_API, THREADS) = %s\n",
rtems_object_get_api_class_name(
- OBJECTS_INTERNAL_API, OBJECTS_INTERNAL_MUTEXES));
+ OBJECTS_INTERNAL_API, OBJECTS_INTERNAL_THREADS));
printf("rtems_object_get_api_class_name(CLASSIC_API, RTEMS_BARRIERS) = %s\n",
rtems_object_get_api_class_name(
OBJECTS_CLASSIC_API, OBJECTS_RTEMS_BARRIERS));
diff --git a/testsuites/sptests/sp43/sp43.scn b/testsuites/sptests/sp43/sp43.scn
index 9594f12772..999e4c1f94 100644
--- a/testsuites/sptests/sp43/sp43.scn
+++ b/testsuites/sptests/sp43/sp43.scn
@@ -1,5 +1,5 @@
*** BEGIN OF TEST SP 43 ***
-RTEMS Version: rtems-4.11.99.0(SPARC/w/FPU/sis)
+RTEMS Version: rtems-5.0.0 (SPARC/w/FPU/erc32)
rtems_object_get_classic_name - INVALID_ADDRESS
rtems_object_get_classic_name - INVALID_ID (bad index)
rtems_object_get_classic_name - INVALID_ID (unallocated index)
@@ -53,7 +53,7 @@ rtems_object_api_maximum_class(0) returned 0
rtems_object_api_minimum_class(255) returned -1
rtems_object_api_maximum_class(255) returned 0
rtems_object_api_minimum_class(OBJECTS_INTERNAL_API) returned 1
-rtems_object_api_maximum_class(OBJECTS_INTERNAL_API) returned 2
+rtems_object_api_maximum_class(OBJECTS_INTERNAL_API) returned 1
rtems_object_api_minimum_class(OBJECTS_CLASSIC_API) returned 1
rtems_object_api_maximum_class(OBJECTS_CLASSIC_API) returned 10
<pause>
@@ -63,7 +63,7 @@ rtems_object_get_api_name(INTERNAL_API) = Internal
rtems_object_get_api_name(CLASSIC_API) = Classic
rtems_object_get_api_class_name(0, RTEMS_TASKS) = BAD API
rtems_object_get_api_class_name(CLASSIC_API, 0) = BAD CLASS
-rtems_object_get_api_class_name(INTERNAL_API, MUTEXES) = Mutex
+rtems_object_get_api_class_name(INTERNAL_API, THREADS) = Thread
rtems_object_get_api_class_name(CLASSIC_API, RTEMS_BARRIERS) = Barrier
<pause>
rtems_object_get_class_information - INVALID_ADDRESS
@@ -82,13 +82,10 @@ Classic API Timer Information
maximum : 1 available : 1
auto_extend : no
rtems_task_set_priority - use valid Idle thread id
-rtems_task_set_priority - clobber internal API info
-rtems_task_set_priority - use valid Idle thread id again
-rtems_task_set_priority - restore internal api info
rtems_task_set_priority - clobber internal thread class info
rtems_task_set_priority - use valid Idle thread id again
rtems_task_set_priority - use valid Idle thread id again
rtems_task_set_priority - restore internal thread class info
rtems_semaphore_obtain - good but uncreated ID - INVALID_ID - OK
-rtems_object_get_classic_name - bad API pointer - INVALID_ID
+
*** END OF TEST SP 43 ***
diff --git a/testsuites/sptests/spsysinit01/init.c b/testsuites/sptests/spsysinit01/init.c
index 4b62302bd6..dc09e71e2c 100644
--- a/testsuites/sptests/spsysinit01/init.c
+++ b/testsuites/sptests/spsysinit01/init.c
@@ -232,13 +232,13 @@ LAST(RTEMS_SYSINIT_INITIAL_EXTENSIONS)
FIRST(RTEMS_SYSINIT_DATA_STRUCTURES)
{
- assert(_RTEMS_Allocator_Mutex == NULL);
+ assert(_Thread_Internal_information.Objects.maximum == 0);
next_step(DATA_STRUCTURES_PRE);
}
LAST(RTEMS_SYSINIT_DATA_STRUCTURES)
{
- assert(_RTEMS_Allocator_Mutex != NULL);
+ assert(_Thread_Internal_information.Objects.maximum != 0);
next_step(DATA_STRUCTURES_POST);
}