Skip to content

Conversation

APMuley
Copy link

@APMuley APMuley commented Sep 18, 2025

Priority-Based Scheduler for xv6

Summary

This PR adds a priority-based scheduling algorithm to xv6, along with syscalls to manage and inspect process priorities. It also implements aging and de-aging to prevent starvation.

Changes

  1. Process Structure

    • Added priority, sticks, and wticks for scheduling.
  2. New Syscalls

    • getppid() - returns parent PID
    • getprio() - returns running process priority
    • setprio() - sets current process priority
    • setprioforproc() - sets priority for a specific PID
    • yield() - allows user-space process to yield CPU
    • cprintf_locked() - synchronized printf for console
  3. Priority Scheduler

    • First pass finds process with highest priority
    • Second pass selects process for execution, updates sticks, priorities, and wticks
    • Processes like init() have fixed priority
    • Default priority = 3
    • Implements aging/de-aging to prevent starvation and break ties

Motivation

This PR demonstrates advanced scheduling concepts such as priority scheduling and aging in an educational OS environment. It can be used for learning or experimentation.

Notes

  • All existing functionality is preserved.
  • Extensive testing was performed locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant