CS-537: Midterm Exam (Fall 2008) Hard Questions, Simple Answers

Similar documents
There are 19 total numbered pages, 8 Questions. You have 2.5 hours. Budget your time carefully!

CS 61 Section Notes 5

CS-537: Midterm Exam (Fall 2013) Professor McFlub

There are 13 total numbered pages, 7 Questions.

CS 537: Introduction to Operating Systems Fall 2016: Midterm Exam #1. All cell phones must be turned off and put away.

CS 537: Introduction to Operating Systems Fall 2015: Midterm Exam #1

CS-537: Midterm Exam (Spring 2001)

CS 537: Introduction to Operating Systems Fall 2015: Midterm Exam #1

CS-537: Final Exam (Fall 2013) The Worst Case

CS-537: Midterm Exam (Spring 2009) The Future of Processors, Operating Systems, and You

16 Sharing Main Memory Segmentation and Paging

15 Sharing Main Memory Segmentation and Paging

CS-537: Final Exam (Spring 2011) The Black Box

Memory Hierarchy. Mehran Rezaei

EECE.4810/EECE.5730: Operating Systems Spring 2017 Homework 3 Solution

Operating Systems Comprehensive Exam. Spring Student ID # 3/16/2006

(page 0 of the address space) (page 1) (page 2) (page 3) Figure 12.1: A Simple 64-byte Address Space

COSC3330 Computer Architecture Lecture 20. Virtual Memory

CPS 310 first midterm exam, 10/6/2014

(Refer Slide Time: 01:25)

CS-537: Midterm Exam (Fall 2013) Professor McFlub: The Solutions Edition

CSE 410 Final Exam 6/09/09. Suppose we have a memory and a direct-mapped cache with the following characteristics.

Final Examination CS 111, Fall 2016 UCLA. Name:

Question Points Score Total 100

Operating Systems Comprehensive Exam. Spring Student ID # 2/17/2011

Simple idea 1: load-time linking. Our main questions. Some terminology. Simple idea 2: base + bound register. Protection mechanics.

CS-736 Midterm: Beyond Compare (Spring 2008)

CMPS 111 Spring 2013 Prof. Scott A. Brandt Midterm Examination May 6, Name: ID:

Computer Science 146. Computer Architecture

There are 15 total numbered pages, 9 Questions. You have 2.5 hours. Budget your time carefully!

Computer Architecture and Engineering. CS152 Quiz #3. March 18th, Professor Krste Asanovic. Name:

Operating Systems Comprehensive Exam. Spring Student ID # 3/20/2013

Virtual Memory Overview

CS140 Operating Systems and Systems Programming

File. File System Implementation. Operations. Permissions and Data Layout. Storing and Accessing File Data. Opening a File

! What is main memory? ! What is static and dynamic allocation? ! What is segmentation? Maria Hybinette, UGA. High Address (0x7fffffff) !

Midterm II December 4 th, 2006 CS162: Operating Systems and Systems Programming

Multi-Level Feedback Queues

The Art and Science of Memory Allocation

Virtual Memory. CS 3410 Computer System Organization & Programming

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 13: Address Translation

UW CSE 351, Winter 2013 Final Exam

Address spaces and memory management

University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Science

Virtual Memory. CS 3410 Computer System Organization & Programming. [K. Bala, A. Bracy, E. Sirer, and H. Weatherspoon]

ENCM 369 Winter 2016 Lab 11 for the Week of April 4

CS Operating system Summer Midterm I -- July 11, 2017 You have 115 min (10:00am-11:55pm). Good Luck!

Virtual Memory. Chapter 8

COMP 3361: Operating Systems 1 Final Exam Winter 2009

Virtual Memory I. CSE 351 Spring Instructor: Ruth Anderson

Virtual Memory. CS 351: Systems Programming Michael Saelee

This Unit: Main Memory. Virtual Memory. Virtual Memory. Other Uses of Virtual Memory

CSE 451: Operating Systems Winter Page Table Management, TLBs and Other Pragmatics. Gary Kimura

Multi-level Translation. CS 537 Lecture 9 Paging. Example two-level page table. Multi-level Translation Analysis

CS 351 Exam 3, Fall 2011

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017

MEMORY: SWAPPING. Shivaram Venkataraman CS 537, Spring 2019

CS 322 Operating Systems Practice Midterm Questions

CS 537: Intro to Operating Systems (Fall 2017) Worksheet 3 - Scheduling & Process API Due: Sep 27 th 2017 (Wed) in-class OR Simmi before 5:30 pm

Midterm Exam #2 Solutions April 20, 2016 CS162 Operating Systems

