← All projects

KernelWare

WarioWare-style micro-game engine where the game logic runs inside a Linux kernel module instead of userspace.

Problem

For Dr. Mark Burkley's CS4422 course we needed to build something non-trivial with a Linux kernel module. Our idea was a WarioWare-style micro-game engine, but with the game logic actually running inside the kernel rather than in userspace.

Role

Team of four. Aidan, Cathal, Tom and me.

How it works

The kernel module lives in driver/kernelware_main.c and exposes /dev/kernelware as a character device. Userspace spawns three pthreads: input_thread reads raw key events (with an SSH stdin fallback), render_thread draws the ncurses HUD at around 20fps, and game_thread runs each mini-game's blocking run(). They talk to the kernel through write(), read() on a waitqueue, and ioctls (START, STOP, GET_STATE, SET_DIFF).

Inside the kernel, kw_state.c keeps state consistent under a spinlock and an hrtimer counts down each round. Seven mini-games, including Kill It (spawns a child and validates the PID before sending SIGKILL), Memory Leak (tracks live kmalloc), Load Balancer (spawns three kthreads), and Hack the Host (overwrites the real system hostname through init_uts_ns). Difficulty ramps by shrinking the round timer 10% every three wins, floored at 2 seconds.

Stack
Coursework C Linux Kernel Module Character Device Driver hrtimer kthreads spinlocks ncurses pthreads proc filesystem
Result

Complete and playable via QuickStart.sh. All seven games, the difficulty ramp, and the shared ioctl protocol between kernel and userspace all working.