|
miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
|
#include <pipe.h>
Public Attributes | |
| uint8_t | buf [PIPE_SIZE] |
| uint32_t | write_pos |
| uint32_t | read_pos |
| uint32_t | ref_count |
| uint8_t | write_closed |
pipe_t - Kernel object for an anonymous pipe.
Uses monotonically increasing uint32_t cursors (never reset). The actual buffer index is cursor % PIPE_SIZE. This eliminates the full/empty ambiguity that plagues same-value-cursor designs.
Available bytes = write_pos - read_pos Free space = PIPE_SIZE - (write_pos - read_pos)
uint32_t overflow at 2^32 wraps cleanly because PIPE_SIZE is a power of 2 and all arithmetic is unsigned modulo 2^32.
| uint32_t pipe_t::read_pos |
| uint32_t pipe_t::ref_count |
| uint8_t pipe_t::write_closed |
| uint32_t pipe_t::write_pos |