summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-04-30 13:12:54 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2015-05-19 12:00:46 +0200
commitcc18d7bec7b3c5515cb9e6cd9771d4b94309b3bd (patch)
tree59fd8c8ca70830762e632e255a2078f22ac6a821 /cpukit/rtems
parentscore: Delete _CORE_message_queue_Flush_support() (diff)
downloadrtems-cc18d7bec7b3c5515cb9e6cd9771d4b94309b3bd.tar.bz2
score: Fine grained locking for message queues
Aggregate several critical sections into a bigger one. Sending and receiving messages is now protected by an ISR lock. Thread dispatching is only disabled in case a blocking operation is necessary. The message copy procedure is done inside the critical section (interrupts disabled). Thus this change may have a negative impact on the interrupt latency in case very large messages are transferred. Update #2273.
Diffstat (limited to 'cpukit/rtems')
-rw-r--r--cpukit/rtems/include/rtems/rtems/messageimpl.h15
-rw-r--r--cpukit/rtems/src/msgqbroadcast.c12
-rw-r--r--cpukit/rtems/src/msgqflush.c13
-rw-r--r--cpukit/rtems/src/msgqreceive.c11
-rw-r--r--cpukit/rtems/src/msgqsend.c12
-rw-r--r--cpukit/rtems/src/msgqurgent.c11
6 files changed, 57 insertions, 17 deletions
diff --git a/cpukit/rtems/include/rtems/rtems/messageimpl.h b/cpukit/rtems/include/rtems/rtems/messageimpl.h
index fa9e573892..2399d65f29 100644
--- a/cpukit/rtems/include/rtems/rtems/messageimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/messageimpl.h
@@ -139,6 +139,21 @@ RTEMS_INLINE_ROUTINE Message_queue_Control *_Message_queue_Get (
_Objects_Get( &_Message_queue_Information, id, location );
}
+RTEMS_INLINE_ROUTINE Message_queue_Control *
+_Message_queue_Get_interrupt_disable(
+ Objects_Id id,
+ Objects_Locations *location,
+ ISR_lock_Context *lock_context
+)
+{
+ return (Message_queue_Control *) _Objects_Get_isr_disable(
+ &_Message_queue_Information,
+ id,
+ location,
+ lock_context
+ );
+}
+
RTEMS_INLINE_ROUTINE Message_queue_Control *_Message_queue_Allocate( void )
{
return (Message_queue_Control *)
diff --git a/cpukit/rtems/src/msgqbroadcast.c b/cpukit/rtems/src/msgqbroadcast.c
index 64ea80e3de..aabbf3f6ac 100644
--- a/cpukit/rtems/src/msgqbroadcast.c
+++ b/cpukit/rtems/src/msgqbroadcast.c
@@ -40,6 +40,7 @@ rtems_status_code rtems_message_queue_broadcast(
Message_queue_Control *the_message_queue;
Objects_Locations location;
CORE_message_queue_Status core_status;
+ ISR_lock_Context lock_context;
if ( !buffer )
return RTEMS_INVALID_ADDRESS;
@@ -47,7 +48,11 @@ rtems_status_code rtems_message_queue_broadcast(
if ( !count )
return RTEMS_INVALID_ADDRESS;
- the_message_queue = _Message_queue_Get( id, &location );
+ the_message_queue = _Message_queue_Get_interrupt_disable(
+ id,
+ &location,
+ &lock_context
+ );
switch ( location ) {
case OBJECTS_LOCAL:
@@ -61,10 +66,9 @@ rtems_status_code rtems_message_queue_broadcast(
#else
NULL,
#endif
- count
+ count,
+ &lock_context
);
-
- _Objects_Put( &the_message_queue->Object );
return
_Message_queue_Translate_core_message_queue_return_code( core_status );
diff --git a/cpukit/rtems/src/msgqflush.c b/cpukit/rtems/src/msgqflush.c
index 7ae7ef4544..809c243b52 100644
--- a/cpukit/rtems/src/msgqflush.c
+++ b/cpukit/rtems/src/msgqflush.c
@@ -54,16 +54,23 @@ rtems_status_code rtems_message_queue_flush(
{
Message_queue_Control *the_message_queue;
Objects_Locations location;
+ ISR_lock_Context lock_context;
if ( !count )
return RTEMS_INVALID_ADDRESS;
- the_message_queue = _Message_queue_Get( id, &location );
+ the_message_queue = _Message_queue_Get_interrupt_disable(
+ id,
+ &location,
+ &lock_context
+ );
switch ( location ) {
case OBJECTS_LOCAL:
- *count = _CORE_message_queue_Flush( &the_message_queue->message_queue );
- _Objects_Put( &the_message_queue->Object );
+ *count = _CORE_message_queue_Flush(
+ &the_message_queue->message_queue,
+ &lock_context
+ );
return RTEMS_SUCCESSFUL;
#if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/msgqreceive.c b/cpukit/rtems/src/msgqreceive.c
index db09cfe547..2b9a4e742b 100644
--- a/cpukit/rtems/src/msgqreceive.c
+++ b/cpukit/rtems/src/msgqreceive.c
@@ -42,6 +42,7 @@ rtems_status_code rtems_message_queue_receive(
Objects_Locations location;
bool wait;
Thread_Control *executing;
+ ISR_lock_Context lock_context;
if ( !buffer )
return RTEMS_INVALID_ADDRESS;
@@ -49,7 +50,11 @@ rtems_status_code rtems_message_queue_receive(
if ( !size )
return RTEMS_INVALID_ADDRESS;
- the_message_queue = _Message_queue_Get( id, &location );
+ the_message_queue = _Message_queue_Get_interrupt_disable(
+ id,
+ &location,
+ &lock_context
+ );
switch ( location ) {
case OBJECTS_LOCAL:
@@ -66,9 +71,9 @@ rtems_status_code rtems_message_queue_receive(
buffer,
size,
wait,
- timeout
+ timeout,
+ &lock_context
);
- _Objects_Put( &the_message_queue->Object );
return _Message_queue_Translate_core_message_queue_return_code(
executing->Wait.return_code
);
diff --git a/cpukit/rtems/src/msgqsend.c b/cpukit/rtems/src/msgqsend.c
index 34b7c29e7c..fb3979ed78 100644
--- a/cpukit/rtems/src/msgqsend.c
+++ b/cpukit/rtems/src/msgqsend.c
@@ -62,11 +62,16 @@ rtems_status_code rtems_message_queue_send(
Message_queue_Control *the_message_queue;
Objects_Locations location;
CORE_message_queue_Status status;
+ ISR_lock_Context lock_context;
if ( !buffer )
return RTEMS_INVALID_ADDRESS;
- the_message_queue = _Message_queue_Get( id, &location );
+ the_message_queue = _Message_queue_Get_interrupt_disable(
+ id,
+ &location,
+ &lock_context
+ );
switch ( location ) {
case OBJECTS_LOCAL:
@@ -77,11 +82,10 @@ rtems_status_code rtems_message_queue_send(
id,
MESSAGE_QUEUE_MP_HANDLER,
false, /* sender does not block */
- 0 /* no timeout */
+ 0, /* no timeout */
+ &lock_context
);
- _Objects_Put( &the_message_queue->Object );
-
/*
* Since this API does not allow for blocking sends, we can directly
* return the returned status.
diff --git a/cpukit/rtems/src/msgqurgent.c b/cpukit/rtems/src/msgqurgent.c
index 85a9d4f1b4..e6ae5efcf0 100644
--- a/cpukit/rtems/src/msgqurgent.c
+++ b/cpukit/rtems/src/msgqurgent.c
@@ -45,11 +45,16 @@ rtems_status_code rtems_message_queue_urgent(
Message_queue_Control *the_message_queue;
Objects_Locations location;
CORE_message_queue_Status status;
+ ISR_lock_Context lock_context;
if ( !buffer )
return RTEMS_INVALID_ADDRESS;
- the_message_queue = _Message_queue_Get( id, &location );
+ the_message_queue = _Message_queue_Get_interrupt_disable(
+ id,
+ &location,
+ &lock_context
+ );
switch ( location ) {
case OBJECTS_LOCAL:
@@ -60,9 +65,9 @@ rtems_status_code rtems_message_queue_urgent(
id,
MESSAGE_QUEUE_MP_HANDLER,
false, /* sender does not block */
- 0 /* no timeout */
+ 0, /* no timeout */
+ &lock_context
);
- _Objects_Put( &the_message_queue->Object );
/*
* Since this API does not allow for blocking sends, we can directly