diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2000-01-13 19:25:15 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2000-01-13 19:25:15 +0000 |
commit | 53fb837afc4285486e318bcb614c911bbe9b1348 (patch) | |
tree | cdd9b6ff2a66e8f5c746a06d1e639be4c01c6941 /cpukit/score/src/coremsgbroadcast.c | |
parent | Missed removing this file in an earlier commit. This is removed (diff) | |
download | rtems-53fb837afc4285486e318bcb614c911bbe9b1348.tar.bz2 |
POSIX message queues now include complete functionality including
blocking sends when the queue is full. The SuperCore was enhanced
to support blocking on send. The existing POSIX API was debugged
and numerous test cases were added to psxmsgq01 by Jennifer Averett.
SuperCore enhancements and resulting modifications to other APIs
were done by Joel.
There is one significant point of interpretation for the POSIX API.
What happens to threads already blocked on a message queue when the
mode of that same message queue is changed from blocking to non-blocking?
We decided to unblock all waiting tasks with an EAGAIN error just
as if a non-blocking version of the same operation had returned
unsatisfied. This case is not discussed in the POSIX standard and
other implementations may have chosen differently.
Diffstat (limited to 'cpukit/score/src/coremsgbroadcast.c')
-rw-r--r-- | cpukit/score/src/coremsgbroadcast.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/cpukit/score/src/coremsgbroadcast.c b/cpukit/score/src/coremsgbroadcast.c index 2e6f649545..18e148ab1c 100644 --- a/cpukit/score/src/coremsgbroadcast.c +++ b/cpukit/score/src/coremsgbroadcast.c @@ -64,6 +64,25 @@ CORE_message_queue_Status _CORE_message_queue_Broadcast( Thread_Wait_information *waitp; unsigned32 constrained_size; + /* + * If there are pending messages, then there can't be threads + * waiting for us to send them a message. + * + * NOTE: This check is critical because threads can block on + * send and receive and this ensures that we are broadcasting + * the message to threads waiting to receive -- not to send. + */ + + if ( the_message_queue->number_of_pending_messages != 0 ) { + *count = 0; + return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL; + } + + /* + * There must be no pending messages if there is a thread waiting to + * receive a message. + */ + number_broadcasted = 0; while ((the_thread = _Thread_queue_Dequeue(&the_message_queue->Wait_queue))) { waitp = &the_thread->Wait; |