Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 42: Review for Final Exam

Similar presentations


Presentation on theme: "Lecture 42: Review for Final Exam"— Presentation transcript:

1 Lecture 42: Review for Final Exam

2 About Final Exam Comprehensive
Two double-sided US letter sheet are allowed 12-2pm, Thursday, May 3 Please arrive at 11:55am or earlier, so that we can start right at 12.

3 Overview Processes and Threads Mutual Exclusion Deadlocks
Process Scheduling Memory Management File System OS Security

4 Process Process context Process creation
Address space Registers Stack pointer Program counter Files opened Others Process creation fork(), exec() Multiprogramming/Context switching

5 Threads Per-thread context Threads implementation POSIX standards
Stack Registers Stack pointer Program counter Threads implementation User-level Kernel-level POSIX standards

6 Mutual Exclusion Core issue of multiprogramming Solutions
Disabling interrupts Strict alternation Peterson’s solution Hardware support Semaphore

7 Semaphore and condition variable
Mutual exclusion is not enough E.g., producer-consumer problem We need to block until a condition is satisfied Semaphore Condition variable

8 Classical OS problems Dining philosophers problem
Reader-writer problem

9 Deadlocks Formal definition : A set of processes is deadlocked if each process in the set is waiting for an event that only another process in the set can cause

10 Four Conditions for Deadlock
Mutual exclusion condition each resource assigned to 1 process or is available Hold and wait condition process holding resources can request additional No preemption condition previously granted resources cannot forcibly taken away Circular wait condition must be a circular chain of 2 or more processes each is waiting for resource held by next member of the chain

11 Strategies for dealing with deadlocks
just ignore the problem altogether detection and recovery Directed circle in resource allocation graph Algorithm for multiple-copy resources dynamic avoidance Safe and unsafe states Banker’s algorithm prevention Attacking the four necessary conditions

12 Process scheduling What are the goals of process scheduling?
Scheduling Algorithms for Batch Systems First come first serve Shortest job first Shortest remaining time next Scheduling Algorithms for Interactive Systems Round-Robin scheduling Priority scheduling Multiple queues Lottery scheduling

13 Memory management Memory allocation Memory de-allocation
A new process comes into memory Memory de-allocation A process leaves memory Address translation Virtual address to physical address Process isolation One process cannot access the memory of other processes

14 Memory management approaches
Processes are known in advance Swapping Base and limit registers in CPU Virtual memory

15 Virtual memory Paging Address translation via page table
MMU Page fault Speed up address translation TLB Large page tables Multi-level page table Inverted page table

16 Page Replacement Algorithms
FIFO (First-In-First-Out) NRU (Not-Recently-Used) Second Chance LRU (Least-Recently-Used) Clock Algorithm(s) Determining which pages to replace is a decision that could have significant ramifications to system performance. If the wrong pages are replaced, i.e. pages which are referenced again fairly soon, then not only must these pages be fetched again, but a new set of pages must be tagged for removal. The FIFO scheme has the benefit of being easy to implement, but often removes the wrong pages. Now, we can’t assume that we have perfect knowledge of a process’s reference pattern to memory, but we can assume that most processes are reasonably “well behaved.” In particular, it is usually the case that pages referenced recently will be referenced again soon, and that pages that haven’t been referenced for a while won’t be referenced for a while. This is the basis for a scheme known as LRU—least recently used. We order pages in memory by the time of their last access; the next page to be removed is the page whose last access was the farthest in the past. A variant of this approach is LFU—least frequently used. Pages are ordered by their frequency of use, and we replace the page which has been used the least frequently of those still in primary storage. Both these latter two policies have the advantage that they behave better for average programs than FIFO, but the disadvantage that they are costly to implement. It is straightforward to implement LRU for the Unix buffer cache, since the time to order the buffers is insignificant compared to the time required to access them. But we cannot afford to maintain pages in order of last reference.

17 Manage free memory/disk
Bitmap Linked list

18 Files Naming Structure Types Access Attributes Operations

19 Directories Directory systems Path names Operations

20 File system implmentation
Contiguous allocation Linked list allocation Linked list allocation with a table in memory I-nodes

21 UNIX V7 Directory Implementation
The steps in looking up /usr/ast/mbox

22 Speeding up file operations
Cache Block read ahead Reduce disk-head motion

23 Hard links vs. symbolic links
Inode 134 links=2 . 12 .. 14 f1 134 f2 Hard link inode 134 . 12 .. 14 f1 134 f2 208 special file data Symbolic link /home/gong/f1

24 OS Security Access control Exploiting software Cryptography
Authentication

25 Access control Access control list Capability
File permissions in UNIX systems -rwxrw-r--

26 Exploiting software Attacks Defenses Buffer overflow, stack smashing
NX StackGuard ASLR CFI

27 Cryptography Symmetric-key cryptography Public-key cryptography
Confidentiality Block cipher Stream cipher Integrity & authenticity HMAC Public-key cryptography Public-key encryption Digital signature

28 Cryptographic hash functions
Preimage resistance Given h, intractable to find y such that H(y)=h Second preimage resistance Given x, intractable to find y≠x such that H(y)=H(x) Collision resistance Intractable to find x, y such that y≠x and H(y)=H(x)

29 Authentication Authentication is to prove the identity of a user
Four categories Something you know Something you have Someone you are Someone you know


Download ppt "Lecture 42: Review for Final Exam"

Similar presentations


Ads by Google