Operating systems study outline (not intended to be exhaustive) ------------------------------- Chapter 1 --------- Bootstrap program in ROM to load OS instruction execution: fetch, decode, execute program execution: compile, link, load, execute instructions may execute in either User mode or Kernel mode Chapter 2 --------- How do people run programs on a computer? turn it on, run the program, turn it off batch command-line shell GUI shell Two types of OS services for user: e.g. shell, file system, I/O internal: e.g. accounting, security, manage resources System call: "an interface for accessing an OS service within a computer program" System program: command you invoke at the shell OS design: decide on policies, then the mechanisms Implementation mostly in HLL, some in assembly Monolithic kernel: Kernel is the entire OS Microkernel: Kernel is that part of the OS that is always "awake" Chapter 3 --------- program versus process, static versus dynamic concurrency versus parallel minimal process states: new, ready, running, waiting, terminated the ready queue Kernel maintains process table. What information do we need to maintain while the process exists? While a process is running... its time quantum could expire it may need I/O it may be interrupted context switch hierarchical relationship among processes fork and exec Interprocess Communication: e.g. a producer and consumer may need to work together. They could share a buffer, or send messages to each other. When sending a message, it may be appropriate to block (i.e. wait/sleep) or not. Chapter 4 --------- Thread, a.k.a. "lightweight process" to allow a process to do something in parallel e.g. game, Web browser Amdahl's law: Your speedup is limited by the proportion of the program that can be parallelized. speedup = old execution time / new execution time Threads of the same process share: code, data, open files But distinct program counter and run-time stack You must have both: User threads supported by your language's run-time library, Kernel threads supported by the OS How do these sets of threads correspond? Possibilities: many-to-one (the kernel only gives you one thread, one-to-one (the best possible scenario), many-to-many (economical compromise) Designing multi-threaded program: split the code, or split the data Debates in thread design what should happen if a thread calls fork. how quickly to terminate all threads of a process. if the process receives a signal, send to 1 thread or all threads Chapter 5 --------- critical section race condition synchronization problems, e.g. producer/consumer, dining philosophers Solution criteria: mutual exclusion progress (no starvation) bounded waiting (no deadlock) Critical section code is flanked by statements that seek & release "permission" Semaphores may be boolean or counting (integer) Java's Synchronized qualifier for methods When you call a syncrhonized method, you obtain lock on whole object. If already locked, you go into the object's "entry set" wait, notify (JVM selects one thread at random), notifyAll 4 necessary conditions for deadlock granting exclusive access of a resource you may hold one resource while waiting for another you won't release a resource until done circular wait (cycle in directed graph) - this is the critical criterion because the other 3 are commonly true about the system How should the OS deal with deadlock? Possible approaches: Ignore. Consider it a bug, and let the human figure it out. Prevent. Make it impossible for all 4 conditions to occur. Avoid. e.g. Use Banker's algorithm Detect & recover by killing processes until cycle broken. Banker's algorithm, safe state Chapter 6 --------- A process usually uses the CPU in "bursts" Helpful in setting time quantum in a round-robin scheduling policy. Scheduling criteria CPU utilization throughput: number/rate of jobs completed turnaround time: finish time - request time waiting time: how long spent in the ready state response time: how long after request do we begin to see any output Some scheduling algorithms first-come, first-served round robin shortest job next shortest remaining time Scheduling can be pre-emptive Gantt chart System load: How many tasks are currently running or in the ready queue? Real-time: are deadlines hard or soft? Real-time scheduling algorithms rate monotonic earliest deadline first (harder to implement, but more likely to succeed) Chapter 7 and 8 --------------- main memory: virtual versus physical address A process may be temporarily "swapped out" How should we allocate RAM? 1. fixed size partitions (doesn't mean equal sized) To decide where to allocate a process to RAM, we can use: first fit, best fit, worst fit External fragmentation 2. paging: RAM consists of fixed-size frames (e.g. 4K each) so that virtual memory can consist of analogous pages We partition virtual address: page number, page offset we partition physical address: frame number, frame offset Page table, inverted page table, TLB Page fault 3. segmentation Can be used in conjunction with paging Certain range of addresses assigned to different parts of program e.g. "memory layout" handout Segmentation fault Page replacement algorithms clairvoyant FIFO second-chance FIFO LRU Design question: What should the page size be? We want to minimize the overhead. Two sources of overhead: size of page table, and the internal fragmentation of not needing the entire last page. Thrashing Buddy system of allocating kernel memory Chapter 9 --------- Disk geometry Disk scheduling shortest seek first elevator algorithm circular scan In the elevator and circular scan, we usually also employ the "look" technique of only going as far as the requests require, not to the edge of the disk. RAID striping Chapter 10 and 11 ----------------- attributes of a file, "directory" information operations on files Given a file, how is its file type determined? File permissions Determining the location of a file's contents on disk Contiguous allocation linked allocation indexed allocation: direct and indirect blocks for large files! Determining which disk blocks are free space Chapter 12 ---------- Terminology: controller, device driver, port, bus, daisy chain Memory mapped I/O, e.g. for the screen contents polling versus interrupt. Why do we need interrupts? What happens? Direct Memory Access, to simplify reading an entire file into memory Buffers needed when media operate at different speeds Chapter 13 and 14 ----------------- Access control matrix. Domains & resources represented as 2-d array with the cells indicating what permissions granted. Coding errors or omissions can lead to security flaws Trojan horse Trap door Virus Worm Authentication Dictionary attack Salt the passwords Cipher systems Caesar Substitution Vigenere, including one-time pad RSA Symmetric (using same key for encryption/decryption) vs. asymmetric Diffie-Hellman key exchange Digital signature How aggressive should your security detection be? false positives, false negatives human factors