Lesson 6 of 7

System Calls & Talking Between Processes

Whenever a program prints, reads a file or opens a connection, it asks the through a system call. You'll learn to watch those calls and see how processes talk to each other.

A system call is a controlled jump into the kernel: the program puts a syscall number and in registers and executes a special instruction; the CPU switches to kernel mode at a fixed entry point; the kernel does the work, and returns a result (or an ). There are ~350 syscalls on Linux; a dozen — open, read, write, close, mmap, fork, execve, wait, socket, connect, accept, exit — cover most of what programs do.

Bash
# strace shows every syscall a program makes:
strace -c ls        # summary: counts and time per syscall
strace echo hi      # full trace; note write(1, "hi\n", 3)

# Even print() is a syscall at the bottom:
# python3 -c 'print("hi")'  ends in  write(1, "hi\n", 3)

# Syscalls are ~100-300ns each — cheap, not free.
# That's why buffered IO exists: 1 write() of 8KB
# beats 8000 write()s of 1 byte, ~1000x.

Processes are isolated by design, so the OS provides official channels between them — inter-process communication (IPC). stream from one process to another (every | is one). Sockets do the same across machines. Shared maps the same physical pages into two processes — fastest, and reintroduces every threading hazard. Signals poke; files rendezvous.

Bash
# A shell pipeline is three processes and two pipes:
cat access.log | grep "500" | wc -l
#   cat's stdout -> pipe -> grep's stdin
#   grep's stdout -> pipe -> wc's stdin
# The kernel moves the bytes; the processes never meet.

# The pipe blocks when full — that's backpressure:
# 'cat' automatically slows to the speed of 'wc'.
Finished reading?Mark it done to track your progress.

Tip: use the ← and → keys to move between lessons.