Problem Max Points Score Total 100

Lecture 4: Memory Management & The Programming Interface

Pipelining Exercises, Continued

6.004 Tutorial Problems L20 Virtual Memory

Section 7: Wait/Exit, Address Translation

File System Case Studies. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Address Translation. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Virtual Memory, Address Translation

Virtual Memory: Systems

Learning to Play Well With Others

Changelog. Virtual Memory (2) exercise: 64-bit system. exercise: 64-bit system

CS162 Operating Systems and Systems Programming Lecture 12. Address Translation. Page 1

Advanced Operating Systems (CS 202) Scheduling (1) Jan, 23, 2017

CS Operating system Fall Midterm I -- Oct 5, 2017 You have 75 min. Good Luck!

(a) Which of these two conditions (high or low) is considered more serious? Justify your answer.

we are here Page 1 Recall: How do we Hide I/O Latency? I/O & Storage Layers Recall: C Low level I/O

CSC369 Lecture 5. Larry Zhang, October 19,2015

Virtual to physical address translation

Topics: Memory Management (SGG, Chapter 08) 8.1, 8.2, 8.3, 8.5, 8.6 CS 3733 Operating Systems

CPS 310 second midterm exam, 11/14/2014

CS 4284 Systems Capstone. Virtual Memory Page Tables Godmar Back

CS61C Midterm Review on C & Memory Management

Stanford University Computer Science Department CS 140 Midterm Exam Dawson Engler Winter 1999

TENTAMEN / EXAM. TDDB68 / TDDB72 Processprogrammering och operativsystem / Concurrent programming and operating systems 14 jan 2009, 08:00 12:00 TER2

EECE.4810/EECE.5730: Operating Systems Spring 2017

Operating Systems Design Exam 2 Review: Fall 2010

Chapter 8 Memory Management

File System Case Studies. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

CPS 310 midterm exam #1, 2/19/2016

File System Performance (and Abstractions) Kevin Webb Swarthmore College April 5, 2018

Readings and References. Virtual Memory. Virtual Memory. Virtual Memory VPN. Reading. CSE Computer Systems December 5, 2001.

RCU. ò Walk through two system calls in some detail. ò Open and read. ò Too much code to cover all FS system calls. ò 3 Cases for a dentry:

VFS, Continued. Don Porter CSE 506

Memory Management. 3. What two registers can be used to provide a simple form of memory protection? Base register Limit Register

CS140 Operating Systems Final December 12, 2007 OPEN BOOK, OPEN NOTES

Exploring the file system. Johan Montelius HT2016

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 24

This is an open book, open notes exam. But no online or in-class chatting.

VIRTUAL MEMORY II. Jo, Heeseung

