Final Review Today From threads to file systems. Threads Threads motivation and concept Threads and...

10
Final Review Today From threads to file systems

Transcript of Final Review Today From threads to file systems. Threads Threads motivation and concept Threads and...

Page 1: Final Review Today From threads to file systems. Threads Threads motivation and concept Threads and processes User, kernel-level and hybrid threads Complications.

Final Review

Today From threads to file systems

Page 2: Final Review Today From threads to file systems. Threads Threads motivation and concept Threads and processes User, kernel-level and hybrid threads Complications.

2

Threads

Threads motivation and concept

Threads and processes

User, kernel-level and hybrid threads

Complications with threads

Q: If a multithreaded process forks, a problem occurs if the child gets copies of all the parent’s threads. Suppose that one of the original threads was waiting for keyboard input. Now two threads are waiting for keyboard input, one in each process. Does this problem ever occur in single-threaded processes?

Q: In a system using user-level threads, is there one stack per thread or one stack per process? What about when kernel-level threads are used? Why or why not?

Page 3: Final Review Today From threads to file systems. Threads Threads motivation and concept Threads and processes User, kernel-level and hybrid threads Complications.

3

Thread synchronization

Race conditions and critical sections

Requirements for a solution

Locks and lock 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.

Page 4: Final Review Today From threads to file systems. Threads Threads motivation and concept Threads and processes User, kernel-level and hybrid threads Complications.

4

Synchronization II

Condition variables

Semaphores

Bounded buffer problem

Reader-writers problem

Issues with semaphores

Monitors

Q: Give a sketch of how an operating system that can disable interrupts could implement semaphores.

Q: Write (pseudocode) a monitor that implements an alarm clock that enables a calling program to delay itself for a specified number of time units (ticks). You may assume the existence of a real hardware clock that invokes a procedure tick in your monitor at regular intervals.

Page 5: Final Review Today From threads to file systems. Threads Threads motivation and concept Threads and processes User, kernel-level and hybrid threads Complications.

5

Monitor for an alarm clock

monitor alarm { condition c; void delay(int ticks) { int begin_time = read_clock(); while (read_clock() < begin_time + ticks) c.wait(); }

void tick() { c.broadcast(); }}

Page 6: Final Review Today From threads to file systems. Threads Threads motivation and concept Threads and processes User, kernel-level and hybrid threads Complications.

6

Deadlocks

Deadlock definition

Condition for deadlocks

Modeling 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.

Page 7: Final Review Today From threads to file systems. Threads Threads motivation and concept Threads and processes User, kernel-level and hybrid threads Complications.

7

I/O

Principles of I/O hardware

I/O software layers

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?

Page 8: Final Review Today From threads to file systems. Threads Threads motivation and concept Threads and processes User, kernel-level and hybrid threads Complications.

8

File systems interface

File system abstractions – files and directories

Implementing files

Implementing directories

Protection

Q: A key issue when designing a file system is deciding how to keep track of which disk block goes with which file. Of the approaches discussed in class, 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.

Page 9: Final Review Today From threads to file systems. Threads Threads motivation and concept Threads and processes User, kernel-level and hybrid threads Complications.

9

File systems implementation

Early FS examples – CP/M, MSDOS, Original Unix

FFS

Fsck and journaling

Log file system

Q: In UNIX System V, the length of a block is 1Kbyte and each block can hold a total of 256 block addresses. Using the i-node scheme, what is the maximum size of a file? (Remember UNIX System V uses three levels of indirection)

Q: How many disk operations are needed to fetch the i-nod e 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.

Page 10: Final Review Today From threads to file systems. Threads Threads motivation and concept Threads and processes User, kernel-level and hybrid threads Complications.

10

Research papers

Scheduler Activations: Effective Kernel Support for the User-Level Management of Parallelism, T. Anderson et al., Proc. of SOSP 1991

Experiences with Processes and Monitors in Mesa, B. Lampson and D. Redell, CACM 1980

Design and implementation of the log-structured file system, M. Rosenblum and J. Ousterhout, Proc. of SOSP 1991