cs111.stanford.edu Topics CS111 leverages CS107 experience to show operating systems and how they function. What is an operating system operating system sits between hardware and user programs most importantly: manages shared resources to allow the program to run CPU: gets which program to do work and for how long RAM: how much memory to give to a program Hard Drive Main Events concurrency: switch between processes so quickly to only use on core while concurrent access memory: memory addresses are mostly scattered everywhere — everything include the lowest level including CPU uses only virtual memory, translated by the OS file management i/o devices networking: CS144 security: interactions between users in a system Main Components of the Course File Systems Process and Multiprocess Threads Virtual Memory + Paging + limits Modern Technologies/Niceties What’s Next SU-CS111 Outline Content filesystem How can we design file systems to manage files on disk, and what are the tradeoffs inherent in designing them. How can we interact with the filesystem? filesystem Unix V6 Filesystem Freelist and Block Cache disk crash recovery fsck ordered writes journaling: write-ahead logging syscalls kernel mode files handling file file descriptor multiprocessing How are programs run, how to spawn subprograms, and how they work in general? multiprocessing fork execvp waitpid shell pipe and ipc Multithreading How do we implement a single program within a single program, and how do we not have race conditions multithreading processes vs threads race condition and mutex passing by reference permits model busy waiting condition variable Unique Lock trust how do we trust software? trust by assumption trust by inference trust by substitution patterns monitor pattern dispatches assembly review process control block dispatching trap interrupts context switch scheduling preemption virtual memory “how can one set of memory be shared across several processes” virtual memory dynamic address translation demand paging clock algorithm model technologies modern OS trust and OS trust An example of a good time: void main() { // make pipe int fds[2]; pipe(fds); pid_t pidp = fork(); if (pidp == 0) { close(pidp[1]); dup2(pidp[0], STDIN_FILENO); close(pidp[0]); execvp("", ...); // throw-a-tantrum exit(1); } close(pidp[0]); return pidp[1]; }