cos 318: operating systems review session 1

23
COS 318: Operating Systems Review Session 1

Upload: others

Post on 12-Apr-2022

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: COS 318: Operating Systems Review Session 1

COS 318: Operating Systems

Review Session 1

Page 2: COS 318: Operating Systems Review Session 1

Outline

2

u Elaborate on the scope of the final exam

u Practice 8 sample questions

Page 3: COS 318: Operating Systems Review Session 1

The Scope of The Final Exam

3

Lecture Slides

MOS ReadingAssignments

Projects

Page 4: COS 318: Operating Systems Review Session 1

Exam Scope: Lecture Slides

4

u Cover all lectures.

u Make sure you l understand concepts, and l reason through code snippets, algorithms, and examples

u In case you have difficulties with a topic and need to watch a lecture recording, feel free to email Dr. Shahrad.

Page 5: COS 318: Operating Systems Review Session 1

Exam Scope: MOS Reading Assignments

5

• You were expected to complete those readings before lectures. • Make sure you cover them fully for the final exam.• Those three papers not assessed in the final exam.

Page 6: COS 318: Operating Systems Review Session 1

Exam Scope: Course Projects

6

u Only the first five projects: P1, P2, P3, P4, and P5

u If your teammates did all the work, you might have difficulties here.l Make sure to fully understand how projects worked.

u Read precept slides, watch precept recordings, and review design review questions.

Page 7: COS 318: Operating Systems Review Session 1

Sample Question 1

7

u What needs to be saved and restored on a context switch between two threads in the same process?l We need to save the registers, stack pointer, and program

counter into the thread control block (TCB) of the thread that is no longer running. Then, we need to reload the registers, stack pointer, and program counter from the TCB of the new thread.

u The answer above is brief, explicit, and accurate.

Page 8: COS 318: Operating Systems Review Session 1

Sample Question 2

8

u Which of the following typically require assistance from hardware to implement well? For those that do, circle them, and name the necessary hardware support and its purpose. For those that don’t briefly explain why (one or two sentences at most).

l System calll Thread creationl Process context switch

Page 9: COS 318: Operating Systems Review Session 1

Hardware assistance for system call?

9

u Requires system supportu In particular to set CPU’s protection

bit to run in the kernel mode

Lecture 3

Page 10: COS 318: Operating Systems Review Session 1

Hardware assistance for thread creation?

10

u Creating kernel threads require system calls and hence need a protection bit. Therefore need hardware support.

u User-level threads do not need assistance from hardware.

You might encounter such questions in the exam. Support your answer with a clear argument and consider cases not stated in the question.

Page 11: COS 318: Operating Systems Review Session 1

HW assistance for process context switch?

11

u Timer interrupt used in preemptive scheduler

Lecture 8

Page 12: COS 318: Operating Systems Review Session 1

Sample Question 3

12

Attribution: from UC Berkeley CS162 Fall 2011 Final ExamA. Answer:

l Each entry is a disk sector addressl 16 bits allows only 65,536 sectors

B. Solution:l Make each FAT entry access a logical

sector that is 2 physical sectorsl Trade-off:

• Con: increased internal fragmentation• Pros: maintaining the size of the FAT,

and backward compatibility Lecture 15

Page 13: COS 318: Operating Systems Review Session 1

Sample Question 4

13

Attribution: from Rutgers CS 416 Spring 2011 Final Exam Review

u Answer: Running à ready

Be prepared to encounter multiple-choice questions in the exam.

Page 14: COS 318: Operating Systems Review Session 1

Sample Question 5

14

Attribution: from U Wisc-Madison CS 537 Fall 2016 Midterm Exam

Page 15: COS 318: Operating Systems Review Session 1

Sample Question 5

15

Attribution: from U Wisc-Madison CS 537 Fall 2016 Midterm Exam

Page 16: COS 318: Operating Systems Review Session 1

Sample Question 5

16

Attribution: from U Wisc-Madison CS 537 Fall 2016 Midterm Exam

Page 17: COS 318: Operating Systems Review Session 1

Sample Question 5

17

Be prepared to encounter true/false questions in the exam.

Attribution: from U Wisc-Madison CS 537 Fall 2016 Midterm Exam

Page 18: COS 318: Operating Systems Review Session 1

Sample Question 6

18

Attribution: from UCSD CSE 120 Fall 2016 Final Exam

Page 19: COS 318: Operating Systems Review Session 1

Sample Question 6

19

S=1

time

T1 T2

Context SwitchS=1

CriticalSection

Context Switch

CriticalSection

Page 20: COS 318: Operating Systems Review Session 1

Sample Question 7

20

Attribution: from U Toronto ECE 344 2018 Midterm Exam

Page 21: COS 318: Operating Systems Review Session 1

Sample Question 8

21

Attribution: from NYU CS 372 Spring 2010 Final ExamFIFO

Example: working set is 38MBLooped access to a 400MB working set, every access causes a PF.Belady’s Anomaly

Page 22: COS 318: Operating Systems Review Session 1

Belady’s Anomaly (FIFO case)

22

Youngest0 1 2 3 0 1 4 0 1 2 3 4

0 1 2 3 0 1 4 4 4 2 3 3

0 1 2 3 0 1 1 1 4 2 2

0 1 2 3 0 0 0 1 4 4

PF PF PF PF PF PF PF PF PF

Oldest

Access Sequence

9 Page Faults

Youngest0 1 2 3 0 1 4 0 1 2 3 4

0 1 2 3 3 3 4 0 1 2 3 4

0 1 2 2 2 3 4 0 1 2 3

0 1 1 1 2 3 4 0 1 2

0 0 0 1 2 3 4 0 1

PF PF PF PF PF PF PF PF PF PF

Oldest

10 Page Faults

Fits 3 pages

Fits 4 pages

Page 23: COS 318: Operating Systems Review Session 1

Summary

23

u Cover all lectures. u Study MOS reading assignments.u Make sure you are fully familiar with course projects.

Best of luck with Project 5!