Introduction to XINU operating system kernel programming, implementing low-level x86 assembly operations, process stack inspection, and system call tracing with statistical tracking across 27 system calls.
- Assembly Programming: Bitwise operations implemented entirely in x86 assembly (
zfunction) - Process Stack Analysis: Inspection and reporting of process stack information including base, limit, size, and pointer
- System Call Tracing: Comprehensive tracking of 27 system calls with frequency counts and average execution time per process
- Statistical Analysis: Start/stop tracing mechanism with per-process syscall summaries
- LTTng-inspired Design: Loosely based on Linux Trace Toolkit Next Generation functionality
h/lab0.h- Header file exposing task functionssys/zfunction.S- Task 1: x86 assembly bitwise operationssys/printprocstks.c- Task 2: Process stack information displaysys/printsyscallsummary.c- Task 3: System call tracing and summary (includessyscallsummary_start()andsyscallsummary_stop())
All system calls modified to add tracing hooks:
sys/freemem.c,sys/chprio.c,sys/getpid.c,sys/getprio.c,sys/gettime.csys/kill.c,sys/receive.c,sys/recvclr.c,sys/recvtim.c,sys/resume.csys/scount.c,sys/sdelete.c,sys/send.c,sys/setdev.c,sys/setnok.csys/screate.c,sys/signal.c,sys/signaln.c,sys/sleep.c,sys/sleep10.csys/sleep100.c,sys/sleep1000.c,sys/sreset.c,sys/stacktrace.c,sys/suspend.csys/unsleep.c,sys/wait.c
compile/Makefile- Added new source files to build
cd compile
make depend # First time only or after Makefile changes
makeThis creates the XINU kernel image xinu.elf.
cd compile
make runTo exit QEMU: Press Ctrl-a then c, then type q at the (qemu) prompt.
In one terminal:
cd compile
make debugIn another terminal:
gdb xinu.elf
(gdb) target remote localhost:1234
(gdb) b main
(gdb) ccd compile
make cleanTask 1 (zfunction)
0xaabbccdd => 0xbbc00dff
Operations performed:
- Clear bits 20-27 (counting from left, starting at 0)
- Shift left by 8 bits
- Fill rightmost 8 bits with 1s
Task 2 (printprocstks)
Process [main]
pid: 49
priority: 20
base: 0x00ff0ff0
limit: 0x00ffffff
len: 4096
pointer: 0x00ffff33
Displays stack information for all processes with priority greater than the specified parameter.
Task 3 (printsyscallsummary)
Process [pid:49]
Syscall: sys_sleep, count: 1, average execution time: 5000 (ms)
Shows frequency and average execution time of all traced system calls, grouped by process.
- Assembly requirement:
zfunction()must be written entirely in x86 assembly (.Sfile, not inline assembly) - Stack pointer access: Uses inline assembly to read
%espregister for current process - Time measurement: Uses global variable
ctr1000(millisecond counter) - Process table: Accesses
proctab[]array for process information - System calls traced: 27 out of 43 declared system calls
- Tracing window: Only syscalls between
syscallsummary_start()andsyscallsummary_stop()are recorded - Process tracking: Includes terminated processes in the summary
- Main.c warning: Test programs should not be in
main.cas it will be replaced during grading - Debug output: Must be disabled before submission
- Platform: XINU+QEMU VCL image (CSC501)
- Storage: NC State Drive (
/mnt/ncsudrive/) - Architecture: x86 (32-bit)
- Assembler: GNU Assembler (AT&T syntax)
- Debugger: GDB with remote target support
This project was completed as part of the graduate-level Operating Systems course (Fall 2025), CSC 501: Operating Systems Principles, at North Carolina State University, instructed by Prof. Man-Ki Yoon.
- See ASSIGNMENT.md for complete project specification
- XINU Source Documentation
- AT&T Assembly Syntax
- Intel 64 and IA-32 Software Developer's Manual
- GDB Documentation