an assignment of all time
Find a file
foreverpyrite 25b3365d4a Initial (and likely only) commit
This was a fun lil project.
If only I didn't waste so much time on the parts that don't matter
though.
2026-04-03 00:23:32 -04:00
src Initial (and likely only) commit 2026-04-03 00:23:32 -04:00
.gitignore Initial (and likely only) commit 2026-04-03 00:23:32 -04:00
Cargo.lock Initial (and likely only) commit 2026-04-03 00:23:32 -04:00
Cargo.toml Initial (and likely only) commit 2026-04-03 00:23:32 -04:00
gen-dummy-input.py Initial (and likely only) commit 2026-04-03 00:23:32 -04:00
README.md Initial (and likely only) commit 2026-04-03 00:23:32 -04:00

cpu-scheduler

I did way more than I needed to for this, but it was fun and that's what matters.

What I've done

  • Met assignment requirements
  • Allow for user specification of time quantum
  • Created validation logic for all command line arguments
  • Supported the usage of stdin for cpu-scheduler (on unix-like systems)
  • Created a python script to create input files
    • Writes to stdin of course, so can be piped to cpu-scheduler or output redirected
  • Crashed out trying to write this in C using strtok after seeing it in the LSP while writing my own parsing logic
    • The byproducts of this include the entire absurdity of ./src/process.rs
  • Unnecessary project structure
  • Way too many log messages
  • Commented pretty much every line which probably would make no sense to anyone else
  • Made a README.md file and published it to my Git remote

What I could do but never will

  • Analyse the output to make sure it works exactly as expected
  • Verbose flag
  • Optimise (parse processes from file as they "arrive", less bindings, ect)
  • Write it in C (die strtok)

Assignment:

Computer Science 4327 Homework #3

You are to implement a simple uni-processor scheduling simulator. Your simulator will step through a sequence of time units, performing the actions of a simple operating system scheduler.

The main input to your simulator will be a file containing process-information. Each line in the file will be of the form: Arrive Priority CPU_Time

Examples: process that arrives at time 10, has a priority of 5 and has one CPU burst of duration 8:

0 5 8

process that arrives at time 12, has a priority of 8 and has a CPU burst of duration 72:

2 8 72

An example of a complete input file is given below. It contains each of the above three processes with first line containing a single value indicating how many processes there are:

3
0 5 8
2 8 72
5 7 2

Some helpful notes/limitations:

  1. Arrival times will be strictly increasing in the input file.
  2. Your program should accept any valid input file
  3. There will be at most 100 processes.
  4. Lower numbers imply higher priority, with the highest priority a 0 and the lowest priority a 9.

Your scheduler should be a preemptive priority scheduler with round-robin as a secondary scheduling criteria. The best solution will allow the user to vary the time quantum but a default of 2 should be used for quantum.

Include enough output of your program to show processes being dispatched, preempted, completed, etc. At the end of the simulation, output the turnaround time for each process as well as average turnaround time.