diff options
author | Jennifer Averett <Jennifer.Averett@OARcorp.com> | 2000-01-13 18:32:09 +0000 |
---|---|---|
committer | Jennifer Averett <Jennifer.Averett@OARcorp.com> | 2000-01-13 18:32:09 +0000 |
commit | d65c376845847ea7a697904b5222c39331bd56ec (patch) | |
tree | 46afa4a044cc79be21314657baad84bfda5ff235 /c | |
parent | Added comment. (diff) | |
download | rtems-d65c376845847ea7a697904b5222c39331bd56ec.tar.bz2 |
+ Added and yellow line tested _CORE_message_queue_Flush_waiting_threads
and _CORE_message_queue_Insert_message for posix message queues.
+ Yellow line tested new source
Diffstat (limited to 'c')
-rw-r--r-- | c/src/exec/score/src/Makefile.am | 3 | ||||
-rw-r--r-- | c/src/exec/score/src/coremsgflushwait.c | 70 | ||||
-rw-r--r-- | c/src/exec/score/src/coremsginsert.c | 102 |
3 files changed, 174 insertions, 1 deletions
diff --git a/c/src/exec/score/src/Makefile.am b/c/src/exec/score/src/Makefile.am index 04947cec47..a75b394a85 100644 --- a/c/src/exec/score/src/Makefile.am +++ b/c/src/exec/score/src/Makefile.am @@ -11,7 +11,8 @@ include $(top_srcdir)/../../../automake/lib.am MP_C_FILES = mpci.c objectmp.c threadmp.c CORE_MESSAGE_QUEUE_C_FILES = coremsg.c coremsgbroadcast.c coremsgclose.c \ - coremsgflush.c coremsgflushsupp.c coremsgseize.c coremsgsubmit.c + coremsgflush.c coremsgflushwait.c coremsginsert.c coremsgflushsupp.c \ + coremsgseize.c coremsgsubmit.c CORE_MUTEX_C_FILES = coremutex.c coremutexflush.c coremutexseize.c \ coremutexsurrender.c diff --git a/c/src/exec/score/src/coremsgflushwait.c b/c/src/exec/score/src/coremsgflushwait.c new file mode 100644 index 0000000000..bda8143ffd --- /dev/null +++ b/c/src/exec/score/src/coremsgflushwait.c @@ -0,0 +1,70 @@ +/* + * CORE Message Queue Handler + * + * DESCRIPTION: + * + * This package is the implementation of the CORE Message Queue Handler. + * This core object provides task synchronization and communication functions + * via messages passed to queue objects. + * + * 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.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#include <rtems/system.h> +#include <rtems/score/chain.h> +#include <rtems/score/isr.h> +#include <rtems/score/object.h> +#include <rtems/score/coremsg.h> +#include <rtems/score/states.h> +#include <rtems/score/thread.h> +#include <rtems/score/wkspace.h> +#if defined(RTEMS_MULTIPROCESSING) +#include <rtems/score/mpci.h> +#endif + +/*PAGE + * + * _CORE_message_queue_Flush_waiting_threads + * + * This function flushes the message_queue's task wait queue. The number + * of messages flushed from the queue is returned. + * + * Input parameters: + * the_message_queue - the message_queue to be flushed + * + * Output parameters: + * returns - the number of messages flushed from the queue + */ + +void _CORE_message_queue_Flush_waiting_threads( + CORE_message_queue_Control *the_message_queue +) +{ + /* XXX this is not supported for global message queues */ + + /* + * IF there are no pending messages, + * THEN threads may be blocked waiting to RECEIVE a message, + * + * IF the pending message queue is full + * THEN threads may be blocked waiting to SEND a message + * + * But in either case, we will return "unsatisfied nowait" + * to indicate that the blocking condition was not satisfied + * and that the blocking state was canceled. + */ + + _Thread_queue_Flush( + &the_message_queue->Wait_queue, + NULL, + CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT + ); +} + diff --git a/c/src/exec/score/src/coremsginsert.c b/c/src/exec/score/src/coremsginsert.c new file mode 100644 index 0000000000..f468334c97 --- /dev/null +++ b/c/src/exec/score/src/coremsginsert.c @@ -0,0 +1,102 @@ +/* + * CORE Message Queue Handler + * + * DESCRIPTION: + * + * This package is the implementation of the CORE Message Queue Handler. + * This core object provides task synchronization and communication functions + * via messages passed to queue objects. + * + * 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.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#include <rtems/system.h> +#include <rtems/score/chain.h> +#include <rtems/score/isr.h> +#include <rtems/score/object.h> +#include <rtems/score/coremsg.h> +#include <rtems/score/states.h> +#include <rtems/score/thread.h> +#include <rtems/score/wkspace.h> +#if defined(RTEMS_MULTIPROCESSING) +#include <rtems/score/mpci.h> +#endif + +/*PAGE + * + * _CORE_message_queue_Insert_message + * + * This kernel routine inserts the specified message into the + * message queue. It is assumed that the message has been filled + * in before this routine is called. + * + * Input parameters: + * the_message_queue - pointer to message queue + * the_message - message to insert + * priority - insert indication + * + * Output parameters: NONE + * + * INTERRUPT LATENCY: + * insert + */ + +void _CORE_message_queue_Insert_message( + CORE_message_queue_Control *the_message_queue, + CORE_message_queue_Buffer_control *the_message, + CORE_message_queue_Submit_types submit_type +) +{ + the_message_queue->number_of_pending_messages += 1; + + the_message->priority = submit_type; + + switch ( submit_type ) { + case CORE_MESSAGE_QUEUE_SEND_REQUEST: + _CORE_message_queue_Append( the_message_queue, the_message ); + break; + case CORE_MESSAGE_QUEUE_URGENT_REQUEST: + _CORE_message_queue_Prepend( the_message_queue, the_message ); + break; + default: + /* XXX interrupt critical section needs to be addressed */ + { + CORE_message_queue_Buffer_control *this_message; + Chain_Node *the_node; + Chain_Control *the_header; + + the_header = &the_message_queue->Pending_messages; + the_node = the_header->first; + while ( !_Chain_Is_tail( the_header, the_node ) ) { + + this_message = (CORE_message_queue_Buffer_control *) the_node; + + if ( this_message->priority <= the_message->priority ) { + the_node = the_node->next; + continue; + } + + break; + } + _Chain_Insert( the_node->previous, &the_message->Node ); + } + break; + } + + /* + * According to POSIX, does this happen before or after the message + * is actually enqueued. It is logical to think afterwards, because + * the message is actually in the queue at this point. + */ + + if ( the_message_queue->number_of_pending_messages == 1 && + the_message_queue->notify_handler ) + (*the_message_queue->notify_handler)( the_message_queue->notify_argument ); +} |