Final review q From threads to file systems
Disclaimer Not guaranteed to be everything you need to know, just an overview of second half of the course 2
What s covered by the exam? Lectures from Threads to File systems Readings Slides Extra reading for extra credit 1. H. Levy et al., Virtual Memory Management in the VAX/VMS Operating System, IEEE Computer, Mar. 1982. 2. T. Anderson et al., Scheduler activations: effective kernel support for the user-level management of parallelism, ACM TOCS, 10(1):53-79, Feb. 1992. 3. B. Lampson et al., Experiences with Processes and Monitors in Mesa, CACM, Feb. 1980. 4. M, Rosenblum et al., Design and implementation of the logstructured file system, SOSP, 1991. 3
Major topics User and kernel-level threads Critical sections, locks and synchronization variables Race conditions, synchronization problems deadlocks I/O File systems 4
Threads Threads motivation and concept Threads and processes User, kernel-level and hybrid threads Complications with threads Q: In class we listed the register set as a per-thread rather than per-process item. Why? After all, the machine has only one set of registers. Q: Can the priority inversion problem discussed in class happen with user-level threads? Why or why not? 5
Synchronization Race conditions and critical sections Requirements for a solution Locks and their implementation Disabling interrupts and TSL Busy waiting, priority inversion and sleeping Basic lock-based data structures Q: Can two threads in the same process synchronize using a kernel semaphore if the threads are implemented by the kernel? What if they are implemented in user space? Assume that no threads in any other processes have access to the semaphores. Q: Why does disabling interrupts work for implementing locks in a single processor, and why is it not used outside the kernel? 6
Synchronization II Condition variables Semaphores, issues with semaphores and monitors Bounded buffer problem Reader-writers problem Q: Synchronization within monitors uses condition variables and two special operations wait and signal. A more general form of synchronization would be to have a single primitive, waituntil, that had an arbitrary Boolean predicate as parameter. Thus, one could say, for instance waituntil ((x < 0) ((y + z) < n)) The signal primitive would no longer be needed, of course. This scheme is clearly more flexible than then one discussed, but it is not used. Why not? Hint: Think about the implementation. 7
Monitor for an alarm clock Q: This is a snippet of the producer/consumer void *producer(void *arg) { int i; for (i = 0; i < loops; i++) { sem_wait(&empty); sem_wait(&mutex); put(i); sem_post(&mutex); sem_post(&full); } } void *consumer(void *arg) { int i; for (i = 0; i < loops; i++) { sem_wait(&full); sem_wait(&mutex); int tmp = get(); sem_post(&mutex); sem_post(&empty); } } Looking at the producer, why do you need the "mutex" semaphore if you have "empty"? Same in the consumer with "full"... Wouldn t those be enough? 8
Deadlocks Deadlock definition Condition for deadlocks Deadlock detection and recovery Dynamic deadlock avoidance Deadlock prevention Q: A system has two processes and three identical resources. Each process needs a maximum of two resources. Is deadlock possible? Explain your answer. 9
I/O Principles of I/O hardware Ways I/O can be done Disks Disk scheduling RAID Q: A computer manufacturer decides to redesign the partition table of a Pentium hard disk to provide more than four partitions. What are some consequences of this change? 10
File systems interface File system abstractions files and directories Implementing files Implementing directories Protection Q: A key issue when designing a FS is deciding how to keep track of which disk block goes with which file. Of the approaches discussed, which one would you choose to maximize efficiency in terms of speed of access, use of storage space, and ease of updating (adding, deleting, modifying) when the data is: a. Updated very infrequently and accessed frequently in random order. b. Updated frequently and accessed in its entirety relatively frequently. c. Updated frequently and accessed frequently in random order. 11
File systems implementation Early FS examples FFS Fsck and journaling Log file system Q: How many disk operations are needed to fetch the i-node for the file /home/fabianb/courses/eecs343/final10.tex? Assume that the i-node for the root directory is in memory, but nothing else along the path is in memory. Also, assume that all directories fit in one disk block. Q: How would you keep track of free blocks in a FAT file system? How would you find a free block then? 12
Notes on the final from those grading Write only your netid and on the first page It will help us grade anonymously Handwriting must be legible We weren't able to grade some midterm s responses Make it *very clear* what your final answer is Multiple answers will make you loose credit 13