summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems
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/rtems
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/rtems')
-rw-r--r--cpukit/rtems/Makefile.am1
-rw-r--r--cpukit/rtems/include/rtems/rtems/messageimpl.h16
-rw-r--r--cpukit/rtems/include/rtems/rtems/tasksimpl.h13
-rw-r--r--cpukit/rtems/src/barriercreate.c6
-rw-r--r--cpukit/rtems/src/barrierdelete.c8
-rw-r--r--cpukit/rtems/src/dpmemcreate.c8
-rw-r--r--cpukit/rtems/src/dpmemdelete.c6
-rw-r--r--cpukit/rtems/src/msgqallocate.c37
-rw-r--r--cpukit/rtems/src/msgqcreate.c10
-rw-r--r--cpukit/rtems/src/msgqdelete.c9
-rw-r--r--cpukit/rtems/src/partcreate.c10
-rw-r--r--cpukit/rtems/src/partdelete.c9
-rw-r--r--cpukit/rtems/src/ratemoncreate.c8
-rw-r--r--cpukit/rtems/src/ratemondelete.c6
-rw-r--r--cpukit/rtems/src/regioncreate.c7
-rw-r--r--cpukit/rtems/src/regiondelete.c5
-rw-r--r--cpukit/rtems/src/regionextend.c3
-rw-r--r--cpukit/rtems/src/regiongetsegment.c3
-rw-r--r--cpukit/rtems/src/regionresizesegment.c3
-rw-r--r--cpukit/rtems/src/semcreate.c12
-rw-r--r--cpukit/rtems/src/semdelete.c11
-rw-r--r--cpukit/rtems/src/taskcreate.c13
-rw-r--r--cpukit/rtems/src/timercreate.c6
-rw-r--r--cpukit/rtems/src/timerdelete.c6
24 files changed, 91 insertions, 125 deletions
diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am
index f89a896f2d..cf8ca3bb67 100644
--- a/cpukit/rtems/Makefile.am
+++ b/cpukit/rtems/Makefile.am
@@ -175,7 +175,6 @@ librtems_a_SOURCES += src/rtemstimerdata.c
## MESSAGE_QUEUE_C_FILES
librtems_a_SOURCES += src/msg.c
-librtems_a_SOURCES += src/msgqallocate.c
librtems_a_SOURCES += src/msgqbroadcast.c
librtems_a_SOURCES += src/msgqcreate.c
librtems_a_SOURCES += src/msgqdelete.c
diff --git a/cpukit/rtems/include/rtems/rtems/messageimpl.h b/cpukit/rtems/include/rtems/rtems/messageimpl.h
index da87fd1d6f..714fb617dc 100644
--- a/cpukit/rtems/include/rtems/rtems/messageimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/messageimpl.h
@@ -90,16 +90,6 @@ rtems_status_code _Message_queue_Submit(
);
/**
- * @brief Message Queue Allocate
- *
- * This function allocates a message queue control block from
- * the inactive chain of free message queue control blocks.
- *
- * @retval the_message_queue filled in if successful, NULL otherwise
- */
-Message_queue_Control *_Message_queue_Allocate (void);
-
-/**
* @brief Message queue Translate Core Message Queue Return Code
*
* This function returns a RTEMS status code based on
@@ -162,6 +152,12 @@ RTEMS_INLINE_ROUTINE Message_queue_Control *_Message_queue_Get (
_Objects_Get( &_Message_queue_Information, id, location );
}
+RTEMS_INLINE_ROUTINE Message_queue_Control *_Message_queue_Allocate( void )
+{
+ return (Message_queue_Control *)
+ _Objects_Allocate( &_Message_queue_Information );
+}
+
/**@}*/
#ifdef __cplusplus
diff --git a/cpukit/rtems/include/rtems/rtems/tasksimpl.h b/cpukit/rtems/include/rtems/rtems/tasksimpl.h
index 2a99812e26..c86d5914c2 100644
--- a/cpukit/rtems/include/rtems/rtems/tasksimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/tasksimpl.h
@@ -77,17 +77,14 @@ void _RTEMS_Tasks_Invoke_task_variable_dtor(
rtems_task_variable_t *tvp
);
-/**
- * @brief Allocates a task control block.
- *
- * This function allocates a task control block from
- * the inactive chain of free task control blocks.
- */
-RTEMS_INLINE_ROUTINE Thread_Control *_RTEMS_tasks_Allocate( void )
+RTEMS_INLINE_ROUTINE Thread_Control *_RTEMS_tasks_Allocate(void)
{
+ _Objects_Allocator_lock();
+
_Thread_Kill_zombies();
- return (Thread_Control *) _Objects_Allocate( &_RTEMS_tasks_Information );
+ return (Thread_Control *)
+ _Objects_Allocate_unprotected( &_RTEMS_tasks_Information );
}
/**
diff --git a/cpukit/rtems/src/barriercreate.c b/cpukit/rtems/src/barriercreate.c
index e865774b17..12a917fe60 100644
--- a/cpukit/rtems/src/barriercreate.c
+++ b/cpukit/rtems/src/barriercreate.c
@@ -68,12 +68,10 @@ rtems_status_code rtems_barrier_create(
the_attributes.discipline = CORE_BARRIER_MANUAL_RELEASE;
the_attributes.maximum_count = maximum_waiters;
- _Thread_Disable_dispatch(); /* prevents deletion */
-
the_barrier = _Barrier_Allocate();
if ( !the_barrier ) {
- _Thread_Enable_dispatch();
+ _Objects_Allocator_unlock();
return RTEMS_TOO_MANY;
}
@@ -89,6 +87,6 @@ rtems_status_code rtems_barrier_create(
*id = the_barrier->Object.id;
- _Thread_Enable_dispatch();
+ _Objects_Allocator_unlock();
return RTEMS_SUCCESSFUL;
}
diff --git a/cpukit/rtems/src/barrierdelete.c b/cpukit/rtems/src/barrierdelete.c
index 90fff5e8ef..2ea15502b3 100644
--- a/cpukit/rtems/src/barrierdelete.c
+++ b/cpukit/rtems/src/barrierdelete.c
@@ -28,6 +28,7 @@ rtems_status_code rtems_barrier_delete(
Barrier_Control *the_barrier;
Objects_Locations location;
+ _Objects_Allocator_lock();
the_barrier = _Barrier_Get( id, &location );
switch ( location ) {
@@ -39,10 +40,9 @@ rtems_status_code rtems_barrier_delete(
);
_Objects_Close( &_Barrier_Information, &the_barrier->Object );
-
- _Barrier_Free( the_barrier );
-
_Objects_Put( &the_barrier->Object );
+ _Barrier_Free( the_barrier );
+ _Objects_Allocator_unlock();
return RTEMS_SUCCESSFUL;
#if defined(RTEMS_MULTIPROCESSING)
@@ -52,5 +52,7 @@ rtems_status_code rtems_barrier_delete(
break;
}
+ _Objects_Allocator_unlock();
+
return RTEMS_INVALID_ID;
}
diff --git a/cpukit/rtems/src/dpmemcreate.c b/cpukit/rtems/src/dpmemcreate.c
index 9ad1588a10..206a199c00 100644
--- a/cpukit/rtems/src/dpmemcreate.c
+++ b/cpukit/rtems/src/dpmemcreate.c
@@ -33,7 +33,7 @@ rtems_status_code rtems_port_create(
rtems_id *id
)
{
- Dual_ported_memory_Control *the_port;
+ Dual_ported_memory_Control *the_port;
if ( !rtems_is_name_valid( name ) )
return RTEMS_INVALID_NAME;
@@ -45,12 +45,10 @@ rtems_status_code rtems_port_create(
!_Addresses_Is_aligned( external_start ) )
return RTEMS_INVALID_ADDRESS;
- _Thread_Disable_dispatch(); /* to prevent deletion */
-
the_port = _Dual_ported_memory_Allocate();
if ( !the_port ) {
- _Thread_Enable_dispatch();
+ _Objects_Allocator_unlock();
return RTEMS_TOO_MANY;
}
@@ -65,6 +63,6 @@ rtems_status_code rtems_port_create(
);
*id = the_port->Object.id;
- _Thread_Enable_dispatch();
+ _Objects_Allocator_unlock();
return RTEMS_SUCCESSFUL;
}
diff --git a/cpukit/rtems/src/dpmemdelete.c b/cpukit/rtems/src/dpmemdelete.c
index d6b42ffcc0..6f11a53a0b 100644
--- a/cpukit/rtems/src/dpmemdelete.c
+++ b/cpukit/rtems/src/dpmemdelete.c
@@ -32,13 +32,15 @@ rtems_status_code rtems_port_delete(
Dual_ported_memory_Control *the_port;
Objects_Locations location;
+ _Objects_Allocator_lock();
the_port = _Dual_ported_memory_Get( id, &location );
switch ( location ) {
case OBJECTS_LOCAL:
_Objects_Close( &_Dual_ported_memory_Information, &the_port->Object );
- _Dual_ported_memory_Free( the_port );
_Objects_Put( &the_port->Object );
+ _Dual_ported_memory_Free( the_port );
+ _Objects_Allocator_unlock();
return RTEMS_SUCCESSFUL;
#if defined(RTEMS_MULTIPROCESSING)
@@ -48,5 +50,7 @@ rtems_status_code rtems_port_delete(
break;
}
+ _Objects_Allocator_unlock();
+
return RTEMS_INVALID_ID;
}
diff --git a/cpukit/rtems/src/msgqallocate.c b/cpukit/rtems/src/msgqallocate.c
deleted file mode 100644
index f5776f1687..0000000000
--- a/cpukit/rtems/src/msgqallocate.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * @file
- *
- * @brief Message Queue Allocate
- * @ingroup ClassicMessageQueue
- */
-
-/*
- * COPYRIGHT (c) 1989-1999.
- * 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/system.h>
-#include <rtems/score/chain.h>
-#include <rtems/score/isr.h>
-#include <rtems/score/coremsgimpl.h>
-#include <rtems/score/thread.h>
-#include <rtems/score/wkspace.h>
-#include <rtems/rtems/status.h>
-#include <rtems/rtems/attrimpl.h>
-#include <rtems/rtems/messageimpl.h>
-#include <rtems/rtems/options.h>
-#include <rtems/rtems/support.h>
-
-Message_queue_Control *_Message_queue_Allocate(void)
-{
- return (Message_queue_Control *)
- _Objects_Allocate(&_Message_queue_Information);
-}
diff --git a/cpukit/rtems/src/msgqcreate.c b/cpukit/rtems/src/msgqcreate.c
index 6f60773458..b18f3b2591 100644
--- a/cpukit/rtems/src/msgqcreate.c
+++ b/cpukit/rtems/src/msgqcreate.c
@@ -81,12 +81,10 @@ rtems_status_code rtems_message_queue_create(
#endif
#endif
- _Thread_Disable_dispatch(); /* protects object pointer */
-
the_message_queue = _Message_queue_Allocate();
if ( !the_message_queue ) {
- _Thread_Enable_dispatch();
+ _Objects_Allocator_unlock();
return RTEMS_TOO_MANY;
}
@@ -95,7 +93,7 @@ rtems_status_code rtems_message_queue_create(
!( _Objects_MP_Allocate_and_open( &_Message_queue_Information,
name, the_message_queue->Object.id, false ) ) ) {
_Message_queue_Free( the_message_queue );
- _Thread_Enable_dispatch();
+ _Objects_Allocator_unlock();
return RTEMS_TOO_MANY;
}
#endif
@@ -120,7 +118,7 @@ rtems_status_code rtems_message_queue_create(
#endif
_Message_queue_Free( the_message_queue );
- _Thread_Enable_dispatch();
+ _Objects_Allocator_unlock();
return RTEMS_UNSATISFIED;
}
@@ -142,6 +140,6 @@ rtems_status_code rtems_message_queue_create(
);
#endif
- _Thread_Enable_dispatch();
+ _Objects_Allocator_unlock();
return RTEMS_SUCCESSFUL;
}
diff --git a/cpukit/rtems/src/msgqdelete.c b/cpukit/rtems/src/msgqdelete.c
index d3c07679f4..e2df2b9d9a 100644
--- a/cpukit/rtems/src/msgqdelete.c
+++ b/cpukit/rtems/src/msgqdelete.c
@@ -37,6 +37,7 @@ rtems_status_code rtems_message_queue_delete(
Message_queue_Control *the_message_queue;
Objects_Locations location;
+ _Objects_Allocator_lock();
the_message_queue = _Message_queue_Get( id, &location );
switch ( location ) {
@@ -54,8 +55,6 @@ rtems_status_code rtems_message_queue_delete(
CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED
);
- _Message_queue_Free( the_message_queue );
-
#if defined(RTEMS_MULTIPROCESSING)
if ( _Attributes_Is_global( the_message_queue->attribute_set ) ) {
_Objects_MP_Close(
@@ -72,11 +71,13 @@ rtems_status_code rtems_message_queue_delete(
}
#endif
_Objects_Put( &the_message_queue->Object );
+ _Message_queue_Free( the_message_queue );
+ _Objects_Allocator_unlock();
return RTEMS_SUCCESSFUL;
#if defined(RTEMS_MULTIPROCESSING)
case OBJECTS_REMOTE:
- _Thread_Dispatch();
+ _Objects_Allocator_unlock();
return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
#endif
@@ -84,5 +85,7 @@ rtems_status_code rtems_message_queue_delete(
break;
}
+ _Objects_Allocator_unlock();
+
return RTEMS_INVALID_ID;
}
diff --git a/cpukit/rtems/src/partcreate.c b/cpukit/rtems/src/partcreate.c
index 32758f8f65..e3544e71b2 100644
--- a/cpukit/rtems/src/partcreate.c
+++ b/cpukit/rtems/src/partcreate.c
@@ -53,7 +53,7 @@ rtems_status_code rtems_partition_create(
rtems_id *id
)
{
- Partition_Control *the_partition;
+ Partition_Control *the_partition;
if ( !rtems_is_name_valid( name ) )
return RTEMS_INVALID_NAME;
@@ -77,12 +77,10 @@ rtems_status_code rtems_partition_create(
return RTEMS_MP_NOT_CONFIGURED;
#endif
- _Thread_Disable_dispatch(); /* prevents deletion */
-
the_partition = _Partition_Allocate();
if ( !the_partition ) {
- _Thread_Enable_dispatch();
+ _Objects_Allocator_unlock();
return RTEMS_TOO_MANY;
}
@@ -91,7 +89,7 @@ rtems_status_code rtems_partition_create(
!( _Objects_MP_Allocate_and_open( &_Partition_Information, name,
the_partition->Object.id, false ) ) ) {
_Partition_Free( the_partition );
- _Thread_Enable_dispatch();
+ _Objects_Allocator_unlock();
return RTEMS_TOO_MANY;
}
#endif
@@ -122,6 +120,6 @@ rtems_status_code rtems_partition_create(
);
#endif
- _Thread_Enable_dispatch();
+ _Objects_Allocator_unlock();
return RTEMS_SUCCESSFUL;
}
diff --git a/cpukit/rtems/src/partdelete.c b/cpukit/rtems/src/partdelete.c
index cc10abcded..032f73d3d0 100644
--- a/cpukit/rtems/src/partdelete.c
+++ b/cpukit/rtems/src/partdelete.c
@@ -29,13 +29,13 @@ rtems_status_code rtems_partition_delete(
Partition_Control *the_partition;
Objects_Locations location;
+ _Objects_Allocator_lock();
the_partition = _Partition_Get( id, &location );
switch ( location ) {
case OBJECTS_LOCAL:
if ( the_partition->number_of_used_blocks == 0 ) {
_Objects_Close( &_Partition_Information, &the_partition->Object );
- _Partition_Free( the_partition );
#if defined(RTEMS_MULTIPROCESSING)
if ( _Attributes_Is_global( the_partition->attribute_set ) ) {
@@ -54,14 +54,17 @@ rtems_status_code rtems_partition_delete(
#endif
_Objects_Put( &the_partition->Object );
+ _Partition_Free( the_partition );
+ _Objects_Allocator_unlock();
return RTEMS_SUCCESSFUL;
}
_Objects_Put( &the_partition->Object );
+ _Objects_Allocator_unlock();
return RTEMS_RESOURCE_IN_USE;
#if defined(RTEMS_MULTIPROCESSING)
case OBJECTS_REMOTE:
- _Thread_Dispatch();
+ _Objects_Allocator_unlock();
return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
#endif
@@ -69,5 +72,7 @@ rtems_status_code rtems_partition_delete(
break;
}
+ _Objects_Allocator_unlock();
+
return RTEMS_INVALID_ID;
}
diff --git a/cpukit/rtems/src/ratemoncreate.c b/cpukit/rtems/src/ratemoncreate.c
index ce0e1de26b..1f597ec944 100644
--- a/cpukit/rtems/src/ratemoncreate.c
+++ b/cpukit/rtems/src/ratemoncreate.c
@@ -55,16 +55,14 @@ rtems_status_code rtems_rate_monotonic_create(
if ( !id )
return RTEMS_INVALID_ADDRESS;
- _Thread_Disable_dispatch(); /* to prevent deletion */
-
the_period = _Rate_monotonic_Allocate();
if ( !the_period ) {
- _Thread_Enable_dispatch();
+ _Objects_Allocator_unlock();
return RTEMS_TOO_MANY;
}
- the_period->owner = _Thread_Executing;
+ the_period->owner = _Thread_Get_executing();
the_period->state = RATE_MONOTONIC_INACTIVE;
_Watchdog_Initialize( &the_period->Timer, NULL, 0, NULL );
@@ -78,6 +76,6 @@ rtems_status_code rtems_rate_monotonic_create(
);
*id = the_period->Object.id;
- _Thread_Enable_dispatch();
+ _Objects_Allocator_unlock();
return RTEMS_SUCCESSFUL;
}
diff --git a/cpukit/rtems/src/ratemondelete.c b/cpukit/rtems/src/ratemondelete.c
index 0a9e6a49e2..36480beab1 100644
--- a/cpukit/rtems/src/ratemondelete.c
+++ b/cpukit/rtems/src/ratemondelete.c
@@ -30,6 +30,7 @@ rtems_status_code rtems_rate_monotonic_delete(
Rate_monotonic_Control *the_period;
Objects_Locations location;
+ _Objects_Allocator_lock();
the_period = _Rate_monotonic_Get( id, &location );
switch ( location ) {
@@ -38,8 +39,9 @@ rtems_status_code rtems_rate_monotonic_delete(
_Objects_Close( &_Rate_monotonic_Information, &the_period->Object );
(void) _Watchdog_Remove( &the_period->Timer );
the_period->state = RATE_MONOTONIC_INACTIVE;
- _Rate_monotonic_Free( the_period );
_Objects_Put( &the_period->Object );
+ _Rate_monotonic_Free( the_period );
+ _Objects_Allocator_unlock();
return RTEMS_SUCCESSFUL;
#if defined(RTEMS_MULTIPROCESSING)
@@ -49,5 +51,7 @@ rtems_status_code rtems_rate_monotonic_delete(
break;
}
+ _Objects_Allocator_unlock();
+
return RTEMS_INVALID_ID;
}
diff --git a/cpukit/rtems/src/regioncreate.c b/cpukit/rtems/src/regioncreate.c
index 3b4325e436..6c623c8250 100644
--- a/cpukit/rtems/src/regioncreate.c
+++ b/cpukit/rtems/src/regioncreate.c
@@ -66,9 +66,7 @@ rtems_status_code rtems_region_create(
if ( !id )
return RTEMS_INVALID_ADDRESS;
- _RTEMS_Lock_allocator(); /* to prevent deletion */
-
- the_region = _Region_Allocate();
+ the_region = _Region_Allocate();
if ( !the_region )
return_status = RTEMS_TOO_MANY;
@@ -111,6 +109,7 @@ rtems_status_code rtems_region_create(
}
}
- _RTEMS_Unlock_allocator();
+ _Objects_Allocator_unlock();
+
return return_status;
}
diff --git a/cpukit/rtems/src/regiondelete.c b/cpukit/rtems/src/regiondelete.c
index 5144db0464..5a2df7c009 100644
--- a/cpukit/rtems/src/regiondelete.c
+++ b/cpukit/rtems/src/regiondelete.c
@@ -34,7 +34,7 @@ rtems_status_code rtems_region_delete(
rtems_status_code return_status;
Region_Control *the_region;
- _RTEMS_Lock_allocator();
+ _Objects_Allocator_lock();
the_region = _Region_Get( id, &location );
switch ( location ) {
@@ -61,6 +61,7 @@ rtems_status_code rtems_region_delete(
break;
}
- _RTEMS_Unlock_allocator();
+ _Objects_Allocator_unlock();
+
return return_status;
}
diff --git a/cpukit/rtems/src/regionextend.c b/cpukit/rtems/src/regionextend.c
index 289377db91..65b68cdf1a 100644
--- a/cpukit/rtems/src/regionextend.c
+++ b/cpukit/rtems/src/regionextend.c
@@ -40,7 +40,7 @@ rtems_status_code rtems_region_extend(
if ( !starting_address )
return RTEMS_INVALID_ADDRESS;
- _RTEMS_Lock_allocator(); /* to prevent deletion */
+ _RTEMS_Lock_allocator(); /* to prevent deletion */
the_region = _Region_Get( id, &location );
switch ( location ) {
@@ -75,5 +75,6 @@ rtems_status_code rtems_region_extend(
}
_RTEMS_Unlock_allocator();
+
return return_status;
}
diff --git a/cpukit/rtems/src/regiongetsegment.c b/cpukit/rtems/src/regiongetsegment.c
index 92b3a94b6d..4bd244551a 100644
--- a/cpukit/rtems/src/regiongetsegment.c
+++ b/cpukit/rtems/src/regiongetsegment.c
@@ -47,7 +47,7 @@ rtems_status_code rtems_region_get_segment(
_RTEMS_Lock_allocator();
- executing = _Thread_Executing;
+ executing = _Thread_Get_executing();
the_region = _Region_Get( id, &location );
switch ( location ) {
@@ -110,5 +110,6 @@ rtems_status_code rtems_region_get_segment(
}
_RTEMS_Unlock_allocator();
+
return return_status;
}
diff --git a/cpukit/rtems/src/regionresizesegment.c b/cpukit/rtems/src/regionresizesegment.c
index ff45215118..ee3499a729 100644
--- a/cpukit/rtems/src/regionresizesegment.c
+++ b/cpukit/rtems/src/regionresizesegment.c
@@ -64,7 +64,8 @@ rtems_status_code rtems_region_resize_segment(
_Region_Debug_Walk( the_region, 8 );
if ( status == HEAP_RESIZE_SUCCESSFUL )
- _Region_Process_queue( the_region ); /* unlocks allocator */
+ /* unlocks allocator */
+ _Region_Process_queue( the_region );
else
_RTEMS_Unlock_allocator();
diff --git a/cpukit/rtems/src/semcreate.c b/cpukit/rtems/src/semcreate.c
index bf9229e2ee..5cd9568a46 100644
--- a/cpukit/rtems/src/semcreate.c
+++ b/cpukit/rtems/src/semcreate.c
@@ -100,12 +100,10 @@ rtems_status_code rtems_semaphore_create(
if ( !_Attributes_Is_counting_semaphore( attribute_set ) && ( count > 1 ) )
return RTEMS_INVALID_NUMBER;
- _Thread_Disable_dispatch(); /* prevents deletion */
-
the_semaphore = _Semaphore_Allocate();
if ( !the_semaphore ) {
- _Thread_Enable_dispatch();
+ _Objects_Allocator_unlock();
return RTEMS_TOO_MANY;
}
@@ -114,7 +112,7 @@ rtems_status_code rtems_semaphore_create(
! ( _Objects_MP_Allocate_and_open( &_Semaphore_Information, name,
the_semaphore->Object.id, false ) ) ) {
_Semaphore_Free( the_semaphore );
- _Thread_Enable_dispatch();
+ _Objects_Allocator_unlock();
return RTEMS_TOO_MANY;
}
#endif
@@ -179,14 +177,14 @@ rtems_status_code rtems_semaphore_create(
mutex_status = _CORE_mutex_Initialize(
&the_semaphore->Core_control.mutex,
- _Thread_Executing,
+ _Thread_Get_executing(),
&the_mutex_attr,
(count == 1) ? CORE_MUTEX_UNLOCKED : CORE_MUTEX_LOCKED
);
if ( mutex_status == CORE_MUTEX_STATUS_CEILING_VIOLATED ) {
_Semaphore_Free( the_semaphore );
- _Thread_Enable_dispatch();
+ _Objects_Allocator_unlock();
return RTEMS_INVALID_PRIORITY;
}
}
@@ -212,6 +210,6 @@ rtems_status_code rtems_semaphore_create(
0 /* Not used */
);
#endif
- _Thread_Enable_dispatch();
+ _Objects_Allocator_unlock();
return RTEMS_SUCCESSFUL;
}
diff --git a/cpukit/rtems/src/semdelete.c b/cpukit/rtems/src/semdelete.c
index ea82b7757d..6e7c5eafad 100644
--- a/cpukit/rtems/src/semdelete.c
+++ b/cpukit/rtems/src/semdelete.c
@@ -44,6 +44,8 @@ rtems_status_code rtems_semaphore_delete(
Semaphore_Control *the_semaphore;
Objects_Locations location;
+ _Objects_Allocator_lock();
+
the_semaphore = _Semaphore_Get( id, &location );
switch ( location ) {
@@ -53,6 +55,7 @@ rtems_status_code rtems_semaphore_delete(
!_Attributes_Is_simple_binary_semaphore(
the_semaphore->attribute_set ) ) {
_Objects_Put( &the_semaphore->Object );
+ _Objects_Allocator_unlock();
return RTEMS_RESOURCE_IN_USE;
}
_CORE_mutex_Flush(
@@ -70,8 +73,6 @@ rtems_status_code rtems_semaphore_delete(
_Objects_Close( &_Semaphore_Information, &the_semaphore->Object );
- _Semaphore_Free( the_semaphore );
-
#if defined(RTEMS_MULTIPROCESSING)
if ( _Attributes_Is_global( the_semaphore->attribute_set ) ) {
@@ -85,12 +86,15 @@ rtems_status_code rtems_semaphore_delete(
);
}
#endif
+
_Objects_Put( &the_semaphore->Object );
+ _Semaphore_Free( the_semaphore );
+ _Objects_Allocator_unlock();
return RTEMS_SUCCESSFUL;
#if defined(RTEMS_MULTIPROCESSING)
case OBJECTS_REMOTE:
- _Thread_Dispatch();
+ _Objects_Allocator_unlock();
return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
#endif
@@ -98,5 +102,6 @@ rtems_status_code rtems_semaphore_delete(
break;
}
+ _Objects_Allocator_unlock();
return RTEMS_INVALID_ID;
}
diff --git a/cpukit/rtems/src/taskcreate.c b/cpukit/rtems/src/taskcreate.c
index ae4e1883e4..35dd37c4e5 100644
--- a/cpukit/rtems/src/taskcreate.c
+++ b/cpukit/rtems/src/taskcreate.c
@@ -105,11 +105,6 @@ rtems_status_code rtems_task_create(
*/
/*
- * Lock the allocator mutex for protection
- */
- _RTEMS_Lock_allocator();
-
- /*
* Allocate the thread control block and -- if the task is global --
* allocate a global object control block.
*
@@ -122,7 +117,7 @@ rtems_status_code rtems_task_create(
the_thread = _RTEMS_tasks_Allocate();
if ( !the_thread ) {
- _RTEMS_Unlock_allocator();
+ _Objects_Allocator_unlock();
return RTEMS_TOO_MANY;
}
@@ -132,7 +127,7 @@ rtems_status_code rtems_task_create(
if ( _Objects_MP_Is_null_global_object( the_global_object ) ) {
_RTEMS_tasks_Free( the_thread );
- _RTEMS_Unlock_allocator();
+ _Objects_Allocator_unlock();
return RTEMS_TOO_MANY;
}
}
@@ -164,7 +159,7 @@ rtems_status_code rtems_task_create(
_Objects_MP_Free_global_object( the_global_object );
#endif
_RTEMS_tasks_Free( the_thread );
- _RTEMS_Unlock_allocator();
+ _Objects_Allocator_unlock();
return RTEMS_UNSATISFIED;
}
@@ -195,6 +190,6 @@ rtems_status_code rtems_task_create(
}
#endif
- _RTEMS_Unlock_allocator();
+ _Objects_Allocator_unlock();
return RTEMS_SUCCESSFUL;
}
diff --git a/cpukit/rtems/src/timercreate.c b/cpukit/rtems/src/timercreate.c
index 35cdfab7fa..0b1c44bdc2 100644
--- a/cpukit/rtems/src/timercreate.c
+++ b/cpukit/rtems/src/timercreate.c
@@ -38,12 +38,10 @@ rtems_status_code rtems_timer_create(
if ( !id )
return RTEMS_INVALID_ADDRESS;
- _Thread_Disable_dispatch(); /* to prevent deletion */
-
the_timer = _Timer_Allocate();
if ( !the_timer ) {
- _Thread_Enable_dispatch();
+ _Objects_Allocator_unlock();
return RTEMS_TOO_MANY;
}
@@ -57,6 +55,6 @@ rtems_status_code rtems_timer_create(
);
*id = the_timer->Object.id;
- _Thread_Enable_dispatch();
+ _Objects_Allocator_unlock();
return RTEMS_SUCCESSFUL;
}
diff --git a/cpukit/rtems/src/timerdelete.c b/cpukit/rtems/src/timerdelete.c
index a3cf52a978..19232c8096 100644
--- a/cpukit/rtems/src/timerdelete.c
+++ b/cpukit/rtems/src/timerdelete.c
@@ -32,14 +32,16 @@ rtems_status_code rtems_timer_delete(
Timer_Control *the_timer;
Objects_Locations location;
+ _Objects_Allocator_lock();
the_timer = _Timer_Get( id, &location );
switch ( location ) {
case OBJECTS_LOCAL:
_Objects_Close( &_Timer_Information, &the_timer->Object );
(void) _Watchdog_Remove( &the_timer->Ticker );
- _Timer_Free( the_timer );
_Objects_Put( &the_timer->Object );
+ _Timer_Free( the_timer );
+ _Objects_Allocator_unlock();
return RTEMS_SUCCESSFUL;
#if defined(RTEMS_MULTIPROCESSING)
@@ -49,5 +51,7 @@ rtems_status_code rtems_timer_delete(
break;
}
+ _Objects_Allocator_unlock();
+
return RTEMS_INVALID_ID;
}