Explain the pipe operation in the shell.
Give two examples of pipe types.
Describe pipe creation with relevant code.
int pipe(int pipefd[2]); int pipe2(int pipefd[2], int flags); /* O_NONBLOCK */
fd[0] descriptor open for readingfd[1] descriptor open for writingerrno variable set)Describe the communication process in pipes with relevant code.
ssize_t read(int fd, void *buf, size_t count); ssize_t write(int fd, void *buf, size_t count);
fd[0] or fd[1])What happens if a process attempts to read from an empty pipe?
read(2) will block until data is available
What happens if a process attempts to write to a full pipe?
write(2) blocks until sufficient data has been read from the pipe to allow the write to complete
How can nonblocking I/O be achieved?
Using O_NONBLOCK status flag
What is the communication channel provided by a pipe?
It is a byte stream, so there is no concept of message boundaries.
What is the major limitation of pipes?
Processes should be related.
How to implement pipes that are accessible by other processes?
Explain the process of closing pipes.
List the characteristics of pipes.
Name an alternative to pipes to solve its limitations, what problem they fix and what characteristics change.
FIFOs, also called named pipes.
mkfifo()Explain process creation.
To start a new process call:
\#include \<unistd.h\> pid_t fork();
Slide 19, 20, chapter 6
Explain UNIX process creation and management.
Unix process creation - two steps
Management
How to execute different programs with a fork?
Replace the code after the fork.