Skip to content
Snippets Groups Projects
Commit 12b2ae56 authored by GAURAV BATRA's avatar GAURAV BATRA
Browse files

chore: updated README.md

parent 1980cfab
No related branches found
No related tags found
No related merge requests found
---
title: CS 537 Project 4
layout: default
---
Name: Gaurav Batra, Thilak Raj Murugan
CS Login: gbatra, thilakraj
Wisc ID: 9087090024, 9086689685
Email: gbatra3@wisc.edu, thilakraj.murugan@wisc.edu
I have completed all the parts of the question.
### Implementation details:
- [x] implemented a stride scheduler
- [x] updated proc struct to store variables
- [x] update local and global variables on the following transitions:
- [x] process creation (allocproc)
- [x] process deletion (exit)
- [x] process sleep (sleep)
- [x] process wakeup (wakeup1)
- [x] each tick (whenever a trap occurs)
- [x] implemented a syscall to settickets
- [x] implemented a syscall to getpinfo
# Dynamic Stride Scheduler for xv6
**Authors**:
- **Gaurav Batra** (CS Login: `gbatra`, Wisc ID: 9087090024, Email: [gbatra3@wisc.edu](mailto:gbatra3@wisc.edu))
- **Thilak Raj Murugan** (CS Login: `thilakraj`, Wisc ID: 9086689685, Email: [thilakraj.murugan@wisc.edu](mailto:thilakraj.murugan@wisc.edu))
## Project Overview
This project implements a **Dynamic Stride Scheduler** in the xv6 operating system, featuring dynamic ticket allocation for fair and deterministic CPU scheduling. The stride scheduler ensures that processes receive CPU time proportional to their tickets while adapting dynamically to changes in process workloads and states.
## Key Features
- **Dynamic Stride Scheduling**: Proportional share resource management with deterministic behavior.
- **Dynamic Ticket Modification**: Processes can adjust their ticket allocation during execution.
- **New System Calls**:
- `settickets(int n)`: Dynamically set the number of tickets for a process.
- `getpinfo(struct pstat*)`: Retrieve scheduling statistics for all processes.
- **Global and Process-Specific Variables**:
- **Global Variables**: `global_tickets`, `global_stride`, and `global_pass` ensure fair scheduling across all processes.
- **Process Variables**: `tickets`, `stride`, `pass`, and `remain` are maintained and updated dynamically.
## Implementation Details
### Process State Transitions
The scheduler updates local and global variables during the following events:
- **Process Creation** (`allocproc`)
- **Process Deletion** (`exit`)
- **Process Sleep** (`sleep`)
- **Process Wakeup** (`wakeup1`)
- **Timer Interrupt** (each tick via `trap`)
### Stride Scheduler Design
1. **Stride Calculation**: `stride = STRIDE1 / tickets` (where `STRIDE1 = 1 << 10`)
2. **Process Selection**: Scheduler selects the process with the **lowest `pass` value**.
3. **Dynamic Participation**: Adjusts `global_pass` and `remain` for processes entering or leaving the scheduler queue.
4. **Fairness Mechanism**: Ensures processes are scheduled proportionally based on their tickets.
### Tie-breaking Rules
If multiple processes have the same `pass` value:
1. Schedule the process with the **lowest total runtime**.
2. If runtime is also equal, fall back on **process ID (PID)**.
### System Calls
- `int settickets(int n)`:
Adjust a process's ticket allocation dynamically. Ticket limits:
- **Maximum**: `1 << 5`
- **Minimum**: `1` (Default: `8` for new processes)
- `int getpinfo(struct pstat*)`:
Retrieve scheduling information using the following struct:
```c
struct pstat {
int inuse[NPROC]; // Process slot usage (1: in use, 0: free)
int tickets[NPROC]; // Ticket count for each process
int pid[NPROC]; // Process IDs
int pass[NPROC]; // Pass values
int remain[NPROC]; // Remain values
int stride[NPROC]; // Stride values
int rtime[NPROC]; // Total runtime
};
```
## Results and Analysis
### Workload Comparison
We evaluated the **RR scheduler** and the **Stride scheduler** using a CPU-intensive workload. Data was collected in the following CSV files:
- `rr_process_stats.csv`
- `stride_process_stats.csv`
### Observations
- Stride scheduling ensures deterministic proportional resource allocation.
- Dynamic ticket modification and process participation maintain fairness, even when new processes enter the system.
- **Key Insight**: Processes with more tickets receive CPU time faster, while those with fewer tickets experience proportional delays.
### Advantage of Stride Scheduling
- Predictable CPU sharing for processes with varying priorities.
- Dynamic adaptation to workload changes ensures efficiency and fairness.
## How to Run
1. **RR Scheduler**:
```bash
make qemu-nox
```
Run workload:
```bash
workload &
cat rr_process_stats.csv
```
2. **Stride Scheduler**:
```bash
make qemu-nox SCHEDULER=STRIDE
```
Run workload:
```bash
workload &
cat stride_process_stats.csv
```
## Submission Structure
```
p4/
├── README.md
├── solution/
├── tests/
├── rr_process_stats.csv
├── stride_process_stats.csv
├── partners.txt
└── slipdays.txt (optional)
```
## References
1. [Stride Scheduling: Deterministic Proportional-Share Resource Management](https://pdos.csail.mit.edu/6.828/2016/xv6.html) by Carl A. Waldspurger and William E. Weihl.
2. [Scheduling Concepts in xv6 (YouTube)](https://www.youtube.com/watch?v=eYfeOT1QYmg)
## Administrivia
- **Due Date**: November 5, 2024, by 11:59 PM
- **Slip Days**: Each partner has two slip days for late submissions.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment