Skip to content

devangsaraogi/xinu-kernel-basics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XINU Kernel Basics

Overview

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.

Key Features

  • 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

Files Modified/Created

Created Files

Modified Files (27 System Calls)

All system calls modified to add tracing hooks:

Build Configuration

How to Build and Run

Build

cd compile
make depend  # First time only or after Makefile changes
make

This creates the XINU kernel image xinu.elf.

Run

cd compile
make run

To exit QEMU: Press Ctrl-a then c, then type q at the (qemu) prompt.

Debug

In one terminal:

cd compile
make debug

In another terminal:

gdb xinu.elf
(gdb) target remote localhost:1234
(gdb) b main
(gdb) c

Clean

cd compile
make clean

Expected Results

Task 1: zfunction()

Task 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()

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()

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.

Notes/Assumptions

  • Assembly requirement: zfunction() must be written entirely in x86 assembly (.S file, not inline assembly)
  • Stack pointer access: Uses inline assembly to read %esp register 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() and syscallsummary_stop() are recorded
  • Process tracking: Includes terminated processes in the summary
  • Main.c warning: Test programs should not be in main.c as it will be replaced during grading
  • Debug output: Must be disabled before submission

Development Environment

  • 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

Acknowledgments

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.

Additional Resources

About

An introduction to XINU kernel programming.

Topics

Resources

Stars

Watchers

Forks

Contributors 2

  •  
  •