forked from Imagelibrary/rtems
Added rtems_message_queue_get_number_pending directive.
This commit is contained in:
@@ -241,6 +241,23 @@ rtems_status_code rtems_message_queue_flush(
|
||||
unsigned32 *count
|
||||
);
|
||||
|
||||
/*
|
||||
* rtems_message_queue_get_number_pending
|
||||
*
|
||||
* DESCRIPTION:
|
||||
*
|
||||
* This routine implements the rtems_message_queue_get_number_pending
|
||||
* directive. This directive returns the number of pending
|
||||
* messages for the message queue indicated by ID
|
||||
* chain. The number of messages pending is returned in COUNT.
|
||||
*/
|
||||
|
||||
rtems_status_code rtems_message_queue_get_number_pending(
|
||||
Objects_Id id,
|
||||
unsigned32 *count
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
* _Message_queue_Submit
|
||||
*
|
||||
|
||||
@@ -34,19 +34,21 @@ extern "C" {
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
MESSAGE_QUEUE_MP_ANNOUNCE_CREATE = 0,
|
||||
MESSAGE_QUEUE_MP_ANNOUNCE_DELETE = 1,
|
||||
MESSAGE_QUEUE_MP_EXTRACT_PROXY = 2,
|
||||
MESSAGE_QUEUE_MP_RECEIVE_REQUEST = 3,
|
||||
MESSAGE_QUEUE_MP_RECEIVE_RESPONSE = 4,
|
||||
MESSAGE_QUEUE_MP_SEND_REQUEST = 5,
|
||||
MESSAGE_QUEUE_MP_SEND_RESPONSE = 6,
|
||||
MESSAGE_QUEUE_MP_URGENT_REQUEST = 7,
|
||||
MESSAGE_QUEUE_MP_URGENT_RESPONSE = 8,
|
||||
MESSAGE_QUEUE_MP_BROADCAST_REQUEST = 9,
|
||||
MESSAGE_QUEUE_MP_BROADCAST_RESPONSE = 10,
|
||||
MESSAGE_QUEUE_MP_FLUSH_REQUEST = 11,
|
||||
MESSAGE_QUEUE_MP_FLUSH_RESPONSE = 12
|
||||
MESSAGE_QUEUE_MP_ANNOUNCE_CREATE = 0,
|
||||
MESSAGE_QUEUE_MP_ANNOUNCE_DELETE = 1,
|
||||
MESSAGE_QUEUE_MP_EXTRACT_PROXY = 2,
|
||||
MESSAGE_QUEUE_MP_RECEIVE_REQUEST = 3,
|
||||
MESSAGE_QUEUE_MP_RECEIVE_RESPONSE = 4,
|
||||
MESSAGE_QUEUE_MP_SEND_REQUEST = 5,
|
||||
MESSAGE_QUEUE_MP_SEND_RESPONSE = 6,
|
||||
MESSAGE_QUEUE_MP_URGENT_REQUEST = 7,
|
||||
MESSAGE_QUEUE_MP_URGENT_RESPONSE = 8,
|
||||
MESSAGE_QUEUE_MP_BROADCAST_REQUEST = 9,
|
||||
MESSAGE_QUEUE_MP_BROADCAST_RESPONSE = 10,
|
||||
MESSAGE_QUEUE_MP_FLUSH_REQUEST = 11,
|
||||
MESSAGE_QUEUE_MP_FLUSH_RESPONSE = 12,
|
||||
MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_REQUEST = 13,
|
||||
MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_RESPONSE = 14
|
||||
} Message_queue_MP_Remote_operations;
|
||||
|
||||
/*
|
||||
|
||||
@@ -241,6 +241,23 @@ rtems_status_code rtems_message_queue_flush(
|
||||
unsigned32 *count
|
||||
);
|
||||
|
||||
/*
|
||||
* rtems_message_queue_get_number_pending
|
||||
*
|
||||
* DESCRIPTION:
|
||||
*
|
||||
* This routine implements the rtems_message_queue_get_number_pending
|
||||
* directive. This directive returns the number of pending
|
||||
* messages for the message queue indicated by ID
|
||||
* chain. The number of messages pending is returned in COUNT.
|
||||
*/
|
||||
|
||||
rtems_status_code rtems_message_queue_get_number_pending(
|
||||
Objects_Id id,
|
||||
unsigned32 *count
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
* _Message_queue_Submit
|
||||
*
|
||||
|
||||
@@ -34,19 +34,21 @@ extern "C" {
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
MESSAGE_QUEUE_MP_ANNOUNCE_CREATE = 0,
|
||||
MESSAGE_QUEUE_MP_ANNOUNCE_DELETE = 1,
|
||||
MESSAGE_QUEUE_MP_EXTRACT_PROXY = 2,
|
||||
MESSAGE_QUEUE_MP_RECEIVE_REQUEST = 3,
|
||||
MESSAGE_QUEUE_MP_RECEIVE_RESPONSE = 4,
|
||||
MESSAGE_QUEUE_MP_SEND_REQUEST = 5,
|
||||
MESSAGE_QUEUE_MP_SEND_RESPONSE = 6,
|
||||
MESSAGE_QUEUE_MP_URGENT_REQUEST = 7,
|
||||
MESSAGE_QUEUE_MP_URGENT_RESPONSE = 8,
|
||||
MESSAGE_QUEUE_MP_BROADCAST_REQUEST = 9,
|
||||
MESSAGE_QUEUE_MP_BROADCAST_RESPONSE = 10,
|
||||
MESSAGE_QUEUE_MP_FLUSH_REQUEST = 11,
|
||||
MESSAGE_QUEUE_MP_FLUSH_RESPONSE = 12
|
||||
MESSAGE_QUEUE_MP_ANNOUNCE_CREATE = 0,
|
||||
MESSAGE_QUEUE_MP_ANNOUNCE_DELETE = 1,
|
||||
MESSAGE_QUEUE_MP_EXTRACT_PROXY = 2,
|
||||
MESSAGE_QUEUE_MP_RECEIVE_REQUEST = 3,
|
||||
MESSAGE_QUEUE_MP_RECEIVE_RESPONSE = 4,
|
||||
MESSAGE_QUEUE_MP_SEND_REQUEST = 5,
|
||||
MESSAGE_QUEUE_MP_SEND_RESPONSE = 6,
|
||||
MESSAGE_QUEUE_MP_URGENT_REQUEST = 7,
|
||||
MESSAGE_QUEUE_MP_URGENT_RESPONSE = 8,
|
||||
MESSAGE_QUEUE_MP_BROADCAST_REQUEST = 9,
|
||||
MESSAGE_QUEUE_MP_BROADCAST_RESPONSE = 10,
|
||||
MESSAGE_QUEUE_MP_FLUSH_REQUEST = 11,
|
||||
MESSAGE_QUEUE_MP_FLUSH_RESPONSE = 12,
|
||||
MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_REQUEST = 13,
|
||||
MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_RESPONSE = 14
|
||||
} Message_queue_MP_Remote_operations;
|
||||
|
||||
/*
|
||||
|
||||
@@ -549,6 +549,56 @@ rtems_status_code rtems_message_queue_flush(
|
||||
return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
|
||||
}
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
* rtems_message_queue_get_number_pending
|
||||
*
|
||||
* This directive returns the number of messages pending.
|
||||
*
|
||||
* Input parameters:
|
||||
* id - queue id
|
||||
* count - return area for count
|
||||
*
|
||||
* Output parameters:
|
||||
* count - number of messages removed ( 0 = empty queue )
|
||||
* RTEMS_SUCCESSFUL - if successful
|
||||
* error code - if unsuccessful
|
||||
*/
|
||||
|
||||
rtems_status_code rtems_message_queue_get_number_pending(
|
||||
Objects_Id id,
|
||||
unsigned32 *count
|
||||
)
|
||||
{
|
||||
register Message_queue_Control *the_message_queue;
|
||||
Objects_Locations location;
|
||||
|
||||
the_message_queue = _Message_queue_Get( id, &location );
|
||||
switch ( location ) {
|
||||
case OBJECTS_ERROR:
|
||||
return RTEMS_INVALID_ID;
|
||||
case OBJECTS_REMOTE:
|
||||
_Thread_Executing->Wait.return_argument = count;
|
||||
|
||||
return
|
||||
_Message_queue_MP_Send_request_packet(
|
||||
MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_REQUEST,
|
||||
id,
|
||||
0, /* buffer not used */
|
||||
0, /* size */
|
||||
0, /* option_set not used */
|
||||
MPCI_DEFAULT_TIMEOUT
|
||||
);
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
*count = the_message_queue->message_queue.number_of_pending_messages;
|
||||
_Thread_Enable_dispatch();
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
|
||||
}
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
* _Message_queue_Submit
|
||||
|
||||
@@ -73,6 +73,8 @@ void _Message_queue_MP_Send_process_packet (
|
||||
case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE:
|
||||
case MESSAGE_QUEUE_MP_FLUSH_REQUEST:
|
||||
case MESSAGE_QUEUE_MP_FLUSH_RESPONSE:
|
||||
case MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_REQUEST:
|
||||
case MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_RESPONSE:
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -101,6 +103,7 @@ rtems_status_code _Message_queue_MP_Send_request_packet (
|
||||
case MESSAGE_QUEUE_MP_URGENT_REQUEST:
|
||||
case MESSAGE_QUEUE_MP_BROADCAST_REQUEST:
|
||||
case MESSAGE_QUEUE_MP_FLUSH_REQUEST:
|
||||
case MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_REQUEST:
|
||||
|
||||
the_packet = _Message_queue_MP_Get_packet();
|
||||
the_packet->Prefix.the_class = MP_PACKET_MESSAGE_QUEUE;
|
||||
@@ -120,7 +123,7 @@ rtems_status_code _Message_queue_MP_Send_request_packet (
|
||||
return RTEMS_INVALID_SIZE;
|
||||
}
|
||||
|
||||
if ( ! _Options_Is_no_wait(option_set))
|
||||
if (! _Options_Is_no_wait(option_set))
|
||||
the_packet->Prefix.timeout = timeout;
|
||||
|
||||
the_packet->operation = operation;
|
||||
@@ -154,7 +157,7 @@ rtems_status_code _Message_queue_MP_Send_request_packet (
|
||||
the_packet->Prefix.length = sizeof(Message_queue_MP_Packet);
|
||||
the_packet->Prefix.to_convert = sizeof(Message_queue_MP_Packet);
|
||||
|
||||
if ( ! _Options_Is_no_wait(option_set))
|
||||
if (! _Options_Is_no_wait(option_set))
|
||||
the_packet->Prefix.timeout = timeout;
|
||||
|
||||
the_packet->operation = MESSAGE_QUEUE_MP_RECEIVE_REQUEST;
|
||||
@@ -180,6 +183,7 @@ rtems_status_code _Message_queue_MP_Send_request_packet (
|
||||
case MESSAGE_QUEUE_MP_URGENT_RESPONSE:
|
||||
case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE:
|
||||
case MESSAGE_QUEUE_MP_FLUSH_RESPONSE:
|
||||
case MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_RESPONSE:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -207,6 +211,7 @@ void _Message_queue_MP_Send_response_packet (
|
||||
case MESSAGE_QUEUE_MP_URGENT_RESPONSE:
|
||||
case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE:
|
||||
case MESSAGE_QUEUE_MP_FLUSH_RESPONSE:
|
||||
case MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_RESPONSE:
|
||||
|
||||
the_packet = ( Message_queue_MP_Packet *) the_thread->receive_packet;
|
||||
|
||||
@@ -237,6 +242,7 @@ void _Message_queue_MP_Send_response_packet (
|
||||
case MESSAGE_QUEUE_MP_URGENT_REQUEST:
|
||||
case MESSAGE_QUEUE_MP_BROADCAST_REQUEST:
|
||||
case MESSAGE_QUEUE_MP_FLUSH_REQUEST:
|
||||
case MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_REQUEST:
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -284,7 +290,7 @@ void _Message_queue_MP_Process_packet (
|
||||
|
||||
the_thread = _Thread_MP_Find_proxy( the_packet->proxy_id );
|
||||
|
||||
if ( ! _Thread_Is_null( the_thread ) )
|
||||
if (! _Thread_Is_null( the_thread ) )
|
||||
_Thread_queue_Extract( the_thread->Wait.queue, the_thread );
|
||||
|
||||
_MPCI_Return_packet( the_packet_prefix );
|
||||
@@ -300,7 +306,7 @@ void _Message_queue_MP_Process_packet (
|
||||
the_packet->Prefix.timeout
|
||||
);
|
||||
|
||||
if ( ! _Thread_Is_proxy_blocking( the_packet->Prefix.return_code ) )
|
||||
if (! _Thread_Is_proxy_blocking( the_packet->Prefix.return_code ) )
|
||||
_Message_queue_MP_Send_response_packet(
|
||||
MESSAGE_QUEUE_MP_RECEIVE_RESPONSE,
|
||||
the_packet->Prefix.id,
|
||||
@@ -382,6 +388,7 @@ void _Message_queue_MP_Process_packet (
|
||||
|
||||
case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE:
|
||||
case MESSAGE_QUEUE_MP_FLUSH_RESPONSE:
|
||||
case MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_RESPONSE:
|
||||
|
||||
the_thread = _MPCI_Process_response( the_packet_prefix );
|
||||
|
||||
@@ -404,6 +411,20 @@ void _Message_queue_MP_Process_packet (
|
||||
);
|
||||
break;
|
||||
|
||||
case MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_REQUEST:
|
||||
|
||||
the_packet->Prefix.return_code = rtems_message_queue_get_number_pending(
|
||||
the_packet->Prefix.id,
|
||||
&the_packet->count
|
||||
);
|
||||
|
||||
_Message_queue_MP_Send_response_packet(
|
||||
MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_RESPONSE,
|
||||
the_packet->Prefix.id,
|
||||
_Thread_Executing
|
||||
);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user