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:
- 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.