1 CS153: Final Review1 Chengyu Song Slides modified from Harsha Madhyvasta, Nael Abu-Ghazaleh, and Zhiyun Qian
2 Administrivia Final exam Thursday, June 15, 3:00 p.m. - 6:00 p.m. In this classroom (Sproul Hall 1102) Read questions carefully! Closed book. No additional sheets of notes DO NOT CHEAT
3 Administrivia (cont.) Scope Most topics covered after midterm Memory management, file systems, access control Virtualization, communication, attacks&defenses One problem from pre-midterm Either alternation or reader/writer Based on lecture and textbook ( Preparation on the class schedule) Keys for HW2 and HW3 will be posted tomorrow
4 Overview Virtual address space and address translation Paging and optimizations Memory hierarchy and cache replacement Disk I/O File systems: abstraction and disk layout Access control Advanced topics: Shared memory, copy-on-write, memory-mapped file, FFS, JFS, LFS, RAID, IPC, RPC, attacks&defenses
5 Memory management Abstractions and operations Virtual address, read/write/execute Objectives Simplify programming: where the program will be loaded Sharing and isolation Challenges and good performance metrics Fragmentations: internal and external Speed: translation and context switch
6 Virtual address space Fixed partitions: base register + fixed size Fastest translation/context switch, large internal fragmentation Variable partitions: based register + limit Fast translation/context switch, large external fragmentation Segmentation: selector + segment table Similar to variable partitions with less external fragmentation Paging : page tables No external fragmentation, acceptable internal fragmentation
7 Paging address translation Virtual address has two parts: virtual page number and offset Virtual page number (VPN) is an index into a page table Page table determines page frame number (PFN) Physical address is PFN::offset
8 Page table entries (PTEs) +---------------------+-----+----+-+-+-+ Page Frame Number... PROT R M V +---------------------+-----+----+-+-+-+ <---- 20 bits ----> 4b 1 1 1 What are the purpose of PTE bits?
9 Multi-level page tables Goal: reduce memory cost of page tables Virtual addresses (VAs) have several parts: 1st level page number, 2nd level page number,..., and page offset First few levels of page tables map page number to next level page table The last level page tables maps the last level page number to physical page Offset indicates where in physical page address is located
Intel IA32e translation (from manual) 10
11 Translation Lookaside Buffers (TLB) Caches translation results Fully associative cache (all entries looked up in parallel) Leverages program locality Managed by hardware (x86) or software
Memory hierarchy 12
13 Caches & Locality A smaller, faster storage device that acts as a staging area for a subset of the data in a larger, slower device. Cache works because of locality : programs tend to use data and instructions with addresses near or equal to those they have used recently Temporal locality: recently referenced items are likely to be referenced again in the near future Spatial locality: items with nearby addresses tend to be referenced close together
14 Cache misses Cold (compulsory) miss Cold misses occur because the cache is empty. Conflict miss When mapping a larger set of blocks at level k+1 to a smaller subset of blocks at level k, multiple data objects will map to the same block. Capacity miss -> replacement policy Occurs when the set of active cache blocks ( working set ) is larger than the cache.
15 Cache replacement policies The goal of the replacement algorithm is to reduce the miss rate The best item to evict is the one never be accessed again Belady's algorithm: replace the item that will not be used for the longest time in the future ( how? ) FIFO: Belady's anomaly LRU: reference count Scanning: check ref bit in every valid PTE LRU clock: replace page that is "old enough"
16 Disks Physical disk structure Platters, surfaces, tracks, sectors, cylinders, arms, heads Disk interface How does the OS make requests to the disk? Disk performance What steps determine disk request performance? What are seek, rotation, transfer?
17 Disk scheduling How can disk scheduling improve performance? What are the issues in disk scheduling? Response time, throughput, fairness FCFS: do nothing SSTF: "starvation" SCAN, C-SCAN: long wait time for edge blocks
18 Files What is a file? What operations are supported? What properties do they have? What are file access methods? Why is file type?
Basic file operations 19
20 Directories What is a directory? What are they used for? How are they implemented? What is a directory entry? How are directories used to do path name translation?
Basic directory operations 21
22 File system layouts What are file system layouts used for? What are the general strategies? Contiguous, linked, indexed? What are the tradeoffs for those strategies? How do those strategies reflect file access methods?
23 Unix inodes What is an inode? How are inodes different from directories? How are inodes and directories used to do path resolution, find files?
24 FS performance optimization Disk reads and writes take order of milliseconds Very slow compared to CPU and memory speeds How to speed things up? File buffer cache Cache writes Read ahead
25 Access control What is access control Goals and principles Access control models DAC: access control matrix, ACLs, Capabilities What are the advantages/disadvantages of each? Owner, group, and root User and process MAC and sandbox
26 For next class... Example problems