So far we’ve put a lot of effort into making sure each program (represented by a process in our kernel) is completely isolated from all others. This is great for safety and security, but it presents a big problem: what if we want two processes to communicate with each other?
The answer to this is some form of inter-process communication (aka IPC
). This part will look at some basic implementations for the common types and will hopefully serve a good jumping off point for further implementations. It should be noted that IPC is mainly intended for userspace programs to communicate with each other, if you have multiple kernel threads wanting to communicate there’s no need for the overhead of IPC.
All IPC can be broken down into two forms:
These terms refer to the number of times the data must be copied before reaching its destination. Message passing as described above is double-copy (process A’s buffer is copied to the kernel buffer, kernel buffer is copied to process B’s buffer). There are ways to implement single-copy of course.
For fun, we can think of shared memory as ‘zero-copy’, since the data is never copied at all.