diff options
-rw-r--r-- | cpukit/ChangeLog | 10 | ||||
-rw-r--r-- | cpukit/sapi/src/exinit.c | 2 | ||||
-rw-r--r-- | cpukit/score/Makefile.am | 4 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/apimutex.h | 70 | ||||
-rw-r--r-- | cpukit/score/src/apimutex.c | 37 | ||||
-rw-r--r-- | cpukit/score/src/apimutexallocate.c | 40 | ||||
-rw-r--r-- | cpukit/score/src/apimutexlock.c | 30 | ||||
-rw-r--r-- | cpukit/score/src/apimutexunlock.c | 34 |
8 files changed, 172 insertions, 55 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index c59da97b73..27aaf4b1c7 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -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 diff --git a/cpukit/sapi/src/exinit.c b/cpukit/sapi/src/exinit.c index c7c6e18552..f8c13ffe62 100644 --- a/cpukit/sapi/src/exinit.c +++ b/cpukit/sapi/src/exinit.c @@ -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(); diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am index cdf975ea5c..eefe200510 100644 --- a/cpukit/score/Makefile.am +++ b/cpukit/score/Makefile.am @@ -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 diff --git a/cpukit/score/include/rtems/score/apimutex.h b/cpukit/score/include/rtems/score/apimutex.h index ea257f4a7e..2a7a3d2305 100644 --- a/cpukit/score/include/rtems/score/apimutex.h +++ b/cpukit/score/include/rtems/score/apimutex.h @@ -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 diff --git a/cpukit/score/src/apimutex.c b/cpukit/score/src/apimutex.c new file mode 100644 index 0000000000..48c25fbef2 --- /dev/null +++ b/cpukit/score/src/apimutex.c @@ -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 + ); +} diff --git a/cpukit/score/src/apimutexallocate.c b/cpukit/score/src/apimutexallocate.c new file mode 100644 index 0000000000..b346af42f2 --- /dev/null +++ b/cpukit/score/src/apimutexallocate.c @@ -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; +} diff --git a/cpukit/score/src/apimutexlock.c b/cpukit/score/src/apimutexlock.c new file mode 100644 index 0000000000..ca824a6e6c --- /dev/null +++ b/cpukit/score/src/apimutexlock.c @@ -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(); +} diff --git a/cpukit/score/src/apimutexunlock.c b/cpukit/score/src/apimutexunlock.c new file mode 100644 index 0000000000..3618af1d8a --- /dev/null +++ b/cpukit/score/src/apimutexunlock.c @@ -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 + ); +} |