Presentation is loading. Please wait.

Presentation is loading. Please wait.

Operating Systems Review.

Similar presentations


Presentation on theme: "Operating Systems Review."— Presentation transcript:

1 Operating Systems Review

2 Questions What are two functions of an OS?
From top to down, providing abstractions to applications From down to top, resource manager, multiplexing( sharing) resource

3 Questions What causes OS to change?
What is multi-programming? What is time-sharing? Or, why aren’t we still running MS-DOS? What is a process? What is a thread? What is address space? What is a file? Process is an instance of an executing program, including the current values of the program counter, registers, and variables. Thread is miniprocess. Address space is the set of addresses that a process can use to address memory. A file is logical units of information created by processes.

4 Questions How does a shell work? Or … arrange the commands in order:
wait() pid = fork() exec() gets() while(1) { }

5 Review Process Scheduling Explain how SJF,FCFS,RR etc. works
True or False: FCFS is optimal in terms of average turnaround time Most processes are CPU bound The shorter the time quantum, the better

6 Response time Turnaround time P1 20 P2 32 P3 P4 P5 40 56 60 FCFS P1 4
Estimate by time from job submission to time to first CPU dispatch Assume all jobs submitted at same time, in order given Turnaround time Time interval from submission of a process until completion of the process Assume all jobs submitted at same time P1 20 P2 32 P3 P4 P5 40 56 60 FCFS Have the students work the Response time & Turnaround time calculation for the RR, so they get some experience. P1 4 P2 12 P3 P4 P5 24 40 60 SJF P1 P2 4 P3 P4 P5 8 12 16 20 24 28 32 36 40 44 48 52 56 60 RR

7 Response Time Calculations
Job FCFS SJF RR P1 40 P2 20 12 4 P3 32 8 P4 24 P5 56 16 Average 29.6 Response time is the same as waiting time for FCFS and SJF-- because each process only runs once, until completion.

8 Turnaround Time Calculations
Job FCFS SJF RR P1 20 60 P2 32 24 44 P3 40 12 P4 56 P5 4 Average 41.6 28 42.4

9 Review What is a “race condition”?
What are 4 properties necessary for a correct “critical region” solution? mutual exclusion, no assumption, bounded waiting, let others use when unusing What is Peterson’s Solution? Why is semaphore better than Peterson’s solution and TSL?

10 Review What is deadlock?
What is the four conditions for deadlock to happen?

11 Review of Banker’s Algorithm
P = {P0, P1, …, P4}; R={A(10), B(5), C(7)} Snapshot at time T0: Allocation Max Available A B C P0 0 1 0 7 5 3 3 3 2 P1 2 0 0 3 2 2 P2 3 0 2 9 0 2 P3 2 1 1 2 2 2 P4 0 0 2 4 3 3 Can request for (1,0,2) by P1 be granted? Can request for (3,3,0) by P4 be granted? Can request for (0,2,0) by P0 be granted?

12 Review What is the Memory Management Unit?
How does it work during a virtual—physical address translation?

13 Translate virtual address to physical address
20 4100 8300

14 Review A paging scheme uses a Translation Loo-aside Buffer (TLB) A TLB access takes 10 ns and a main memory access takes 50 ns. What is the effective access time (in ns) if the TLB hit ratio is 90% and there is no page-fault?

15 Multilevel Page Tables
What is the PT1 and PT2 value for a virtual address 0x ? Figure (a) A 32-bit address with two page table fields. (b) Two-level page tables. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

16 ? Suppose that a machine has 38-bit virtual address ad 32-bit physical addresses. What is the main advantage of a multilevel page table over a single-level one? With a two-level page table, 16-KB pages, and 4-byte entries, how many bits should be allocated for the top-level page table field and how many for the next-level page table filed? To answer this question, consider the internal fragmentation resulting from page table size. For example, when a page table is less than 1 page in size, you have internal fragmentation that is unused and wasted memory.

17 True or False With paging, a process’ logical address spaces is contiguous With paging, a process’ physical address spaces is contiguous

18 Review Does paging have fragmentation?
No? Then why not? Yes? Then what kind? What are the overheads associated with paging?

19 Review True or False: Demand paging:
The logical address space cannot be bigger than the physical address space Processes have big address spaces because they always need them Demand paging: Is unrelated to prepaging Brings logical pages into physical memory when requested by a process Increases memory requirements for a system

20 Questions What is static relocation? What is dynamic relocation?
What is static linking? What is dynamic linking?

21 Review What is a Page Replacement Algorithm? What is thrashing?
What is “Belady’s Anomaly”? How does the Optimal algorithm work? How does Enhanced Second Chance work? What is thrashing? How do we fix it?

22 ? A computer has four page frames. The time of loading, time of last access, and the R and M bits for each page are as shown below (the times are in clock ticks): Page Loaded Last Ref. R M (a) Which page will NRU replace? (b) Which page will FIFO replace? (c) Which page will LRU replace? (d) Which page will second chance replace?

23 Cause of thrashing thrashing increases CPU utilization
Degree of multiprogramming

24 ? Array A[1024, 1024] of integer, each row is stored in one page Program 1 for j := 1 to 1024 do for i := 1 to 1024 do A[i,j] := 0; 1024 × 1024 page faults Program 2 for i := 1 to 1024 do for j := 1 to 1024 do A[i,j] := 0; 1024 page faults

25 First-In-First-Out (FIFO)
1,2,3,4,1,2,5,1,2,3,4,5 1 4 5 3 Frames / Process 9 Page Faults 2 1 3 3 2 4 How many page faults would we have if we had 4 Frames/Process?

26 ? How long does it take to load a 64KB program from a disk whose average seek time and average rotation time are 10 msec, and whose tracks hold 32KB. For 2KB block size? For 4KB block size? ( /32*20)*32=( )*32=680 ( /32*20)*16=(20+2.5)*16 =360 ( /32*20)*32=( )*32=680 ( /32*20)*16=(20+2.5)*16 =360

27 The UNIX V7 File System (2)
Figure A UNIX i-node. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

28 I-Node How many data blocks are there?
If you added 3 more data blocks to the file, what would happen? 62 77 Disk blocks null null null null null

29

30 Review Directories: Aliases: Free space management:
In what way is a directory different than a file? In what way is a directory similar to a file? Aliases: Describe a hard-link Describe a soft-link Free space management: If the size of a block is B bytes, then what is the biggest size of a group in ext2?

31 The UNIX V7 File System (3)
Figure The steps in looking up /usr/ast/mbox. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved


Download ppt "Operating Systems Review."

Similar presentations


Ads by Google