CS140 Operating Systems and Systems Programming

Similar documents
CS 140: Operating Systems and Systems Programming Midterm Exam

CS140 Operating Systems and Systems Programming Midterm Exam

CS140 Operating Systems and Systems Programming Midterm Exam

CS140 Operating Systems and Systems Programming Midterm Exam

CS140 Operating Systems and Systems Programming

(b) External fragmentation can happen in a virtual memory paging system.

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

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

CS140 Operating Systems Midterm Review. Feb. 5 th, 2009 Derrick Isaacson

Computer Science 161

CS 140 Midterm Examination Winter Quarter, 2012

CPS 110 Midterm. Spring 2011

CS140 Operating Systems and Systems Programming

ECE469 - Operating Systems Engineering Exam # March 25

Operating Systems (1DT020 & 1TT802)

CROWDMARK. Examination Midterm. Spring 2017 CS 350. Closed Book. Page 1 of 30. University of Waterloo CS350 Midterm Examination.

CSC369 Lecture 5. Larry Zhang, October 19,2015

Midterm Exam Amy Murphy 6 March 2002

CSL373: Lecture 6 CPU Scheduling

University of Waterloo Midterm Examination Model Solution CS350 Operating Systems

CS-537: Midterm Exam (Spring 2001)

Midterm Exam Solutions Amy Murphy 28 February 2001

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

Midterm Exam Amy Murphy 19 March 2003

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

CS 571 Operating Systems. Midterm Review. Angelos Stavrou, George Mason University

Multiprocessor Systems. COMP s1

1. Consider the following page reference string: 1, 2, 3, 4, 2, 1, 5, 6, 2, 1, 2, 3, 7, 6, 3, 2, 1, 2, 3, 6.

CSE 153 Design of Operating Systems

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

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

Lecture 4: Memory Management & The Programming Interface

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

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Processes and threads

Second Midterm Exam March 21, 2017 CS162 Operating Systems

CS140 Operating Systems and Systems Programming Final Exam

COMP 3361: Operating Systems 1 Final Exam Winter 2009

CS350: Final Exam Review

Operating Systems Comprehensive Exam. Fall Student ID # 10/31/2013

Multiprocessor System. Multiprocessor Systems. Bus Based UMA. Types of Multiprocessors (MPs) Cache Consistency. Bus Based UMA. Chapter 8, 8.

Last Class: CPU Scheduling! Adjusting Priorities in MLFQ!

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

COS 318: Operating Systems. Virtual Memory and Address Translation

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

COS 318: Midterm Exam (October 23, 2012) (80 Minutes)

Midterm I October 11 th, 2006 CS162: Operating Systems and Systems Programming

Lecture 9: Midterm Review

Midterm Exam #2 Solutions October 25, 2016 CS162 Operating Systems

Midterm Exam Solutions and Grading Guidelines March 3, 1999 CS162 Operating Systems

Midterm Exam October 15, 2012 CS162 Operating Systems

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

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

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

To Everyone... iii To Educators... v To Students... vi Acknowledgments... vii Final Words... ix References... x. 1 ADialogueontheBook 1

Two hours. Question ONE is COMPULSORY UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. Date: Friday 25th January 2013 Time: 14:00-16:00

CS140 Operating Systems and Systems Programming Final Exam

CSC369H1 S2016 Midterm Test Instructor: Bogdan Simion. Duration 50 minutes Aids allowed: none. Student number:

Midterm Exam March 3, 1999 CS162 Operating Systems

Review for Midterm. Starring Ari and Tyler

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

Stanford University Computer Science Department CS 240 Quiz 1 Spring May 6, total

Sections 01 (11:30), 02 (16:00), 03 (8:30) Ashraf Aboulnaga & Borzoo Bonakdarpour

Do not start the test until instructed to do so!

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

Memory Management. CSE 2431: Introduction to Operating Systems Reading: , [OSC]

CSE 451 Midterm Exam May 13 th, 2009

Last Class: Deadlocks. Today

KEY CENG 334. Midterm. Question 1. Question 2. Question 3. Question 4. Question 5. Question 6. Total. Name, SURNAME and ID

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

2 nd Half. Memory management Disk management Network and Security Virtual machine

MCS-378 Intraterm Exam 1 Serial #:

