Kernel Development Learning Pipeline
Lecture 07: 31 September 2024
What ways can your program crash? Has anyone written a C program that crashed? what happened?
Crash type iceberg:
- SIGSEGV
- SIGFPE
- SIGBUS
- SIGILL
try and write some assembly code that executes illegal or privileged instructions. What happens?
What mechanism underlies this
traps exceptions interrupts aborts
https://kdlp.underground.software/articles/kernel_basics.html
OLD L06:
- Processes (35m)
- PID, TGID kernel vs userspace lingo
- parent/child relationships
- PID 1, subreapers (
prctl(PR_SET_CHILD_SUBREAPER)
), and orphans
- PID namespaces, unshare, containers
- file descriptors & syscalls (35m)
- what is a file descriptor
- usage in syscalls
- everything is a file (descriptor)
- fopen vs open: beyond the libc
- signals: SIGCHLD, SIGPIPE
What is a file?
- references open file on disk (could refer to a directory or a symlink too)
- even unix had seeds of something else (block and char devices, sockets and fifos)
- the real answer is a handle to some sort of kernel resource
What is a signal?
- naive answer is asynchronous notification that calls a function
- really just an upcall from kernel space to userspace
- actually not nessecarily a function call, or asynchronous (signalfd)
What is a syscall?
- naive answer is magic function call that invokes the kernel
- could write a program that invokes no syscalls, but its results would not be obvservable (caveat, maybe?)
- really it is the atom of observable computing
- not even really a function call (io_uring)
What is a process, what is a thread?
- naive answer is fork and pthread create,
- in reality they are points within a multidimensional space governed by unshare