home blog portfolio Ian Fisher

Week 10: Review

Week 1 – Syscalls

System calls are how Linux programs talk to the operating system. System calls look like function calls, but under the hood they are very different: instead of jumping to another place in your program, they switch out of your program and into the operating system. We used C for our examples in this course, but many languages have system APIs.

Weeks 2 & 3 – Filesystems

The filesystem is where Linux programs can read and write data that will persist indefinitely. Files are arrays of bytes; directories are listings of files (and possibly other directories). Linux permissions allow you to specify who can access a file and what they can do with it. Multiple processes can access the same file at once; use file locks or lock down permissions to protect against data races and corruption.

Week 4 – Process control

The process is the basic unit of running code on Linux. Processes are identified by PIDs, and run as a particular user and group. You create a new process with fork and start running a new program with execve. Every process has a parent, and parents can wait for their children to exit.

Week 5 – Interprocess communication

Interprocess communication refers to the various mechanisms for processes to communicate with each other. Pipes are a simple way for parent and child processes to pass data to each other. Shared memory lets (potentially unrelated) processes share data structures in memory, with access synchronized by semaphores.

Week 6 – Networking

The Linux socket API is used both for networking (talking to the external world) and as a form of IPC. Servers use bind, listen, and accept to handle incoming connections, while clients use connect to talk to the outside world. Sockets are file descriptors and can use the regular file I/O system calls, though specialized APIs like send and recv also exist.

Week 7 – Multithreading

Multithreading lets different parts of the same program run concurrently (and possibly in parallel). The syscalls for multithreading are too low-level for regular use; applications use the pthreads interface instead. Mutexes and read-write locks let multiple threads synchronize with each other.

Week 8 – Signals

Signals are a wait to asynchronously notify a process of an interesting event. Signals can be ignored or handled by a callback function. Processes can mask signals – temporarily blocking. Like multithreading, signals are a form of concurrent execution, and are tricky to get right.

Week 9 – Advanced I/O

Some programs need to read and write from multiple devices at once. Linux provides the O_NONBLOCK flag, the epoll family of system calls, and most recently the io_uring subsystem to do so conveniently and efficiently.