Index
Week 5
Multi-core means that you can put into a single chip several CPUs. (Instruction-level parallelism) (does not mean multiple instructions per cycle, that's 90's tech)Inter-Process Communication
Program reuse, both cooperation/independence, parallellism, OS needs (microkernel)
- Why do we need to have inter-process communication between processes?
- What is the challenge?
→ Between P0 and P1 there is hard modularity, which means that for P0 and P1, they are unable to access each other's memory directly.
- What are the use-cases?
→ 1st use case (Historical)
⇒ Multi-programming
⇒ Cooperating processes
• Ancestor idea to multithreading
→ Chain commands together
⇒ Piping
- Either the sharing or the transfer of data.
Communication within a process (uses soft modularity)
- Function calls
- Global variables
Types of IPC
- Pipes
→ Every process can create a pipe through the pipe command
⇒ Pipe takes in an array of 2 ints, 0 for reading, 1 for writing
• write(int fd, const char *, size_t);
- Message Passing
- Shared Memory
Unidirectional is essentially half duplex (ie one directional)
Every process has at least 3 files: stdin, stdout and stderr
If the process creates a pipe it would have 2 more files opened: PipeIn and PipeOut.
How does the parent process pass on stuff to the child process?
- All child processes inherit the open files of the parent.
dup(int fd)
duplicates fd on the lowest closed file descriptor.