Kernel-level enhancements to the xv6 RISC-V operating system completed as part of CS3523 (Operating Systems II) at IIT Hyderabad.
This repository documents the design, implementation, and evaluation of a series of operating system extensions covering process management, CPU scheduling, virtual memory, and kernel accounting.
This repository contains documentation, design decisions, implementation summaries, architecture diagrams, and experimental results from a series of operating systems assignments completed as part of CS3523 (Operating Systems II) at IIT Hyderabad. Source code is not included.
xv6 is a small Unix-like teaching operating system originally developed by MIT's PDOS (Parallel and Distributed Operating Systems) group. It is widely used in operating systems courses to help students understand kernel internals and core OS concepts through direct implementation and experimentation.
The RISC-V version of xv6 provides a simplified but realistic operating system codebase covering:
- Process Management
- System Calls
- CPU Scheduling
- Virtual Memory
- Page Tables
- Trap Handling
- File Systems
- Synchronization
Unlike application-level development, working with xv6 requires modifying kernel-space components and reasoning about low-level operating system behavior, correctness, and performance.
This project was completed as part of CS3523: Operating Systems II at Indian Institute of Technology Hyderabad under the guidance of Prof. Abhijit Das.
The project consisted of three progressively connected programming assignments built on top of the xv6 RISC-V operating system. Each assignment extended the functionality implemented in the previous one, resulting in a significantly enhanced operating system supporting advanced process accounting, scheduling, and virtual memory management features.
Programming Assignment 01
- Custom System Calls
- Parent-Child Process Relationships
- Per-Process System Call Accounting
Programming Assignment 02
- System-Call-Aware Multi-Level Feedback Queue (SC-MLFQ) Scheduler
- Interactive Workload Detection
- Scheduling Statistics and Runtime Telemetry
Programming Assignment 03
- Scheduler-Aware Virtual Memory Management
- Clock Page Replacement
- Swap Management
- Page Fault Handling and Memory Statistics
Together, these assignments provided hands-on experience working across multiple core operating system subsystems and understanding how scheduling, process management, and virtual memory interact within a kernel.
This project extends the xv6 RISC-V operating system across three major areas:
- Kernel Interface Extensions and Process Accounting
- System-Call-Aware Multi-Level Feedback Queue Scheduling
- Scheduler-Aware Virtual Memory Management
The work involved modifying core kernel subsystems related to:
- Process Management
- System Calls
- CPU Scheduling
- Trap Handling
- Virtual Memory
- Page Fault Handling
- Page Replacement
- Swapping
Implemented multiple kernel system calls for:
- Process identification
- Parent-child process relationships
- Process statistics
- System call accounting
Examples include:
hello()getpid2()getppid()getnumchild()getsyscount()getchildsyscount()
Extended the process control block to maintain:
- Total system calls executed
- Child process statistics
- Runtime accounting information
The accounting system was integrated directly into the xv6 system call dispatch path.
Replaced the default xv6 scheduler with a 4-level SC-MLFQ scheduler featuring:
- Four priority queues
- Fixed time quanta
- Interactive workload detection
- CPU-bound workload demotion
- Global priority boosting
- Runtime scheduling statistics
Interactive processes are identified using system-call activity during a scheduling quantum, allowing the scheduler to distinguish between:
- CPU-bound workloads
- System-call-heavy interactive workloads
Implemented a scheduler-aware virtual memory subsystem featuring:
- Global frame table
- Clock page replacement algorithm
- Swap space management
- Page fault handling
- Swap-in / swap-out support
- Memory statistics tracking
The replacement policy integrates scheduling information from SC-MLFQ to preferentially preserve the working sets of higher-priority interactive processes.
Implemented:
- Kernel-to-user system call plumbing
- Parent-child process relationship queries
- Per-process system call counters
- Child process statistics retrieval
Concepts explored:
- System call dispatching
- Kernel data structures
- Process table traversal
- Locking and synchronization
- Process metadata management
Implemented:
- Four-level MLFQ scheduler
- Runtime workload classification
- Interactive process retention
- CPU-bound process demotion
- Global starvation prevention
Key scheduling policies:
| Queue Level | Time Quantum |
|---|---|
| Level 0 | 2 Ticks |
| Level 1 | 4 Ticks |
| Level 2 | 8 Ticks |
| Level 3 | 16 Ticks |
Additional system calls:
getlevel()getmlfqinfo()
Experimental workloads demonstrated:
- CPU-bound task demotion
- Interactive task retention
- Starvation prevention through priority boosting
Implemented:
- Global frame tracking
- Clock page replacement
- In-memory swap management
- Scheduler-aware victim selection
- Virtual memory statistics
Additional system call:
getvmstats()
Features:
- Lazy allocation support
- Page fault tracking
- Swap-in / swap-out accounting
- Resident page monitoring
Experimental evaluation verified:
- Correct eviction behavior
- Successful page restoration
- Data integrity after swapping
- Scheduler-aware replacement decisions
Extending_xv6
│
├── README.md
│
├── reports
│ ├── PA1_System_Calls.pdf
│ ├── PA2_SC_MLFQ.pdf
│ └── PA3_Virtual_Memory.pdf
│
├── diagrams
│ ├── syscall-accounting.png
│ ├── sc-mlfq-architecture.png
│ ├── page-replacement-flow.png
│ └── scheduler-aware-eviction.png
│
├── screenshots
│ ├── pa1-tests.png
│ ├── pa2-workload-results.png
│ └── pa3-memory-stats.png
│
└── implementation-summary.md
Through this project I gained hands-on experience with:
- Operating System Internals
- Kernel Development
- CPU Scheduling
- Process Management
- Virtual Memory
- Page Replacement Algorithms
- Swapping Mechanisms
- Trap Handling
- RISC-V Architecture
- Kernel Synchronization
- Performance Analysis
- C
- xv6 RISC-V
- QEMU
- Linux
- Operating Systems Concepts
- CPU Scheduling
- Virtual Memory Systems
Atul Boyal Computer Science & Engineering Indian Institute of Technology Hyderabad