From 23fec9f0e18dc4913fab818118f836af150b98f3 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 27 Mar 2014 14:16:12 +0100 Subject: score: PR2152: Use allocator mutex for objects Use allocator mutex for objects allocate/free. This prevents that the thread dispatch latency depends on the workspace/heap fragmentation. --- cpukit/score/src/objectallocate.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'cpukit/score/src/objectallocate.c') diff --git a/cpukit/score/src/objectallocate.c b/cpukit/score/src/objectallocate.c index 842c49d77a..40a7cae82c 100644 --- a/cpukit/score/src/objectallocate.c +++ b/cpukit/score/src/objectallocate.c @@ -19,7 +19,9 @@ #endif #include +#include #include +#include /* #define RTEMS_DEBUG_OBJECT_ALLOCATION */ @@ -27,12 +29,24 @@ #include #endif -Objects_Control *_Objects_Allocate( +static Objects_Control *_Objects_Get_inactive( + Objects_Information *information +) +{ + return (Objects_Control *) _Chain_Get_unprotected( &information->Inactive ); +} + +Objects_Control *_Objects_Allocate_unprotected( Objects_Information *information ) { Objects_Control *the_object; + _Assert( + _Debug_Is_owner_of_allocator() + || !_System_state_Is_up( _System_state_Get() ) + ); + /* * If the application is using the optional manager stubs and * still attempts to create the object, the information block @@ -46,7 +60,7 @@ Objects_Control *_Objects_Allocate( * OK. The manager should be initialized and configured to have objects. * With any luck, it is safe to attempt to allocate an object. */ - the_object = (Objects_Control *) _Chain_Get( &information->Inactive ); + the_object = _Objects_Get_inactive( information ); if ( information->auto_extend ) { /* @@ -56,7 +70,7 @@ Objects_Control *_Objects_Allocate( if ( !the_object ) { _Objects_Extend_information( information ); - the_object = (Objects_Control *) _Chain_Get( &information->Inactive ); + the_object = _Objects_Get_inactive( information ); } if ( the_object ) { @@ -83,3 +97,10 @@ Objects_Control *_Objects_Allocate( return the_object; } + +Objects_Control *_Objects_Allocate( Objects_Information *information ) +{ + _RTEMS_Lock_allocator(); + + return _Objects_Allocate_unprotected( information ); +} -- cgit v1.2.3