summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/objectallocate.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-03-27 14:16:12 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-03-31 08:29:44 +0200
commit23fec9f0e18dc4913fab818118f836af150b98f3 (patch)
tree66228f23bbf654117a33e28db7a017eea21fb785 /cpukit/score/src/objectallocate.c
parentscore: Use thread life protection for API mutexes (diff)
downloadrtems-23fec9f0e18dc4913fab818118f836af150b98f3.tar.bz2
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.
Diffstat (limited to 'cpukit/score/src/objectallocate.c')
-rw-r--r--cpukit/score/src/objectallocate.c27
1 files changed, 24 insertions, 3 deletions
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 <rtems/score/objectimpl.h>
+#include <rtems/score/assert.h>
#include <rtems/score/chainimpl.h>
+#include <rtems/score/sysstate.h>
/* #define RTEMS_DEBUG_OBJECT_ALLOCATION */
@@ -27,12 +29,24 @@
#include <rtems/bspIo.h>
#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 );
+}