os: batching of packet-stream source operations

This patch adds support for manually triggering the wakeup of the packet
sink by the source. This way, a packet source becomes able to marshal
batches of submissions or unmarshal batches of acknowledgements before
yielding the control over to the sink.

Issue #3283
This commit is contained in:
Norman Feske 2019-04-10 22:16:31 +02:00 committed by Christian Helmuth
parent ea6b1c255e
commit c433f87000
1 changed files with 37 additions and 3 deletions

View File

@ -784,11 +784,11 @@ class Genode::Packet_stream_source : private Packet_stream_base
return Packet_stream_base::packet_content<Content_type>(packet); }
/**
* Return true if submit queue can hold another packet
* Return true if submit queue can hold 'count' additional packets
*/
bool ready_to_submit()
bool ready_to_submit(unsigned count = 1)
{
return _submit_transmitter.ready_for_tx();
return _submit_transmitter.tx_slots_free() >= count;
}
/**
@ -799,6 +799,30 @@ class Genode::Packet_stream_source : private Packet_stream_base
_submit_transmitter.tx(packet);
}
/**
* Submit the specified packet to the server if possible
*
* \return false if the submit queue is congested
*
* This method never blocks.
*/
bool try_submit_packet(Packet_descriptor packet)
{
return _submit_transmitter.try_tx(packet);
}
/**
* Wake up the packet sink if needed
*
* This method assumes that the same signal handler is used for
* the submit transmitter and the ack receiver.
*/
void wakeup()
{
/* submit only one signal */
_submit_transmitter.tx_wakeup() || _ack_receiver.rx_wakeup();
}
/**
* Returns true if one or more packet acknowledgements are available
*/
@ -814,6 +838,16 @@ class Genode::Packet_stream_source : private Packet_stream_base
return packet;
}
/**
* Return next acknowledgement from sink, or an invalid packet
*
* This method never blocks.
*/
Packet_descriptor try_get_acked_packet()
{
return _ack_receiver.try_rx();
}
/**
* Release bulk-buffer space consumed by the packet
*/