documentation/kernel/proc/pipe.h.md

2.4 KiB

pipe.h

Pipes are data streams between processes.

PIPE_MAX_SENDERS - macro

The maximum amount of processes, which can write data to one pipe.

PIPE_STD_STREAM_SIZE - macro

The size of a pipes stream buffer, in bytes.

pipe_T - struct

Name Type Description
stream stream_T* The stream, where the pipes data is saved.
receiver process_T* The process which is allowed to read from the pipe.
senders process_T* [PIPE_MAX_SENDERS] The processes which are allowed to write to the pipe.
senders_bitmap bitmap_T Indicates which fields of senders are currently used.
on_write void function pointer If this is not NULL, this function will be called when data is written into the stream.

pipe_init(pipe*, receiver*, (*on_write)()) - function (void)

Initializes pipe and allocates a stream for it.

pipe_destruct(pipe*) - function (void)

Destructs pipe and frees all of its resources.

pipe_add_sender(pipe*, sender*) - function (bool)

Adds sender to the sender list of pipe. Returns if the operation was successful.

pipe_remove_sender(pipe*, sender*) - function (void)

Removes sender from the sender list of pipe.

pipe_write(pipe*, buffer_in*, n) - function (uint64_t)

Writes at most n bytes from buffer_in into pipe. Returns the amount of bytes that were actually written. If the amount of actually written bytes is smaller than n all sender processes of pipe will be PIPE_OUT blocked. If the receiver is PIPE_IN blocked the blocker will be removed.

pipe_read(pipe*, buffer_out*, n) - function (uint64_t)

Reads at most n bytes from buffer_in into pipe. Returns the amount of bytes that were actually read. If the amount of actually read bytes is smaller than n the receiver process of pipe will be PIPE_IN blocked. If the senders are PIPE_OUT blocked the blockers will be removed.