High-Performance C11 Systems Programming: Process Management, IPC & Concurrent Data Structures
This repository showcases professional systems programming skills through two focused C11 implementations:
- Mini Shell - Low-level process lifecycle management with multi-stage pipelines, signal handling, and proper resource cleanup
- Thread-Safe Queue - Lock-based producer-consumer coordination achieving ~400K items/sec with per-thread condition variables
β Memory Management - Zero leaks (Valgrind-verified), explicit ownership semantics β Concurrency - C11 threads, mutexes, condition variables, atomic operations β Systems Programming - POSIX signals, fork/exec/pipe, process groups, file descriptor handling β Performance Engineering - Optimized synchronization patterns, throughput benchmarking β Production Readiness - CI/CD pipeline, Docker containerization, comprehensive testing strategy
# Clone the repository
git clone https://github.com/odeliyach/Linux-System-Programming.git
cd Linux-System-Programming
# Build all targets
make all
# Run the shell
./bin/myshell
# Run queue tests
make test# Build container
docker build -t linux-sys-prog .
# Run queue test
docker run --rm linux-sys-prog ./queue_test
# Interactive shell
docker run --rm -it linux-sys-prog ./myshellLinux-System-Programming/
βββ src/ # Source code (new structure)
β βββ shell/ # Mini shell implementation
β β βββ myshell.c # Core shell logic (fork/exec/pipe)
β β βββ shell_main.c # Shell REPL driver
β βββ queue/ # Thread-safe queue
β βββ queue.c # Concurrent FIFO implementation
βββ include/ # Public headers
β βββ queue.h # Queue API
βββ tests/ # Test suites
β βββ queue_test.c # Producer-consumer benchmark
βββ System_Programming_Projects/ # Legacy structure (maintained for compatibility)
βββ docs/ # Documentation (technical analysis, feedback, study plan)
βββ .github/workflows/ # CI/CD pipeline
β βββ ci.yml # Build and test automation
βββ Makefile # Professional build system
βββ Dockerfile # Production container
βββ TESTING.md # Testing strategy and edge cases
βββ README.md # This file
make all # Build all targets (default)
make test # Run test suite
make check # Build and test (CI-friendly)
make debug # Build with debug symbols (-g -O0)
make clean # Remove build artifacts
make install # Install to PREFIX (default: /usr/local)
make help # Show all targets-std=c11- C11 standard compliance-Wall -Wextra -Werror- Strict warnings as errors-O2- Optimization level 2 (release builds)-pthread- POSIX threads support
| Configuration | Items | Elapsed | Throughput | Notes |
|---|---|---|---|---|
| 2P / 2C baseline | 100 | 0.0002s | 447K items/s | Per-thread condition variables |
| 4P / 4C stress | 400 | 0.0009s | 444K items/s | Scales linearly with threads |
Hardware: Ubuntu 22.04, Intel Xeon (GitHub Actions runner)
Key Optimization: Direct producer-to-consumer handoff via per-waiter condition variables reduces context switches compared to broadcast wakeups.
Capabilities:
- Multi-stage pipelines (up to 10 commands)
- Input/output redirection (
<,>) - Background execution (
&) - Proper signal handling (SIGINT, SIGCHLD)
- Zombie process prevention
Architecture:
prepare() β Install signal handlers (SIGINT ignore, SIGCHLD reaper)
process_arglist() β Fork/exec with pipe() + dup2() wiring
finalize() β Restore default signal dispositions
Signal Handling Strategy:
- Parent ignores SIGINT (Ctrl+C) β children inherit default handler
- SIGCHLD handler with
waitpid(WNOHANG)prevents zombie accumulation SA_RESTARTflag resumes interrupted syscalls automatically
Example Usage:
./bin/myshell
> ls -l | grep .c | wc -l
> cat input.txt | sort > output.txt
> sleep 10 &Design:
- Dual-queue architecture (item queue + per-thread wait queue)
- Single mutex protects both queues (simple critical section)
- Per-consumer condition variables (eliminates thundering herd)
- Lock-free atomic counter for throughput telemetry
API:
void initQueue(void); // Initialize synchronization primitives
int enqueue(void *item); // Add item (wakes waiting consumer if present)
void *dequeue(void); // Remove item (blocks if empty)
size_t visited(void); // Non-blocking throughput query
void destroyQueue(void); // CleanupSynchronization Pattern:
- Consumer arrives first β parks on unique
cnd_tin wait queue - Producer enqueues β directly hands off item to waiting consumer
- No waiting consumers β append to item queue
- Fast path: consumer grabs from item queue without blocking
Performance Notes:
memory_order_relaxedfor atomic counter (no barriers needed for telemetry)- Avoids global condition variable broadcasts (O(1) wakeups)
# Run all tests
make test
# Memory leak check (requires Valgrind)
make debug
valgrind --leak-check=full ./bin/queue_test
# Thread safety check
valgrind --tool=helgrind ./bin/queue_test| Component | Test Case | Status |
|---|---|---|
| Queue | Concurrent enqueue/dequeue | β Covered |
| Queue | Multiple producers, empty queue | β Covered |
| Queue | Throughput validation | β Covered |
| Shell | Zombie prevention (SIGCHLD) | β Manual test |
| Shell | FD cleanup in pipelines | β Code review |
| Shell | SIGINT delegation | β Manual test |
See TESTING.md for comprehensive edge case analysis and testing philosophy.
"I built a minimal shell and thread-safe queue in pure C11 to demonstrate low-level systems expertise. The shell handles multi-stage pipelines with proper signal semantics, while the queue achieves ~400K items/sec using per-thread condition variablesβa pattern I saw in production databases. Both emphasize correct resource management and pragmatic design."
- Race condition prevention (mutex + per-thread condition variables)
- Signal handling semantics (SIGINT, SIGCHLD, SA_RESTART)
- Debugging deadlocks (GDB, Valgrind, lock ordering)
- Memory management (ownership rules, Valgrind verification)
- Performance trade-offs (mutex vs. lock-free, batch operations)
See TECHNICAL_ANALYSIS.md for in-depth Q&A and behavioral interview strategies.
- clang-format: Consistent code style (
.clang-formatincluded) - Compiler warnings: Zero warnings with
-Wall -Wextra -Werror - Valgrind: Memory leak and race condition verification
GitHub Actions workflow (.github/workflows/ci.yml):
- Build verification (both legacy and new structure)
- Automated test execution
- Executable validation
- Code formatting check (clang-format)
# Build stage: Compile with full toolchain
FROM gcc:11-bullseye AS builder
COPY . /build
RUN make clean && make all && make test
# Runtime stage: Minimal Debian with non-root user
FROM debian:bullseye-slim
COPY --from=builder /build/bin/* /app/
USER sysuserImage Size: ~80MB (minimal runtime dependencies)
- README.md - This file (overview, quick start, architecture)
- TESTING.md - Edge cases, test strategy, debugging guide
- TECHNICAL_ANALYSIS.md - Technical Q&A, elevator pitch, behavioral prep
- CV_FEEDBACK.md - Technical recruiter analysis (language recommendations)
All source files include Doxygen-style comments with @brief, @param, and @return annotations.
| Component | Limitation | Production Fix |
|---|---|---|
| Queue | Unbounded capacity | Add max size + backpressure |
| Queue | Destroy during active use is unsafe | Reference counting or shutdown flag |
| Shell | No job control (fg/bg) |
Process groups with setpgid() |
| Shell | Limited error propagation in pipelines | Per-stage exit status tracking |
Design Philosophy: This project demonstrates foundational systems knowledge. I prioritized correctness and clarity over feature completeness, showing I can build the core mechanisms before adding complexity.
- Non-root Docker execution: Container runs as
sysuser(UID 1000) - No shell injection vectors: Uses
execvp()directly, nosystem()calls - Resource limits: Recommended to add
ulimitfor production (max FDs, max processes)
This is a portfolio project, but feedback is welcome! If you spot a bug or have suggestions:
- Open an issue describing the problem
- Include steps to reproduce
- For code contributions, ensure
make checkpasses
This repository is for portfolio and educational purposes only. If you are a student currently taking an Operating Systems course, copying this code violates academic integrity policies. I do not take responsibility for disciplinary actions against individuals who misuse this code.
This project is licensed under the MIT License - see LICENSE file for details.