Added rtems_message_queue_get_number_pending directive.

This commit is contained in:
Joel Sherrill
1997-07-31 19:01:42 +00:00
parent a2fa8c2525
commit e7d8b58826
10 changed files with 246 additions and 47 deletions

View File

@@ -241,6 +241,23 @@ rtems_status_code rtems_message_queue_flush(
unsigned32 *count 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 * _Message_queue_Submit
* *

View File

@@ -46,7 +46,9 @@ typedef enum {
MESSAGE_QUEUE_MP_BROADCAST_REQUEST = 9, MESSAGE_QUEUE_MP_BROADCAST_REQUEST = 9,
MESSAGE_QUEUE_MP_BROADCAST_RESPONSE = 10, MESSAGE_QUEUE_MP_BROADCAST_RESPONSE = 10,
MESSAGE_QUEUE_MP_FLUSH_REQUEST = 11, MESSAGE_QUEUE_MP_FLUSH_REQUEST = 11,
MESSAGE_QUEUE_MP_FLUSH_RESPONSE = 12 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; } Message_queue_MP_Remote_operations;
/* /*

View File

@@ -241,6 +241,23 @@ rtems_status_code rtems_message_queue_flush(
unsigned32 *count 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 * _Message_queue_Submit
* *

View File

@@ -46,7 +46,9 @@ typedef enum {
MESSAGE_QUEUE_MP_BROADCAST_REQUEST = 9, MESSAGE_QUEUE_MP_BROADCAST_REQUEST = 9,
MESSAGE_QUEUE_MP_BROADCAST_RESPONSE = 10, MESSAGE_QUEUE_MP_BROADCAST_RESPONSE = 10,
MESSAGE_QUEUE_MP_FLUSH_REQUEST = 11, MESSAGE_QUEUE_MP_FLUSH_REQUEST = 11,
MESSAGE_QUEUE_MP_FLUSH_RESPONSE = 12 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; } Message_queue_MP_Remote_operations;
/* /*

View File

@@ -549,6 +549,56 @@ rtems_status_code rtems_message_queue_flush(
return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ 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 /*PAGE
* *
* _Message_queue_Submit * _Message_queue_Submit

View File

@@ -73,6 +73,8 @@ void _Message_queue_MP_Send_process_packet (
case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE: case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE:
case MESSAGE_QUEUE_MP_FLUSH_REQUEST: case MESSAGE_QUEUE_MP_FLUSH_REQUEST:
case MESSAGE_QUEUE_MP_FLUSH_RESPONSE: case MESSAGE_QUEUE_MP_FLUSH_RESPONSE:
case MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_REQUEST:
case MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_RESPONSE:
break; break;
} }
@@ -101,6 +103,7 @@ rtems_status_code _Message_queue_MP_Send_request_packet (
case MESSAGE_QUEUE_MP_URGENT_REQUEST: case MESSAGE_QUEUE_MP_URGENT_REQUEST:
case MESSAGE_QUEUE_MP_BROADCAST_REQUEST: case MESSAGE_QUEUE_MP_BROADCAST_REQUEST:
case MESSAGE_QUEUE_MP_FLUSH_REQUEST: case MESSAGE_QUEUE_MP_FLUSH_REQUEST:
case MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_REQUEST:
the_packet = _Message_queue_MP_Get_packet(); the_packet = _Message_queue_MP_Get_packet();
the_packet->Prefix.the_class = MP_PACKET_MESSAGE_QUEUE; the_packet->Prefix.the_class = MP_PACKET_MESSAGE_QUEUE;
@@ -180,6 +183,7 @@ rtems_status_code _Message_queue_MP_Send_request_packet (
case MESSAGE_QUEUE_MP_URGENT_RESPONSE: case MESSAGE_QUEUE_MP_URGENT_RESPONSE:
case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE: case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE:
case MESSAGE_QUEUE_MP_FLUSH_RESPONSE: case MESSAGE_QUEUE_MP_FLUSH_RESPONSE:
case MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_RESPONSE:
break; break;
} }
@@ -207,6 +211,7 @@ void _Message_queue_MP_Send_response_packet (
case MESSAGE_QUEUE_MP_URGENT_RESPONSE: case MESSAGE_QUEUE_MP_URGENT_RESPONSE:
case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE: case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE:
case MESSAGE_QUEUE_MP_FLUSH_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; 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_URGENT_REQUEST:
case MESSAGE_QUEUE_MP_BROADCAST_REQUEST: case MESSAGE_QUEUE_MP_BROADCAST_REQUEST:
case MESSAGE_QUEUE_MP_FLUSH_REQUEST: case MESSAGE_QUEUE_MP_FLUSH_REQUEST:
case MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_REQUEST:
break; break;
} }
@@ -382,6 +388,7 @@ void _Message_queue_MP_Process_packet (
case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE: case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE:
case MESSAGE_QUEUE_MP_FLUSH_RESPONSE: case MESSAGE_QUEUE_MP_FLUSH_RESPONSE:
case MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_RESPONSE:
the_thread = _MPCI_Process_response( the_packet_prefix ); the_thread = _MPCI_Process_response( the_packet_prefix );
@@ -404,6 +411,20 @@ void _Message_queue_MP_Process_packet (
); );
break; 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;
} }
} }

View File

@@ -241,6 +241,23 @@ rtems_status_code rtems_message_queue_flush(
unsigned32 *count 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 * _Message_queue_Submit
* *

View File

@@ -46,7 +46,9 @@ typedef enum {
MESSAGE_QUEUE_MP_BROADCAST_REQUEST = 9, MESSAGE_QUEUE_MP_BROADCAST_REQUEST = 9,
MESSAGE_QUEUE_MP_BROADCAST_RESPONSE = 10, MESSAGE_QUEUE_MP_BROADCAST_RESPONSE = 10,
MESSAGE_QUEUE_MP_FLUSH_REQUEST = 11, MESSAGE_QUEUE_MP_FLUSH_REQUEST = 11,
MESSAGE_QUEUE_MP_FLUSH_RESPONSE = 12 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; } Message_queue_MP_Remote_operations;
/* /*

View File

@@ -549,6 +549,56 @@ rtems_status_code rtems_message_queue_flush(
return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ 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 /*PAGE
* *
* _Message_queue_Submit * _Message_queue_Submit

View File

@@ -73,6 +73,8 @@ void _Message_queue_MP_Send_process_packet (
case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE: case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE:
case MESSAGE_QUEUE_MP_FLUSH_REQUEST: case MESSAGE_QUEUE_MP_FLUSH_REQUEST:
case MESSAGE_QUEUE_MP_FLUSH_RESPONSE: case MESSAGE_QUEUE_MP_FLUSH_RESPONSE:
case MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_REQUEST:
case MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_RESPONSE:
break; break;
} }
@@ -101,6 +103,7 @@ rtems_status_code _Message_queue_MP_Send_request_packet (
case MESSAGE_QUEUE_MP_URGENT_REQUEST: case MESSAGE_QUEUE_MP_URGENT_REQUEST:
case MESSAGE_QUEUE_MP_BROADCAST_REQUEST: case MESSAGE_QUEUE_MP_BROADCAST_REQUEST:
case MESSAGE_QUEUE_MP_FLUSH_REQUEST: case MESSAGE_QUEUE_MP_FLUSH_REQUEST:
case MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_REQUEST:
the_packet = _Message_queue_MP_Get_packet(); the_packet = _Message_queue_MP_Get_packet();
the_packet->Prefix.the_class = MP_PACKET_MESSAGE_QUEUE; the_packet->Prefix.the_class = MP_PACKET_MESSAGE_QUEUE;
@@ -180,6 +183,7 @@ rtems_status_code _Message_queue_MP_Send_request_packet (
case MESSAGE_QUEUE_MP_URGENT_RESPONSE: case MESSAGE_QUEUE_MP_URGENT_RESPONSE:
case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE: case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE:
case MESSAGE_QUEUE_MP_FLUSH_RESPONSE: case MESSAGE_QUEUE_MP_FLUSH_RESPONSE:
case MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_RESPONSE:
break; break;
} }
@@ -207,6 +211,7 @@ void _Message_queue_MP_Send_response_packet (
case MESSAGE_QUEUE_MP_URGENT_RESPONSE: case MESSAGE_QUEUE_MP_URGENT_RESPONSE:
case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE: case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE:
case MESSAGE_QUEUE_MP_FLUSH_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; 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_URGENT_REQUEST:
case MESSAGE_QUEUE_MP_BROADCAST_REQUEST: case MESSAGE_QUEUE_MP_BROADCAST_REQUEST:
case MESSAGE_QUEUE_MP_FLUSH_REQUEST: case MESSAGE_QUEUE_MP_FLUSH_REQUEST:
case MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_REQUEST:
break; break;
} }
@@ -382,6 +388,7 @@ void _Message_queue_MP_Process_packet (
case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE: case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE:
case MESSAGE_QUEUE_MP_FLUSH_RESPONSE: case MESSAGE_QUEUE_MP_FLUSH_RESPONSE:
case MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_RESPONSE:
the_thread = _MPCI_Process_response( the_packet_prefix ); the_thread = _MPCI_Process_response( the_packet_prefix );
@@ -404,6 +411,20 @@ void _Message_queue_MP_Process_packet (
); );
break; 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;
} }
} }