CS 318 Principles of Operating Systems

CSE473/Spring st Midterm Exam Tuesday, February 19, 2007 Professor Trent Jaeger

CPS 310 second midterm exam, 11/14/2014

COMP 3361: Operating Systems 1 Midterm Winter 2009

Operating Systems. Process scheduling. Thomas Ropars.

EECS 482 Midterm (Fall 1998)

CMPS 111 Spring 2003 Midterm Exam May 8, Name: ID:

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

Problem Max Points Score Total 100

CS 153 Design of Operating Systems Winter 2016

CS140 Operating Systems and Systems Programming Final Exam

CPSC/ECE 3220 Summer 2017 Exam 2

Page 1. Goals for Today" TLB organization" CS162 Operating Systems and Systems Programming Lecture 11. Page Allocation and Replacement"

Midterm Exam March 13, 2013 CS162 Operating Systems

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

CSE 410 Final Exam Sample Solution 6/08/10

Multi-level Page Tables & Paging+ segmentation combined

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

Page 1. CS162 Operating Systems and Systems Programming Lecture 14. Caching and Demand Paging

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

CS162 Operating Systems and Systems Programming Lecture 14. Caching and Demand Paging

Address spaces and memory management

Multiprocessor Systems. Chapter 8, 8.1

Midterm I October 18 th, 2010 CS162: Operating Systems and Systems Programming

Final Exam Preparation Questions

COMP 300E Operating Systems Fall Semester 2011 Midterm Examination SAMPLE. Name: Student ID:

Process Scheduling. Copyright : University of Illinois CS 241 Staff

Scheduling. CS 161: Lecture 4 2/9/17

CMPSCI 377: Operating Systems Exam 1: Processes, Threads, CPU Scheduling and Synchronization. October 9, 2002

Transcription:

CS140 Operating Systems and Systems Programming Midterm Exam July 25th, 2006 Total time = 60 minutes, Total Points = 100 Name: (please print) In recognition of and in the spirit of the Stanford University Honor Code, I certify that I will neither give nor receive unpermitted aid on this exam. Signature: This exam is closed notes and closed book. No collaboration of any kind is permitted. You have 60 minutes to complete the exam. There are 8 questions totaling 100 points. Some questions have multiple parts. Read all parts before answering! Please check that you have all 8 pages. Before starting, write your initials on each page, in case they become separated during grading. Please print or write legibly. Answers may not require all the space provided. Complete but concise answers are encouraged. SCPD students: If you wish to have the exam returned to you at your company, please check the box. 1 2 3 4 5 6 7 8 Total SCPD? CS140 Midterm Exam Page 1 of 8 Initials

1. [20] A processor has a 32 bit address space, and combines both segmentation and paging. 4 bits for the segment, 16 for the page, and 12 for the offset. A PTE is 4 bytes. Describe in detail what happens in the MMU and OS (use generic terms not the x86 terms) when: (a) [10] A user process does a read of address 0xC0DEDBAD and it is in memory. Segment 0xC, Page 0x0DED, Offset 0xBAD. Lookup the base/bound and where the page table if for segment 0xC. Check them all for validity. Look at the 0x0DED th PTE (0x0DED * 4 bytes into the page table) and see what physical page it is in. Add 0xBAD to that physical page number shifted 12 bits to the left. Access memory. Hopefully all that was in the TLB, so it s all cached in the hardware. (b) [5] What different/more/less happens if it is paged out to disk? If it is paged out to disk, when you look at the PTE, instead of a physical page number you will see the present bit un-set and a disk offset/pointer to the page on disk, and generate a page fault. The OS then requests that block be loaded in, and puts the thread on the blocked list. When the page is returned by the I/O device, a physical page is allocated, the block put there, the PTE present bit is set and the physical page number set. The thread is then put on the ready list, and the instruction restarted. (c) [5] What different/more/less happens if it is not a valid address? At any of the steps in part A) we could find an invalid PTE, an address out of bounds etc. In which case the process would raise a page fault, and since it s not valid, probably be killed. CS140 Midterm Exam Page 2 of 8 Initials

