kernel: pipes: add pipe flush routines

Adds two routines to flush pipe objects:
   k_pipe_flush()
     - This routine flushes the entire pipe. That includes both
     the pipe's buffer and all pended writers. It is equivalent
     to reading everything into a giant temporary buffer which
     is then discarded.
   k_pipe_buffer_flush()
     - This routine flushes only the pipe's buffer (if it exists).
     It is equivalent to reading a maximum of "buffer size" bytes
     into a temporary buffer which is then discarded.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
This commit is contained in:
Peter Mitsis 2021-10-04 12:36:22 -04:00 committed by Anas Nashif
commit d1353a4584
7 changed files with 193 additions and 30 deletions

View file

@ -4925,6 +4925,35 @@ __syscall size_t k_pipe_read_avail(struct k_pipe *pipe);
*/
__syscall size_t k_pipe_write_avail(struct k_pipe *pipe);
/**
* @brief Flush the pipe of write data
*
* This routine flushes the pipe. Flushing the pipe is equivalent to reading
* both all the data in the pipe's buffer and all the data waiting to go into
* that pipe into a large temporary buffer and discarding the buffer. Any
* writers that were previously pended become unpended.
*
* @param pipe Address of the pipe.
*
* @return N/A
*/
__syscall void k_pipe_flush(struct k_pipe *pipe);
/**
* @brief Flush the pipe's internal buffer
*
* This routine flushes the pipe's internal buffer. This is equivalent to
* reading up to N bytes from the pipe (where N is the size of the pipe's
* buffer) into a temporary buffer and then discarding that buffer. If there
* were writers previously pending, then some may unpend as they try to fill
* up the pipe's emptied buffer.
*
* @param pipe Address of the pipe.
*
* @return N/A
*/
__syscall void k_pipe_buffer_flush(struct k_pipe *pipe);
/** @} */
/**