Download presentation
Presentation is loading. Please wait.
1
Lecture 35: Review for Midterm 2
2
About Midterm 2 Cover scheduling, memory management, and file systems. We do have a couple of review questions for the materials covered in the 1st midterm exam. A single-side A4 or US letter sheet of note is allowed 50 minutes
3
Overview Process Scheduling Memory Management File System
4
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
5
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
6
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
7
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.
8
Belady's anomaly Intuitively, more page frames the memory has, the fewer page faults a program will get. Belady 1969
9
Files Naming Structure Types Access Attributes Operations
10
Directories Directory systems Path names Operations
11
File system implmentation
Contiguous allocation Linked list allocation Linked list allocation with a table in memory I-nodes
12
UNIX V7 Directory Implementation
The steps in looking up /usr/ast/mbox
13
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
14
Sample Questions
15
Sample Questions RR, Q = 10 P1: 4 36 8 112 1 13 16 P2: 23 40 2 20
13 16 20 P1: P2: P3: P4: Which process goes next, and when? Gantt chart P1 idle P2 P3 P4
16
Sample Questions MLFQ: Q0 = 8, Q1 = 16, Q2 =
40 q1 45 177 13 16 20 P1: P2: 15 P3: P4: Gantt chart 1 idle
17
Sample Questions Which page frame will be replaced?
Time loaded Time referenced R bit M bit 60 161 1 130 160 2 26 162 3 20 163 Which page frame will be replaced? First-In-First-Out (FIFO) Not-Recently-Used (NRU) Second Chance Least-Recently-Used (LRU)
18
Sample Questions Assume file “x” content is: 0123456789876543210
fdrw = open("x", O_RDWR); fdr = open("x", O_RDONLY); read(fdrw, buf, 3); read(fdr, buf2, 4);
19
Sample Questions Assume file “x” content is: 0123456789876543210
fdrw = open("x", O_RDWR); fdrw2 = dup(fdrw); read(fdrw, buf, 3); read(fdrw2, buf2, 4);
20
Sample Questions Assume file “x” content is: 0123456789876543210
fdrw = open("x", O_RDWR); Fork(); Parent: read(fdrw, buf, 3); Child: read(fdrw, buf2, 4);
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.