CS 537 Fall 2017 Review Session Deadlock Conditions for deadlock: Hold and wait No preemption Circular wait Mutual exclusion QUESTION: Fix code List_insert(struct list * head, struc node * node List_move(struct list * list1, struct list * list2 { mutex_lock(&list1->lock); mutex_lock(&list2>lock); node * node = list1->head; list1->head = node->next; node->next = list2->head list2->head = node; mutex_unlock(&list2->lock); mutex_unlock(&list1->lock); } 1
Disks read/write head spindle platter sector surface cylinder track Disks Consider a disk with the following characteristics: Number of surfaces: 8 (= 2^3 ) Number of tracks / surface: 512 K (= 2^19) Number of bytes / track: 8 MB (= 2^23 bytes) Number of sectors / track: 8 K (= 2^13) Questions: How many heads does this disk have? What is the size of each sector? How many bytes per cylinder? What is the total capacity of this disk? 2
Disk Scheduling Types: FCFS SSTF / SPTF SCAN / C-SCAN Assume the disk head is at cylinder 18 and moving towards higher cylinders. Assume a stream of requests arrives for the following cylinders: 5, 20, 1, 60, 3, 8, 90, 2, 20, 40, 6, 70. With a FCFS scheduling policy, what is the total seek distance to service all the requests? a SSTF scheduling policy, what is the total seek distance? With a SCAN scheduling policy (bi-directional scanning), what is the total seek distance? SSDs Characteristics: - Fast random read - Erase blocks / page reads and writes - FTL for erase before write - In/place or Direct Mapping - Log structured Example question Given read speed of 50 microseconds, no parallelism, how many random reads per second? For a RAID-0 array with a random time of 2 miliseconds, how many disks needed for same performance If SSD can do 10 paralllel requests, how many disks? 3
RAID Raid types: 0, 1, 4, 5 Performance: sequential, random Reads, writes Sample: Different RAID levels have different performance. Given a RAID 10 or 01 (striping + mirroring) system and a RAID 5 (rotating parity) system using the same number of disks: Which provides better throughput (requests/second) (if either) for small reads (~1 KB)? Which provides better throughput for large writes (if either) (~1 MB) Why? File system API File names: Inode number Path name File handle Open / read and write / close Metadata accessed on open: Directory inode + directory data + file inode Metadata accessed on read/write File inode (may be cached) + file data File inode write optional to update modify time Metadata accessed on create: Directory inode/data File inode Inode bitmap Sample Question: How many blocks accessed to rename a file? 4
File system implementation Metadata approaches Contiguous Linked FAT Indexed / Multilevel index The standard Unix and FFS layout uses an inode with 10 direct pointers, 1 indirect pointer, 1 double indirect pointer, and 1 triple indirect pointer. Assume blocks are 1 KB, and block indexes are 4 bytes (32 bits). Starting with an empty file, how many blocks must be written to write to the 5 th block of the file? Please include all metadata updates. Starting with an empty file, how many blocks must be written to update the 270 th block of the file? FFS Cylinder groups Larger blocks + fragments Layout policy The Fast File System (FFS) tries to improve performance by grouping related things on disk in a cylinder group. List two file-system structures that FFS tries to place within a cylinder group Not everything can be near everything else. What things should FFS put in different cylinder groups and why? 5
LFS Segments Inode maps Cleaning Question: Describe one common file system operation that is sequential on LFS but requires seeks or rotations with FFS. Explain which structures in FFS are accessed as part of this operation. LFS uses segments to organize its log: the file system splits the disk into segments, and writes sequential within a segment before seeking to another segment. How should LFS decide how big to make a segment? Journaling & Recovery Redundancy FSCK Journaling Data journaling Ordered journaling Barriers & checksums Question: Suppose the disk you are using becomes faulty and a block on your disk becomes corrupted. For each of the following scenarios, say whether (a) what the impact of the failure is and (b) whether and how it could be repaired. You are storing free blocks as a linked list. Each free block has a pointer to the next free block. The first free block becomes corrupted, so you can no longer read the pointer it contains. You are storing files using linked allocation, so each block maintains a pointer to the next block in the file. One of the blocks in the middle of the file becomes corrupted. 6
Distributed Systems Differences with OS Dropped/lost messages Failures Protocols UDP TCP RPC Question: What technique protects against: Corrupted packets Dropped packets Duplicated packets NFS RPC messages for file system API File handles for recovery Caching + policy Update server on file close or after 30 seconds Poll for changes if haven t checked in 3 seconds Question: Client does open(), write(), write(). Server crashes & recovers between second and this write Another machine opens & read the file - what does it see? 7
Virtualization CPU virtualization: Trap + emulate Memory virtualization: Shadow + nested page tables I/O virtualization: Virtual devices Question What workloads perform equally well under virtualization? Which perform worse? 8