Skip to content

About

This repository documents the step-by-step development of a custom xv6 operating system. Starting from a basic kernel, we iteratively added advanced features like hybrid scheduling , priority-based locking , and software demand paging. The final iteration serves as a comprehensive kernel.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

132 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Enhanced xv6 Operating System

This repository contains all projects and kernel extensions developed for the
Operating Systems Laboratory course,
offered by the School of Electrical and Computer Engineering,
University of Tehran – Fall 2025
.

Overview

Throughout the semester, we took the original, raw version of the MIT xv6 Operating System (x86) and continuously expanded its capabilities. Instead of isolated assignments, this course followed an iterative development model. Each lab built directly upon the previous one.

As a result, the final version of the OS located in the Lab-5 folder is the most complete iteration, containing every feature, system call, and kernel extension developed during the course.

Code Navigation Note: To help reviewers and developers easily identify our modifications, all newly implemented codes and extensions in the source files are denoted with // add or // new comments at the beginning of the respective blocks.

The Complete xv6 (Lab 5 Features)

By the end of the semester, the following major features and subsystems were successfully integrated into the xv6 kernel:

  • Console & Shell Enhancements:
    • Cursor navigation (left/right, jump by word).
    • Advanced text editing (Ctrl + Z undo, substring Select/Copy/Paste with visual highlighting).
    • Tab-autocompletion for user programs and built-in shell commands.
    • Custom boot message displaying contributor names.
  • New System Calls & User Programs:
    • find_sum: Extracts integers from strings and calculates their sum.
    • make_duplicate: In-kernel block-by-block file duplication.
    • show_process_family: Displays a process's parent, siblings, and children.
    • grep_syscall: Kernel-level keyword search within files.
    • Register-based argument passing directly via EBX and ECX.
  • Advanced Process Scheduling:
    • Heterogeneous Core Support: Distinguishes between Performance (P-cores) and Efficiency (E-cores).
    • Hybrid Policies: Round-Robin for E-cores and Preemptive FCFS for P-cores.
    • Load Balancing: Per-CPU ready queues with dynamic "process pushing" to prevent core starvation.
  • Kernel Synchronization:
    • Ownership enforcement for Sleeplocks (prevents unauthorized lock releases).
    • Implementation of a Reader-Writer lock (rwlock) for read-heavy workloads.
    • Per-CPU Lock Profiling (getlockstat) to track contention and spin cycles.
    • Priority-based Lock (plock) to grant resources to the highest-priority waiting process.
  • Memory Management & Paging:
    • Centralized software page table simulating demand paging.
    • Implementation of multiple Page Replacement Algorithms: FIFO, LRU, LFU, and Clock (Second-Chance).
    • Real-time paging statistics tracking (Hit count, Hit ratio, Runtime ticks).

List of Assignments

Lab Project Title Description Link
Lab-1 Introduction to the xv6 Kernel Bootloader analysis, GDB debugging, and implementing smart console navigation, copy-paste, and tab-completion. View
Lab-2 System Call Implementation Adding kernel-level file duplication, process family tracking, and in-kernel string searching (grep). View
Lab-3 Hybrid Scheduling Transitioning from SMP to a heterogeneous architecture with per-CPU queues, Round-Robin, FCFS, and load balancing. View
Lab-4 Synchronization in xv6 Fixing sleeplock ownership, designing a reader-writer lock, per-CPU lock profiling, and building a priority-based lock. View
Lab-5 Memory Management Creating a software page table and evaluating FIFO, LRU, LFU, and Clock page replacement algorithms. View

How to Reproduce and Run

The xv6 operating system requires a standard x86 compilation toolchain and the QEMU emulator.

  1. Install dependencies (Linux/Ubuntu):
    sudo apt-get update
    sudo apt-get install git build-essential gdb gcc-multilib qemu-system-x86

(Note: Ensure your QEMU version is compatible. If using QEMU > 2.6.2, specific Makefile adjustments may be required as noted in the Lab 3 documentation).

  1. Navigate to the desired Lab:

    Example:

    cd Lab-5
    cd xv6-public-master
    

    (We recommend running Lab-5 to experience the fully featured OS).

  2. Compile and Run:

    make clean
    make qemu
    

    (To run with GDB attached for debugging, use make qemu-gdb instead).

  3. Explore:

    Once the QEMU window opens and the shell boots, you can test the new commands (like find_sum, make_duplicate, or use the new Ctrl console shortcuts).

Contributors

Join the Project

Contributions are welcome!

Whether it’s refining the scheduling algorithms, testing new page replacement methods, or expanding the user-level utilities — feel free to open an issue or submit a PR.

License

This repository is licensed under the MIT License.

About

This repository documents the step-by-step development of a custom xv6 operating system. Starting from a basic kernel, we iteratively added advanced features like hybrid scheduling , priority-based locking , and software demand paging. The final iteration serves as a comprehensive kernel.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages