diff --git a/.gallery/demand-paging.png b/.gallery/demand-paging.png new file mode 100644 index 0000000..bc72084 Binary files /dev/null and b/.gallery/demand-paging.png differ diff --git a/.gallery/disk-scheduling.png b/.gallery/disk-scheduling.png new file mode 100644 index 0000000..3cce608 Binary files /dev/null and b/.gallery/disk-scheduling.png differ diff --git a/.gallery/gallery.py b/.gallery/gallery.py new file mode 100644 index 0000000..b6379bc --- /dev/null +++ b/.gallery/gallery.py @@ -0,0 +1,46 @@ +import json +import os +import subprocess + + +def compile(root_path): + subprocess.run([ + "typst", + "c", + "--root="+root_path, + os.path.join(root_path, ".gallery", "gallery.typ"), + os.path.join(root_path, ".gallery", "page-{n}.png") + ]) + + +def query(root_path): + proc = subprocess.run([ + "typst", + "query", + "--root="+root_path, + os.path.join(root_path, ".gallery", "gallery.typ"), + "metadata" + ], capture_output=True) + return json.loads(proc.stdout) + + +def main(): + root_path = os.path.abspath( + os.path.join( + os.path.dirname(__file__), + os.path.pardir + ) + ) + + compile(root_path) + metadata = query(root_path) + for entry in metadata: + name = entry["value"]["name"] + page = entry["value"]["page"] + from_path = os.path.join(root_path, ".gallery", f"page-{page}.png") + to_path = os.path.join(root_path, ".gallery", f"{name}.png") + os.rename(from_path, to_path) + + +if __name__ == "__main__": + main() diff --git a/.gallery/gallery.typ b/.gallery/gallery.typ new file mode 100644 index 0000000..88f205b --- /dev/null +++ b/.gallery/gallery.typ @@ -0,0 +1,63 @@ +#set page(height: auto, margin: 1cm) +#set text(font: "Source Sans 3") + +#let subject(name) = context { + metadata((name: name, page: locate(here()).page())) +} + +////////////////////////// +// Process Scheduling // +////////////////////////// +#subject("process-scheduling") +#import "/process-scheduling/utils.typ": task, display-processes +#import "/process-scheduling/algorithms.typ": FCFS +#let tasks = { + task(1, 0, 10, 3) + task(2, 20, 40, 2) + task(3, 30, 20, 2) + task(4, 60, 10, 3) + task(5, 80, 30, 1) + task(6, 90, 20, 1) + task(7, 100, 50, 3) + task(8, 130, 30, 2) + task(9, 180, 10, 3) + task(10, 200, 60, 1) +} +#display-processes(..FCFS(tasks)) +#pagebreak() + +///////////////////// +// Demand Paging // +///////////////////// +#subject("demand-paging") +#import "/demand-paging/utils.typ": sim-demand-paging +#set page(width: auto) +#let requests = (7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0 , 1) +#sim-demand-paging(requests, "FIFO") +#pagebreak() + +/////////////////////// +// Disk Scheduling // +/////////////////////// +#subject("disk-scheduling") +#import "/disk-scheduling/algorithms.typ": schedule-fcfs +#import "/disk-scheduling/utils.typ": draw-algo, compute-total + +#let places = (53, 98, 193, 37, 14, 124, 65, 67) +#let min = 0 +#let max = 199 + +#let result = schedule-fcfs(places) +#let graph = draw-algo(result, min: min, max: max, width: 10) +#let compute-total = compute-total.with(min: min, max: max) + +#table( + columns: 2, + inset: 0.5em, + align: center + horizon, + rotate( + -90deg, + reflow: true + )[*FCFS* (total: #compute-total(result, wrap: false))], + graph +) \ No newline at end of file diff --git a/.gallery/process-scheduling.png b/.gallery/process-scheduling.png new file mode 100644 index 0000000..31f635b Binary files /dev/null and b/.gallery/process-scheduling.png differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..cde52e9 --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +# Tasty TacOS + +This repo compiles some visualizations of algorithms from the OS course. + +Here is a little showcase of the different kinds of algorithms in the repo + +## Process scheduling + + +[See more](process-scheduling/) + +## Demand paging + + +[See more](demand-paging/) + +## Disk scheduling + + +[See more](disk-scheduling/) diff --git a/demand-paging/main.pdf b/demand-paging/main.pdf index 783f98d..dcf2d06 100644 Binary files a/demand-paging/main.pdf and b/demand-paging/main.pdf differ diff --git a/disk-scheduling/main.pdf b/disk-scheduling/main.pdf index cd152e9..e06f386 100644 Binary files a/disk-scheduling/main.pdf and b/disk-scheduling/main.pdf differ diff --git a/process-scheduling/main.pdf b/process-scheduling/main.pdf index 96f8202..f33502f 100644 Binary files a/process-scheduling/main.pdf and b/process-scheduling/main.pdf differ