This project implements a basic container runtime in C using core Linux concepts:
- Process isolation (namespaces)
- Resource control (cgroups)
- Kernel monitoring (custom module)
It simulates how tools like Docker manage containers at a low level.
-
Create and manage containers using a custom
engine -
Memory limit enforcement (soft & hard limits)
-
CPU scheduling using
nicevalues -
Kernel-level monitoring using a custom module
-
Logging system for each container
-
Stress tools:
cpu_hog(CPU intensive)memory_hog(memory intensive)
boilerplate/
├── engine.c # Container runtime
├── monitor.c # Kernel monitoring logic
├── monitor_mod.c # Kernel module interface
├── monitor_ioctl.h # Communication (ioctl)
├── cpu_hog.c # CPU stress program
├── memory_hog.c # Memory stress program
├── Makefile # Build instructions
├── rootfs-alpha/ # Container filesystem (alpha)
├── rootfs-beta/ # Container filesystem (beta)
├── logs/ # Container logs
makesudo insmod monitor.kosudo ./engine supervisor ../rootfs-basesudo ./engine start alpha ../rootfs-alpha /cpu_hog --nice -5
sudo ./engine start beta ../rootfs-beta /cpu_hog --nice 10sudo ./engine psView logs:
sudo ./engine logs alpha
sudo ./engine logs betaStop containers:
sudo ./engine stop alpha
sudo ./engine stop betagcc -static -o memory_hog memory_hog.c
sudo cp memory_hog ./rootfs-alpha/
sudo cp memory_hog ./rootfs-beta/
sudo ./engine start alpha ./rootfs-alpha /memory_hog --soft-mib 10 --hard-mib 30
sudo ./engine start beta ./rootfs-beta /memory_hog --soft-mib 10 --hard-mib 30gcc -static -o cpu_hog cpu_hog.c
sudo cp cpu_hog ./rootfs-alpha/
sudo cp cpu_hog ./rootfs-beta/
sudo ./engine start alpha ./rootfs-alpha /cpu_hog --nice -5
sudo ./engine start beta ./rootfs-beta /cpu_hog --nice 10
sleep 3
ps -eo pid,ni,%cpu,comm | grep cpu_hogsudo dmesg | grep container_monitorsudo ./engine stop alpha
sudo ./engine stop beta
ps aux | grep defunct
sudo rmmod monitor
sudo dmesg | tail -5- Lower nice value → higher CPU priority
- Memory exceeding soft limit → warning (dmesg)
- Memory exceeding hard limit → process killed
- Some processes may become
<defunct>if not cleaned
Multiple containers (alpha, beta) managed simultaneously by a single supervisor process. This demonstrates concurrent container execution and supervision.
Output of engine ps showing container ID, PID, state (running/exited), and lifecycle information, confirming proper metadata management.
Logs from containers alpha and beta captured via pipe-based IPC and stored independently. This demonstrates the bounded-buffer producer–consumer logging mechanism.
Interaction between CLI and supervisor showing container lifecycle commands (start, stop). Demonstrates IPC-based communication.
Kernel logs showing soft memory limit exceeded. The process continues execution but a warning is generated.
Kernel logs showing enforcement of hard memory limits where the container process is terminated after exceeding allowed memory.
CPU scheduling behavior using different nice values. Lower nice value results in higher CPU priority, validating Linux scheduler behavior.
After stopping containers, no <defunct> (zombie) processes are present. Confirms proper resource cleanup and child process reaping.
clone(),exec(),wait()chroot()for filesystem isolationioctl()for user-kernel communication- Linux scheduling (
nice) - Process states (Running, Zombie, etc.)
- Run commands with
sudowhere required - Kernel module must be loaded before using supervisor
- Avoid committing binaries and logs
##Authors Shriranjini[PES1UG24CS447] Shantheri Shenoy[PES1UG24CS428]








