CPS: Systems Programming & Embedded Exercises
Systems Programming Exercises — Hands-on C exercises covering algorithms, process management, IPC, file I/O, and dynamic libraries.
Collection of systems programming exercises in C covering fundamental OS concepts: process management (fork, exec, wait), inter-process communication (pipes, shared memory), file I/O, dynamic library creation, and algorithmic problem solving.
🧮 Algorithms & Data Structures
File
Topic
Concepts
ValidMountainArray.c
LeetCode 941
Two-pointer array validation
insertion_sort_list.c
Linked List Sort
Insertion sort on singly linked list
sorting_algorithms.h
Sorting Utilities
Sorting algorithm declarations
File
Topic
Concepts
Exercise_fork_wait_execve.c
Process Creation
fork(), execvp(), wait()
Exercise_find_a_file_in_the_PATH.c
PATH Resolution
PATH env var, access(), execve()
Exercise_super_simple_shell.c
Shell Implementation
Command parsing, builtins, execution
📡 Inter-Process Communication (IPC)
File
Topic
Concepts
pipe.c
Unnamed Pipes
pipe(), fork(), read(), write()
cdl.c
Dynamic Library Loading
dlopen(), dlsym(), dlclose()
functionpointers.c
Function Pointers
Callback patterns, qsort comparator
File
Topic
Concepts
fileio.c
File I/O
open(), read(), write(), lseek(), close()
fileio.c
File Operations
stat(), fstat(), permissions
exec.c
Exec Family
execl(), execv(), execle(), execve()
unsetenv.c
Environment
unsetenv(), getenv(), setenv()
oflags.md
Open Flags
O_RDONLY, O_WRONLY, O_CREAT, O_APPEND
stat.md
File Status
stat(), S_IFMT, S_IRUSR, etc.
🧵 Concurrency & Synchronization
File
Topic
Concepts
stack.c
Stack Implementation
Linked list stack, push/pop
split.c
String Splitting
strtok(), custom delimiters
msprintf.c
Custom printf
Variadic functions, format parsing
randnums.c
Random Numbers
rand(), srand(), /dev/urandom
File
Topic
Concepts
100-tests.py
C-Python FFI
ctypes, shared library loading
Category
Technologies
Language
C (C89/gnu89 standard)
Compiler
gcc -Wall -Wextra -Werror -pedantic -std=c89
Build
Makefiles, manual compilation
Debugging
gdb, valgrind
Dynamic Loading
libdl (dlopen, dlsym)
Python FFI
ctypes
git clone https://github.com/oovaa/cps.git
cd cps
# Compile a specific exercise
gcc -Wall -Wextra -Werror -pedantic -std=c89 ValidMountainArray.c -o mountain
./mountain
# Compile with dynamic library
gcc -shared -fPIC -o dlib.so functionpointers.c
python3 100-tests.py
# Compile pipe exercise
gcc -Wall -Wextra -Werror -pedantic -std=c89 pipe.c -o pipe
./pipe
# Compile with debug symbols
gcc -g -Wall -Wextra -Werror -pedantic -std=c89 Exercise_fork_wait_execve.c -o shell
# Debug with GDB
gdb ./shell
# Memory leak check
valgrind --leak-check=full --show-leak-kinds=all ./pipe
✅ Process Management : fork(), exec(), wait(), waitpid(), zombie/orphan handling
✅ IPC Mechanisms : Pipes (unnamed/named), shared memory, signals
✅ Dynamic Loading : dlopen(), dlsym(), dlclose(), plugin architectures
✅ File I/O : Low-level open/read/write/lseek/close vs stdio
✅ Environment Management : getenv, setenv, unsetenv, PATH resolution
✅ Shell Implementation : Command parsing, builtins, pipeline execution
✅ Memory Management : Manual allocation, leak detection with Valgrind
✅ C-Python FFI : ctypes for calling C from Python
cps/
├── *.c # C exercise files
├── *.h # Header files
├── *.md # Documentation (oflags.md, stat.md)
├── *.py # Python test scripts
├── Makefile # Build automation (if present)
├── dlib.so # Dynamic library (built)
├── LICENSE
└── README.md
MIT License - see LICENSE for details.
Omar Abdulrahim
GitHub: @oovaa