2. [10] Briefly explaining what conditions cause a thread to move between each of the 3 states, and what causes each arrow. Label it N/A if it doesn t happen. 1 RUNNING 2 READY 3 5 6 4 BLOCKED Arrow 1: Process is scheduled and run by the scheduler. Arrow 2: Time slice runs out, but process is still wanting to run. Yield(). Arrow 3: I/O completes, or lock is acquired. Woken up by a semaphore or conditional. Arrow 4: N/A Arrow 5: Any blocking action. I/O request, lock blocks. Arrow 6: N/A CS140 Midterm Exam Page 3 of 8 Initials

3. [10] If you have an OS that s designed for a single CPU, and you want to adapt it to a multi-cpu system, describe the types of changes/additions to the software or hardware you would need to make related to the synchronization primitives (locks, etc ) and why. List three. The hardware must handle synchronization of shared memory, like making sure swap is atomic. The scheduler must take into account that moving a thread from one processor to another is expensive. When you pick which thread to wake when you unlock/up this can be taken into account. On a multi-cpu system, you can use spinlocks much more extensively, because there is another CPU to unlock what you are waiting for. 4. [5] What do semaphores do that condition variables not do, that means you need to be careful how you start the threads? Condition variables have no history. So if you signal before you are waiting, it is lost forever. This means you need to be sure you re waiting thread is active before the signaling one. CS140 Midterm Exam Page 4 of 8 Initials

5. [10] Deadlocks are bad. (a) [5] How can you prevent them? Order all resources in the system, and only allow ascending allocations. Require processes to request all resources at startup. (b) [5] How can you detect them? Check for cycles in the resources of the blocked processes. All solutions to the problem are variations on methods for doing that. CS140 Midterm Exam Page 5 of 8 Initials

6. [10] A system you admin is thrashing, and the users are mad. (a) [5] What are some ways to get into this mess? Running too many processes for too short a timeslice Processes that use more memory then you have in their working set. Bad page replacement algorithm that picks bad pages. Global page replacement where processes are cannibalizing each other. Stupid users. Malicious users. (b) [5] How would you prevent it from happening in YourOS? Optimize your scheduler for high-memory loads. Calculate and use working sets, and use long-term scheduling. Use local page replacement, and slow moving barriers. Good security and educated users. CS140 Midterm Exam Page 6 of 8 Initials

7. [20] Linking (a) [15] Given the following code, list the data segment, text(code) segment, def s and ref s that the linker would create. Assume each line of code is magically 4 bytes, data is also 4 bytes. extern int printf( char *,... ); extern float func( float ); float foo; float bar; float myfunction() { printf( hello world ); foo = func( 1 ); printf( foo 1 = %f\n, foo ); bar = func( foo ); return( bar ); } Text(code) segment: (word call not required) 0: call printf( hello world ); 4: foo = call func( 1 ); 8: call printf( foo 1 = %f\n, foo ); 12: bar = call func( foo ); 16: return( bar ); Data: 0: foo 4: bar Defs: myfunction @0:T foo @ 0:d bar @ 4:d Refs: foo: @ 4:T, 8:T, 12:T bar: @ 12:T, 16:T printf: @ 0:T, 8:T func: @ 4:T, 12:T (b) [5] If this function was placed in a dynamic shared library, describe how it gets called. When the library was loaded, an array with the function offsets would be created. When it s called, it s not a normal jump instruction but a jump to array[function #]. The question didn t ask about lazy loading, but if it was lazy, that array would be filled in on the first call to that function. CS140 Midterm Exam Page 7 of 8 Initials

8. [15] Scheduling (a) [3] What s good and bad about First Come First Served? Pro: Trivial. Con: Convoy effect, avg time to completion is very bad. (b) [3] What s good and bad about Round Robin? Pro: Simple to implement, fair. Con: Avg time to completion for lots of large jobs is worst case. (c) [3] What s good and bad about STCF? Pro: Theoretically best. Con: Future prediction required. Unfair to long jobs. (d) [3] What s good and bad about Multi-Level Feedback Queueing? Pro: Adapts to the actual workload. Keeps I/O busy. Con: Complex, difficult to model, can be slow. (e) [3] What s good and bad about Lottery scheduling? Pro: Simple, Easy to do priority donation, very hard to cheat or drive system to bad behaviors. Con: Only fair in theory, jobs may never actually run. CS140 Midterm Exam Page 8 of 8 Initials