Linux System Programming
A hands-on repository for learning Linux system programming through practical labs, notes, and quizzes. Twenty labs cover processes, threads, file I/O, filesystems, networking, event loops, terminal job control, services, isolation, diagnostics, and advanced interfaces. Reference implementations use C11 with current POSIX/Linux patterns. The implementation guide separates recommended application patterns, API comparisons, and historical OS models; the learning path connects the topics.

Table of Contents
About
This repository is designed for students and developers who want to gain practical experience with Linux system programming. It covers essential topics including process management, inter-process communication, threading, synchronization mechanisms, and more. Each lab is a separate executable with detailed instructions and shared checked helpers; the notes provide the OS background for the exercises.
Repository Layout
labs/ - programming assignments with main.c and lab-specific README.md
labs/common/ - shared error handling, process cleanup, parsing, and bounded queues
notes/ - course notes, the modern C/POSIX guide, and clearly labeled OS models
tests/ - strict builds, behavioral checks, and Linux fault-injection fixtures
quizzes/ - quick checks and practice questions
LICENSE - MIT license
Labs Overview
Each lab includes a dedicated README with objectives, constraints, and build/run instructions.
| Lab |
Topic |
Core Concepts |
Difficulty |
Est. Time |
| lab1 |
Maze Navigator |
sigaction, self-pipe, poll, complete input |
Beginner |
2-3 hours |
| lab2 |
Forked File Reader |
CLI paths, independent file I/O, child reaping |
Beginner |
1-2 hours |
| lab3 |
Mini Shell |
posix_spawnp, complete lines, checked child status; fork/exec comparison |
Intermediate |
3-4 hours |
| lab4 |
Sleeping Barber |
shared FIFO, per-customer completion, supervised processes |
Advanced |
4-6 hours |
| lab5 |
Text Pipeline |
bounded shared buffers, stream preservation, failure propagation |
Advanced |
4-5 hours |
| lab6 |
Parking Garage |
reserved capacity, per-vehicle gates, phase fairness |
Advanced |
4-6 hours |
| lab7 |
Thread Pool |
reusable workers, bounded queue, explicit closure |
Intermediate |
3-4 hours |
| lab8 |
Restaurant Simulation |
streamed orders, backpressure, monotonic deadlines, final reporting |
Advanced |
4-5 hours |
| lab9 |
Descriptor I/O |
complete binary copies, partial I/O, EINTR, positional offsets |
Intermediate |
2-3 hours |
| lab10 |
Filesystems and Persistence |
descriptor-relative traversal, metadata, links, durable replacement |
Intermediate |
3-4 hours |
| lab11 |
Network and Local Sockets |
TCP/UDP/Unix sockets, framing, timeouts, half-closes |
Intermediate |
3-4 hours |
| lab12 |
Event-driven Server |
nonblocking sockets, epoll, bounded buffers, timer/signal descriptors |
Advanced |
4-6 hours |
| lab13 |
Shell and Terminal Jobs |
pipelines, redirection, process groups, jobs/bg/fg |
Advanced |
5-7 hours |
| lab14 |
Service Lifecycle |
validated reload, graceful stop, logging, systemd readiness |
Intermediate |
3-4 hours |
| lab15 |
Security and Isolation |
credentials, capabilities, limits, seccomp, namespaces, delegated cgroups |
Advanced |
4-6 hours |
| lab16 |
Diagnostics |
strace, GDB, sanitizers, /proc, descriptor accounting |
Intermediate |
2-4 hours |
| lab17 |
C11 Atomics |
relaxed counting, acquire/release publication, lifetime |
Advanced |
3-4 hours |
| lab18 |
Runtime Loading |
shared libraries, versioned C ABI, dlopen/dlsym, unload ownership |
Intermediate |
2-3 hours |
| lab19 |
File-backed Mappings |
private/shared mapping, advisory locks, msync, mprotect |
Advanced |
3-4 hours |
| lab20 |
Optional io_uring |
submission/completion, buffer lifetime, explicit offsets; liburing required |
Advanced |
3-5 hours |
The times are study estimates, including exercises. Follow the
suggested learning order and coverage map rather than
assuming lab numbers are the only prerequisite order. Lab15 reports restricted
optional mechanisms explicitly; lab20 is an optional dependency target.
Notes
Start with Modern C/POSIX Patterns to choose an implementation approach and compare it with older recipes.
The notes/ directory contains comprehensive course materials covering theoretical concepts that complement the hands-on labs:
- Operating Systems - Overview of OS types, responsibilities, and fundamental concepts
- Processes and Threads - Process lifecycle, scheduling, and thread management
- Memory Management - Virtual memory, paging, segmentation, and memory allocation strategies
- Synchronization Tools - Mutexes, semaphores, and other synchronization primitives
- Critical Section Problem - Race conditions, mutual exclusion, and solutions
- Scheduling Algorithms - CPU scheduling policies and algorithms
- Disk Scheduling - Disk I/O optimization and scheduling strategies
- File I/O and Filesystems - Descriptors, metadata, links, permissions, persistence
- Networking and Event Loops - Framing, transports, readiness, bounded state
- Shells and Terminals - Pipelines, process groups, terminal control
- Service Lifecycle - Readiness, logging, configuration reload, shutdown
- Security and Isolation - Credentials, capabilities, seccomp, namespaces, cgroups
- Debugging and Performance - Tracing, debugging, sanitizer and profiling exercises
- Atomics and Memory Order - C11 atomicity and publication protocols
- Dynamic Loading and Mappings - ABI and address ownership
- Asynchronous I/O - io_uring completion model and buffer lifetime
These notes are perfect for reviewing concepts before tackling labs or preparing for exams.
Getting Started
Prerequisites
To work with the labs and examples in this repository, you'll need:
Quick Start
Here's how to get started with your first lab:
# Clone the repository (or your fork)
git clone https://github.com/djeada/Linux-System-Programming.git
cd Linux-System-Programming
# Navigate to lab1
cd labs/lab1
# Read the lab instructions
cat README.md
# Compile the program
gcc -std=c11 -Wall -Wextra -pedantic -o maze main.c -pthread
# Run the program with the provided maze
./maze maze.txt
# Try moving with W, A, S, D keys!
General Build Pattern