ee457_mt_sp2013.fm 3 ( 48 points) 30 min. Virtual Memory: 6 pts 9 pts 6 pts 6 pts 6 pts 7 pts 3.1 PTBR stands for. It is initiated by (hardware / oper

Transcription:

CS-537: Midterm Exam (Fall 28) Hard Questions, Simple Answers Please Read All Questions Carefully! There are seven (7) total numbered pages. Please put your NAME and student ID on THIS page, and JUST YOUR student ID (but NOT YOUR NAME) on every other page. Why are you doing this? So I can grade the exam anonymously. So, particularly important if you think I have something against you! But of course, I don t. I really do want all of you to do well. Really! OK, most of you. Name and Student ID:

Grading Page Points Total Possible Q 25 Q2 25 Q3 25 Q4 25 Total 2

. Bit by Bit. Assume you have a small virtual address space of size 64 KB. Further assume that this is a system that uses paging and that each page is of size 8 KB. (a) How many bits are in a virtual address in this system? 6 (-KB of address space needs bits, and 64 needs 6; thus 6). (b) Recall that with paging, a virtual address is usually split into two components: a virtual page number (VPN) and an offset. How many bits are in the VPN? 3. Only eight 8-KB pages in a 64-KB address space. (c) How many bits are in the offset? 6 (VA) - 3 (VPN) = 3. Alternately: an 8KB page of course requires 3 bits to address each byte (2 3 = 892). (d) Now assume that the OS is using a linear page table, as discussed in class. How many entries does this linear page table contain? One entry per virtual page. Thus, 8. Now assume you again have a small virtual address space of size 64 KB, that the system again uses paging, but that each page is of size 4 bytes (note: not KB!). (a) How many bits are in a virtual address in this system? Still 6. The address space is the same size. (b) How many bits are in the VPN? 4. (c) How many bits are in the offset? Just 2 (4 bytes). (d) Again assume that the OS is using a linear page table. How many entries does this linear page table contain? 2 4, or 6,384. Finally, the OS tracks the linear page table for a process by remembering it s base address, which we will assume for this problem to be the address where the page table is located in kernel physical memory. Given the address of the start of the page table (pt base), and a VPN that you wish to translate into a PPN (physical page number), write some code to that calculates a pointer to the right page table entry (pte) for this VPN and returns it to the caller: struct pte *p find_pte(void *pt_base, int VPN) { struct pte *p =??? return p; } (a) Write your code here: This would work, because pt base is a void pointer and we need to add the right number of bytes to get us to the page specified by the VPN: struct pte *p = pt_base + (VPN * sizeof(struct pte)); This would also work; by first casting the base as a struct pte, adding VPN to it achieves the same as the code above, and thus points us to the VPN th entry in the array of page table entries. struct pte *p = (struct pte *)pt_base + VPN; 3

2. Scheduling with Uncertainty. Assume we have three jobs that enter a system and need to be scheduled. The first job that enters is called A, and it needs seconds of CPU time. The second, which arrives just after A, is called B, and it needs 5 seconds of CPU time. The third, C, arrives just after B, and needs seconds of CPU time. For all questions involving round-robin, assume that there is no cost to context switching. Also assume that if job X arrives just before Y, a round-robin scheduler will schedule X before Y. (a) Assuming a shortest-job-first (SJF) policy, at what time does B finish? Order of completion: A, C, B. B finishes last, after 35 seconds. (b) Assuming a longest-job-first (LJF) policy, at what time does B finish? B, A, C. B finishes first, after 5 seconds. (c) Assuming a round-robin policy (with a time slice length of second), when does job A finish? A needs to run ten times to finish ( seconds @ second/slice). ABC ABC ABC ABC ABC ABC ABC ABC ABC ABC 2 345 678 9 234 567 89 23 456 789 2 222 222 222 The first A starts at and ends at. Then starts at 3 and ends at 4. Then 6 to 7, 9-, 2-3, 5-6, 8-9, 2-22, 24-25, and finally, starts at 27 and completes its last time slice at 28. Thus, 28. (d) Assuming a round-robin policy (with a time-slice length of second), when does job B finish? This is easy. B runs the longest and thus finishes last. We know the total time for all workloads is 35. Thus, B finishes at 35. (e) Assuming a round-robin policy (with an unknown time-slice which is some value less than or equal to 2 seconds), when does job B finish? With any small time slice, B finishes last again, and thus at 35 again. (f) Assuming a round-robin policy (with an unknown time-slice), for what values of the time-slice will B finish before C? There are two interesting cases. When the time slice is greater than or equal to 5, B will finish in its first time slice and thus finish before C. The other case arises when the time slice is greater than or equal to 7.5 seconds but less than seconds. In this case, B will finish in two slices (as will C), but B will finish first. Of course, SJF is unrealistic, because usually the OS doesn t know how long jobs are. In this system, though, the user gives the OS an estimate. The problem is that the users aren t so good at estimation. In fact, if they tell you a job will last N seconds, it might last anywhere between N 5 and N + 5 seconds. But, being a nice, trusting OS, the OS assumes the user is exactly right. (a) Assuming SJF, what estimates (by the user) will lead the OS to make the worst decisions for these jobs in terms of achieving the lowest average response time? Anything that makes B run first. Thus, anything estimate when A s and C s estimates are each X and B s estimate is Y and X > Y. This is possible because the estimates can only be off by 5 seconds in either direction but the run times of B, (A,C) are only 5 seconds apart. -------------A-------------- -------------C-------------- --------------B-------------- 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 2 (b) In this case, what will the average response time of each job (oops: ALL JOBS) be? B s response time will be (it ran first). A s would be 5 (after B finishes), and C s would be 25 (after A finishes). Thus, ( + 5 + 25)/3, or 3 3. 4

(c) What would the average response time of each job (oops: ALL JOBS) be if you instead had used LJF? If we used LJF with our mis-estimates, C would run (), then A (), and then B (2). Thus 3/3 =. (d) Assume we can arbitrarily change the run-time of job B. What should the run-time of B be changed to so that SJF delivers the best average response time to jobs A, B, and C, even if there are bad estimates? This was accidentally a trick question, and the trick answer is. What I meant was: how far apart do the run-times of A, B, and C have to be for the mis-estimation not to matter? The answer to that would be seconds apart, because the worst mis-estimate is 5 seconds in one direction and 5 seconds in the other. Sorry about that! 5

3. Translation station. Assume a 32-bit virtual address space and further assume that we are using paging. Also assume that the virtual address is chopped into a 2-bit virtual page number (VPN) and a 2-bit offset. The TLB has the following contents in each entry: a 2-bit VPN, a 2-bit PPN, and an 8-bit PID field. This TLB only has four entries, and they look like this: VPN PPN PID FFF AAB FA FF ABC Note all these numbers are in hex. Thus, each represents four bits (e.g., hex F is, hex A is, hex 7 is, and so forth). That is why the 2-bit VPN and PPN are represented by five hex numbers each. Now, for each of the following virtual address, say whether we have a TLB hit or a TLB miss. IMPORTANT: If it is a hit, provide the resulting physical address (in hex). Note: unless said otherwise, virtual addresses are also in hex. (a) PID generates the virtual address: The first five hex numbers are the VPN (x); the last three are the offset (x). Thus, we check if is in the table for PID. hit. page is in table for PID ; translates to FFF. (use the PPN and old offset to get the physical address). (b) PID generates the virtual address: hit. page is in table for PID ; translates to AAB. (c) PID generates the virtual address: FFFFAA miss. no page FFF in table. (d) PID generates the virtual address: FFAA miss. no page F in table. (e) PID generates the virtual address: FFAA miss. no page F in table. (f) PID generates the virtual address: FF hit. page is in table for PID ; translates to FFFFF. (g) PID generates the virtual address: FAB hit. page is in table for PID ; translates to AABFAB. (h) PID generates the virtual address: FFFFF miss. no page FF in table for PID. (i) PID generates the binary virtual address binary becomes becomes hex FF5F. hit. page FF is in table for PID ; translates to ABC5F. (j) PID generates the binary virtual address binary becomes becomes hex FF5F. miss. no page xff for PID in TLB. (k) PID 2 generates the virtual address: miss. no PID 2 entries in table. 6

4. A Simple File System. In this question, we are going to unearth the data and metadata from a very simple file system. The disk this file system is on has a fixed block size of 6 bytes (pretty small!) and there are only 2 blocks overall. A picture of this disk and the contents of each block is shown on the next page. The disk is formatted with a very simple file system, which looks a lot like that old Unix file system we have talked about in class. Specifically, the first block is a super block, the next 9 blocks each contain a single inode, and the final blocks are data. The super block (block ) has just four integers in it:,, 2, and 3, in that order. The root inode of this file system is in inode number 2 (at block 3 in the diagram). The format of an inode is also quite simple: type: means regular file, means directory size: number of blocks in file (can be,, or 2) direct pointer: pointer to first block of file (if there is one) direct pointer: pointer to second block of file (if there is one) (assume that each of these fields takes up 4 bytes of a block) Finally, the format of a directory is also quite simple: name of file inode number of file name of next file inode number of next file (again assume that each field takes up 4 bytes of a block) Finally, assume that in all cases, no blocks are cached in memory. Thus, you always have to read from this disk all the blocks you need to satisfy a particular request. Also assume you never have to read the super block (just to make your life easier). That s it! Well, not quite; now you have to answer some questions: (a) To read the contents of the root directory, which blocks do you need to read? The root directory is called / and its inode (inode number 2) is the block numbered 3. Thus, Block 3 (the root inode) must be read. Inside, it points to block 4 (the contents of the root inode). Thus, block 4 must be read. (b) Which files and directories are in the root directory? List the names of each file/directory as well as its type (e.g., file or directory). In /, there are two directories: a and b. (c) Starting at the root, what are all the reachable regular files in this file system? In directory a, there are two files, foo and bar. In directory b, there are two files, cs and 537. (d) What are all the reachable directories? There are just three: /, /a, and /b. (e) What is the biggest file in the file system? It is bar, which contains 2 blocks. (f) What are the contents of the biggest file? 7 8 9 hi you 2 (g) What blocks are free in this file system? (that is, which inodes/data blocks are not in use?) inodes 5 and 8 (in blocks 6 and 9) are not in use. data blocks 6 and 7 are not in use. 7

3 4 2 3 3 4 5 6 7 8 9 a b 2 3 i 6 7 2 8 H I N T : I N O D E S H I N T : S U P E R B L O C K H I N T : R O O T I N O D E 8 4 2 5 9 7 3 B l o c k B l o c k B l o c k 2 B l o c k 3 B l o c k 4 B l o c k 5 B l o c k 6 B l o c k 7 B l o c k 8 B l o c k 9 f o o h i c s g o o b a r l u v b a r y o u o o f c s 5 3 7 2 g o o d a 5 3 7 B l o c k B l o c k B l o c k 2 B l o c k 3 B l o c k 4 B l o c k 5 B l o c k 6 B l o c k 7 B l o c k 8 B l o c k 9 8