mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-08-31 12:48:03 +08:00
2007-11-09 Joel Sherrill <joel.sherrill@OARcorp.com>
* sapi/src/exinit.c, score/Makefile.am, score/include/rtems/score/apimutex.h: API Mutex calls should never have been inlined. Inlining them lead to many inlined copies of core mutex lock. This lead to over 2K savings in the SPARC/ERC32 minimum.exe. * score/src/apimutex.c, score/src/apimutexallocate.c, score/src/apimutexlock.c, score/src/apimutexunlock.c: New files.
This commit is contained in:
@@ -1,3 +1,13 @@
|
||||
2007-11-09 Joel Sherrill <joel.sherrill@OARcorp.com>
|
||||
|
||||
* sapi/src/exinit.c, score/Makefile.am,
|
||||
score/include/rtems/score/apimutex.h: API Mutex calls should never
|
||||
have been inlined. Inlining them lead to many inlined copies of core
|
||||
mutex lock. This lead to over 2K savings in the SPARC/ERC32
|
||||
minimum.exe.
|
||||
* score/src/apimutex.c, score/src/apimutexallocate.c,
|
||||
score/src/apimutexlock.c, score/src/apimutexunlock.c: New files.
|
||||
|
||||
2007-11-07 Till Straumann <strauman@slac.stanford.edu>
|
||||
|
||||
* score/include/rtems/score/isr.h: added RTEMS_COMPILER_MEMORY_BARRIER
|
||||
|
||||
@@ -168,7 +168,7 @@ rtems_interrupt_level rtems_initialize_executive_early(
|
||||
* Initialize the internal allocator Mutex
|
||||
*/
|
||||
_API_Mutex_Initialization( 1 );
|
||||
_API_Mutex_Allocate( _RTEMS_Allocator_Mutex );
|
||||
_API_Mutex_Allocate( &_RTEMS_Allocator_Mutex );
|
||||
|
||||
_Priority_Handler_initialization();
|
||||
|
||||
|
||||
@@ -73,6 +73,10 @@ if HAS_MP
|
||||
libscore_a_SOURCES += src/mpci.c src/objectmp.c src/threadmp.c
|
||||
endif
|
||||
|
||||
## CORE_APIMUTEX_C_FILES
|
||||
libscore_a_SOURCES += src/apimutex.c src/apimutexallocate.c \
|
||||
src/apimutexlock.c src/apimutexunlock.c
|
||||
|
||||
## CORE_BARRIER_C_FILES
|
||||
libscore_a_SOURCES += src/corebarrier.c src/corebarrierrelease.c \
|
||||
src/corebarrierwait.c
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-2006.
|
||||
* COPYRIGHT (c) 1989-2007.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
@@ -56,77 +56,39 @@ SCORE_EXTERN Objects_Information _API_Mutex_Information;
|
||||
/**
|
||||
* This routine performs the initialization necessary for this handler.
|
||||
*
|
||||
* @param[in] _maximum_mutexes is the maximum number of API mutexes
|
||||
* @param[in] maximum_mutexes is the maximum number of API mutexes
|
||||
* that may exist at any time
|
||||
*/
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
#define _API_Mutex_Initialization( _maximum_mutexes ) \
|
||||
_Objects_Initialize_information( \
|
||||
&_API_Mutex_Information, \
|
||||
OBJECTS_INTERNAL_API, \
|
||||
OBJECTS_INTERNAL_MUTEXES, \
|
||||
_maximum_mutexes, \
|
||||
sizeof( API_Mutex_Control ), \
|
||||
FALSE, \
|
||||
0, \
|
||||
FALSE, \
|
||||
NULL \
|
||||
);
|
||||
#else
|
||||
#define _API_Mutex_Initialization( _maximum_mutexes ) \
|
||||
_Objects_Initialize_information( \
|
||||
&_API_Mutex_Information, \
|
||||
OBJECTS_INTERNAL_API, \
|
||||
OBJECTS_INTERNAL_MUTEXES, \
|
||||
_maximum_mutexes, \
|
||||
sizeof( API_Mutex_Control ), \
|
||||
FALSE, \
|
||||
0 \
|
||||
);
|
||||
#endif
|
||||
void _API_Mutex_Initialization(
|
||||
uint32_t maximum_mutexes
|
||||
);
|
||||
|
||||
/**
|
||||
* This routine allocates an API mutex from the inactive set.
|
||||
*
|
||||
* @param[out] _the_mutex will contain the allocated mutex.
|
||||
* @param[out] the_mutex will contain the allocated mutex.
|
||||
*/
|
||||
#define _API_Mutex_Allocate( _the_mutex ) \
|
||||
do { \
|
||||
CORE_mutex_Attributes attr = \
|
||||
{ CORE_MUTEX_NESTING_IS_ERROR, FALSE, \
|
||||
CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT, 0 }; \
|
||||
(_the_mutex) = (API_Mutex_Control *) \
|
||||
_Objects_Allocate( &_API_Mutex_Information ); \
|
||||
_CORE_mutex_Initialize( \
|
||||
&(_the_mutex)->Mutex, &attr, CORE_MUTEX_UNLOCKED ); \
|
||||
} while (0)
|
||||
void _API_Mutex_Allocate(
|
||||
API_Mutex_Control **the_mutex
|
||||
);
|
||||
|
||||
/**
|
||||
* This routine acquires the specified API mutex.
|
||||
*
|
||||
* @param[in] _the_mutex is the mutex to acquire.
|
||||
* @param[in] the_mutex is the mutex to acquire.
|
||||
*/
|
||||
#define _API_Mutex_Lock( _the_mutex ) \
|
||||
do { \
|
||||
ISR_Level _level; \
|
||||
_ISR_Disable( _level ); \
|
||||
_CORE_mutex_Seize( \
|
||||
&(_the_mutex)->Mutex, (_the_mutex)->Object.id, TRUE, 0, (_level) ); \
|
||||
} while (0)
|
||||
void _API_Mutex_Lock(
|
||||
API_Mutex_Control *the_mutex
|
||||
);
|
||||
|
||||
/**
|
||||
* This routine releases the specified API mutex.
|
||||
*
|
||||
* @param[in] _the_mutex is the mutex to release.
|
||||
*/
|
||||
|
||||
#define _API_Mutex_Unlock( _the_mutex ) \
|
||||
do { \
|
||||
_Thread_Disable_dispatch(); \
|
||||
_CORE_mutex_Surrender( \
|
||||
&(_the_mutex)->Mutex, (_the_mutex)->Object.id, NULL ); \
|
||||
_Thread_Enable_dispatch(); \
|
||||
} while (0);
|
||||
void _API_Mutex_Unlock(
|
||||
API_Mutex_Control *the_mutex
|
||||
);
|
||||
|
||||
/**
|
||||
* This variable points to the API Mutex instance that is used
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/apimutex.h>
|
||||
|
||||
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 */
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
,
|
||||
TRUE, /* TRUE if this is a global object class */
|
||||
NULL /* Proxy extraction support callout */
|
||||
#endif
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/apimutex.h>
|
||||
|
||||
void _API_Mutex_Allocate(
|
||||
API_Mutex_Control **the_mutex
|
||||
)
|
||||
{
|
||||
API_Mutex_Control *mutex;
|
||||
CORE_mutex_Attributes attr = {
|
||||
CORE_MUTEX_NESTING_IS_ERROR,
|
||||
FALSE,
|
||||
CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT,
|
||||
0
|
||||
};
|
||||
|
||||
mutex = (API_Mutex_Control *) _Objects_Allocate( &_API_Mutex_Information );
|
||||
|
||||
_CORE_mutex_Initialize(
|
||||
&mutex->Mutex,
|
||||
&attr,
|
||||
CORE_MUTEX_UNLOCKED
|
||||
);
|
||||
|
||||
*the_mutex = mutex;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/apimutex.h>
|
||||
|
||||
void _API_Mutex_Unlock(
|
||||
API_Mutex_Control *the_mutex
|
||||
)
|
||||
{
|
||||
_Thread_Disable_dispatch();
|
||||
_CORE_mutex_Surrender(
|
||||
&the_mutex->Mutex,
|
||||
the_mutex->Object.id,
|
||||
NULL
|
||||
);
|
||||
_Thread_Enable_dispatch();
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/apimutex.h>
|
||||
|
||||
void _API_Mutex_Lock(
|
||||
API_Mutex_Control *the_mutex
|
||||
)
|
||||
{
|
||||
ISR_Level level;
|
||||
|
||||
_ISR_Disable( level );
|
||||
|
||||
_CORE_mutex_Seize(
|
||||
&the_mutex->Mutex,
|
||||
the_mutex->Object.id,
|
||||
TRUE,
|
||||
0,
|
||||
level
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user