====== Midterm Topics ====== * Operating systems and abstract machines * An OS is software that provides programs with access to an abstract machine * Protection and sharing * Operating system goals * Performance * Robustness (Safety) * Isolation/Protection * Neutrality * Combinations of goals: Safe sharing, Efficient protection... * Big concepts (that come up again and again) * Process * Thread * Race condition * Critical section * Interrupts and disabling interrupts * Polling vs. blocking (interrupts) * Mechanism vs. policy * File descriptors and structures * A single abstraction for (almost) all resource access (Why is this important?) * File descriptors vs. file structures * open, read, write, rename, unlink * File descriptor manipulation: dup2, pipe, close * Processes * Process vs. program * fork, exec, waitpid, exit * Creating a new process * Stack arrangement, heap * File descriptors and file structures * The process hierarchy * Zombie processes * Process descriptors * When a process forks, which parts are shared, copied, or different? * Contents: IDs, accounting, memory, registers, state, event handlers (signals), file resources, other resources * Process state * Running, runnable, sleeping/blocked * Transitions between states * Context switches * Asynchronous event notification and signals * The need (waking up a process that sleeps for an event, killing an uncooperative process) * signal, kill * Threads * Process vs. thread * pthread_create, pthread_join, pthread_exit * Threads, stacks, and shared state (How does pthread_create differ from fork and why?) * Race conditions * User-level threads vs. kernel threads * Scheduling * Goals: Fairness, Progress/Liveness, CPU utilization, Overhead... * Parameters/Preferences, such as priority * Metrics: Wait time, CPU utilization, Turnaround time, Throughput * Jobs (How does a job differ from a process?) * Gantt charts * Cooperative vs. preemptive * Algorithms: First Come First Serve, Shortest Job First, Round Robin, Preemptive Round Robin (with a quantum), Strict Priority, Priority with Aging, Priority with aging and CPU usage discounting * Priority inversion * Real-time scheduling with deadlines: Admission control vs. best-effort * Synchronization * Critical sections and contexts * Atomicity * Mutual exclusion locks * Priority inversion * Hardware atomic operations (e.g., test_and_set, compare_and_swap) * Synchronization primitives: Semaphores, Mutexes Recursive mutexes, Monitors, Read/write locks, Condition variables, Barriers, Bounded buffer/fixed-capacity queue * Lock-free programming * Spinning vs. blocking * Lock contention * Coarse-grained vs. fine-grained locking * Deadlock and deadlock avoidance * The four necessary conditions: Mutual exclusion, Hold and wait, No preemption, Circular wait * Lock ordering * Detection and recovery * Protected mode, I/O interactions, interrupts * Programmed I/O * Direct memory access * Hardware operations that must be privileged