summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/partreturnbuffer.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-04-04 10:13:35 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-04-06 09:08:22 +0200
commit3570ec684f23dc57772856d1170d39252299a490 (patch)
tree9729d0ff751ec562e68a99dfb62e1f60de5e1f0c /cpukit/rtems/src/partreturnbuffer.c
parentscore: Use red-black tree for active global objects (diff)
downloadrtems-3570ec684f23dc57772856d1170d39252299a490.tar.bz2
rtems: Avoid Giant lock for partitions
Use an ISR lock to protect the partition state changes. Update #2555.
Diffstat (limited to 'cpukit/rtems/src/partreturnbuffer.c')
-rw-r--r--cpukit/rtems/src/partreturnbuffer.c34
1 files changed, 9 insertions, 25 deletions
diff --git a/cpukit/rtems/src/partreturnbuffer.c b/cpukit/rtems/src/partreturnbuffer.c
index 2cccc3c290..641abed572 100644
--- a/cpukit/rtems/src/partreturnbuffer.c
+++ b/cpukit/rtems/src/partreturnbuffer.c
@@ -14,47 +14,31 @@
#include "config.h"
#endif
-#include <rtems/system.h>
-#include <rtems/rtems/status.h>
-#include <rtems/rtems/support.h>
-#include <rtems/score/address.h>
#include <rtems/rtems/partimpl.h>
-#include <rtems/score/thread.h>
-
-/*
- * rtems_partition_return_buffer
- *
- * This directive will return the given buffer to the specified
- * buffer partition.
- *
- * Input parameters:
- * id - partition id
- * buffer - pointer to buffer address
- *
- * Output parameters:
- * RTEMS_SUCCESSFUL - if successful
- * error code - if unsuccessful
- */
rtems_status_code rtems_partition_return_buffer(
rtems_id id,
void *buffer
)
{
- Partition_Control *the_partition;
- Objects_Locations location;
+ Partition_Control *the_partition;
+ Objects_Locations location;
+ ISR_lock_Context lock_context;
- the_partition = _Partition_Get( id, &location );
+ the_partition = _Partition_Get( id, &location, &lock_context );
switch ( location ) {
case OBJECTS_LOCAL:
+ _Partition_Acquire_critical( the_partition, &lock_context );
+
if ( _Partition_Is_buffer_valid( buffer, the_partition ) ) {
_Partition_Free_buffer( the_partition, buffer );
the_partition->number_of_used_blocks -= 1;
- _Objects_Put( &the_partition->Object );
+ _Partition_Release( the_partition, &lock_context );
return RTEMS_SUCCESSFUL;
}
- _Objects_Put( &the_partition->Object );
+
+ _Partition_Release( the_partition, &lock_context );
return RTEMS_INVALID_ADDRESS;
#if defined(RTEMS_MULTIPROCESSING)