2 - Shell (Part 2) Flashcards
How do you provide shared memory for multiple processes?
Use the pipe function.
What is the restriction you must adhere to when using pipes between processes?
You can use pipes between processes that have a common ancestor.
How do you create a pipe?
#include int pip(int filedes[2]);
Which one do you do first: fork or pipe?
You pipe first, then fork. Fork will copy the parents file descriptor table to the child’s - the pipe will be connected between the two.
Once piped and forked, what should you do about the respective child’s and parent’s FD[0] and FD[1]?
You should close parent opposite FD[0] and FD[1]
Where does FD[0] and FD[1] point to?
System File Table
By default, if a writing process attempts to write to a full pipe, what happens?
System will automatically block the process until the pipe is able to receive the data
If a read is attempted on an empty pipe, what happens?
Process will block until data is available.
If a specified pipe has been opened for reading, but another process has not opened the pipe for writing, what will happen?
Process will block.
What is the space called that is used by the pipe?
The buffer space.
Is there a limit to this buffer space? What enforces it if so?
The OS has a limit on the buffer space used by the pipe.
What are the pipe return codes and what do they mean?
0 = ok -1 = error
In the shared memory created by the pipe function, what does the information on the read descriptor table include? The write descriptor?
Info about the last location read from. Info about the last location written to.
How do you re-route stdin and stdout?
Using dup() functions
What is the library that contains the dup() functions?
include