Monday
Room 1
09:00 - 17:00
(UTC+02)
2 Days
Linux System Programming Fundamentals
This two-day workshop provides a solid understanding of the operating system architecture and low-level interfaces (principally, system calls and library functions) that are required to build system-level applications on Linux (and UNIX) systems. By completion of the workshop, participants will have a good understanding of the construction of many common Linux and UNIX programs (e.g., the shell, ls(1), and cp(1))
Topics
(+) Topics marked with a plus sign will be covered as time permits.
1. Introduction
2. Fundamental Concepts
* System calls and library functions
* Error handling
* System data types
* Notes on code examples
3. File I/O and Files
* File I/O overview
* open(), read(), write(), and close()
* The file offset and lseek()
* Relationship between file descriptors and open files
* Duplicating file descriptors
* File status flags (and fcntl())
* Retrieving file information: stat()
4. Processes
* Process IDs
* Process memory layout
* Command-line arguments
* The environment list
* The /proc filesystem
5. Signals
* Overview of signals
* Signal dispositions
* Useful signal-related functions
* Signal handlers
* Signal sets, the signal mask, and pending signals
* Designing signal handlers
6. Signals: Signal Handlers
* Async-signal-safe functions
* Interrupted system calls
* SA_SIGINFO signal handlers
* The signal trampoline (+)
7. Process Lifecycle
* Creating a new process: fork()
* Process termination
* Monitoring child processes
* Orphans and zombies
* The SIGCHLD signal
* Executing programs: execve()
8. System Call Tracing with strace (+)
* Getting started
* Tracing child processes
* Filtering strace output
* System call tampering
* Further strace options
9. Pipes and FIFOs
* Creating and using pipes
* Connecting filters with pipes
* FIFOs (+)
10. Alternative I/O Models
* Nonblocking I/O
* Signal-driven I/O
* I/O multiplexing: poll()
* Problems with poll() and select()
* The epoll API
* epoll events
* epoll: edge-triggered notification
* epoll: API quirks
* Event-loop programming
Audience
The following people are likely to find the workshop of particular benefit:
- Programmers developing system-level applications for Linux systems, or programmers porting such applications from other operating systems (e.g., Windows) to Linux.
- Embedded programmers developing applications for Linux, or porting embedded applications from systems such as VxWorks or QNX to Linux.
- DevOps engineers and sytem administrators who want to gain a greater insight into the oepration of Linux applications.
Format
The workshop consists of a mixture of detailed presentations coupled with many coding exercises that allow participants to apply the knowledge learned in the presentations.
Prerequisites
- You should have a good reading knowledge of C or C++. For the practical sessions, templates will be provided to relieve you of the need to type in tedious boilerplate code. The templates are in C, but if you wish, it is also possible to complete the exercises in another suitable language such as D, Rust, or of course C++.
- You should have a basic familiarity with the Linux/UNIX command line to do tasks such as listing directories, editing files, and compiling programs.
- No previous system programming experience is assumed.
Computer Setup
You'll need a laptop with Linux installed--either as a native install or inside a virtual machine (VM). In the latter case, you should ensure that the VM has working Internet access. The system should have a C compiler (e.g., gcc) and "make" installed. (It's likely that both of these are provided as part of the default install, if you are setting up a new system.)