University of Waterloo Midterm Examination Model Solution CS350 Operating Systems

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

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

CS140 Operating Systems and Systems Programming Midterm Exam

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

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

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

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

University of Waterloo Midterm Examination Model Solution

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

Operating Systems (1DT020 & 1TT802)

COMP 3361: Operating Systems 1 Midterm Winter 2009

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

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

CS350: Final Exam Review

COMP SCI 3SH3: Operating System Concepts (Term 2 Winter 2006) Test 2 February 27, 2006; Time: 50 Minutes ;. Questions Instructor: Dr.

Suggested Solutions (Midterm Exam October 27, 2005)

SNS COLLEGE OF ENGINEERING

CS630 Operating System Design, Second Exam, Fall 2014

Midterm Exam Solutions Amy Murphy 28 February 2001

Structure of Computer Systems

University of Waterloo Midterm Examination Term: Winter Year: Solution. begin solution

CS4411 Intro. to Operating Systems Exam 2 Fall 2009

CSE 120 Principles of Computer Operating Systems Fall Quarter, 2002 Halloween Midterm Exam. Instructor: Geoffrey M. Voelker

CS4411 Intro. to Operating Systems Final Fall points 12 pages

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

Q 1. (10 Points) Assume that a process executes the following pseudo codes:

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

CS399 New Beginnings. Jonathan Walpole

1995 Paper 10 Question 7

Computer Science 161

Midterm Exam Amy Murphy 19 March 2003

Module 9: Virtual Memory

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

CPS 110 Midterm. Spring 2011

COMP 2320 Operating Systems 1st Semester, Mid-term Examination

Subject Teacher: Prof. Sheela Bankar

CS 350 Operating Systems Course Notes

Midterm Exam. October 20th, Thursday NSC

University of Waterloo CS350 Midterm Examination Model Solution

CPSC/ECE 3220 Summer 2017 Exam 2

Techno India Batanagar Department of Computer Science & Engineering. Model Questions. Multiple Choice Questions:

CPS 310 second midterm exam, 11/14/2014

Process Description and Control. Chapter 3

Question Points Score Total 100

Module 9: Virtual Memory

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008.

( D ) 4. Which is not able to solve the race condition? (A) Test and Set Lock (B) Semaphore (C) Monitor (D) Shared memory

Operating Systems CMPSC 473 Midterm 2 Review April 15, Lecture 21 Instructor: Trent Jaeger

Chapter 9: Virtual Memory

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

Virtual Memory. CSCI 315 Operating Systems Design Department of Computer Science

General Objectives: To understand the process management in operating system. Specific Objectives: At the end of the unit you should be able to:

Memory management. Requirements. Relocation: program loading. Terms. Relocation. Protection. Sharing. Logical organization. Physical organization

ECE 341. Lecture # 18

CSE 451 Midterm Exam May 13 th, 2009

CS370 Operating Systems

Addresses in the source program are generally symbolic. A compiler will typically bind these symbolic addresses to re-locatable addresses.

CS140 Operating Systems and Systems Programming Midterm Exam

Second Midterm Exam March 21, 2017 CS162 Operating Systems

What is an Operating System?

Operating Systems. Computer Science & Information Technology (CS) Rank under AIR 100

Midterm Exam #2 April 20, 2016 CS162 Operating Systems

CS370 Operating Systems

INSTITUTE OF AERONAUTICAL ENGINEERING Dundigal, Hyderabad COMPUTER SCIENCE AND ENGINEERING QUESTION BANK OPERATING SYSTEMS

Computing Science 300 Sample Final Examination

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

Lecture 2: September 9

THE PROCESS ABSTRACTION. CS124 Operating Systems Winter , Lecture 7

CS 167 Final Exam Solutions

a. A binary semaphore takes on numerical values 0 and 1 only. b. An atomic operation is a machine instruction or a sequence of instructions

Introduction. CS3026 Operating Systems Lecture 01

CS140 Operating Systems and Systems Programming

Chapter 9: Virtual-Memory

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

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.

QUESTION BANK UNIT I

CS 4410 Operating Systems. Review 1. Summer 2016 Cornell University

* What are the different states for a task in an OS?

CS153: Midterm (Fall 16)

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

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

1 /10 2 /15 3 /20 4 /15 total /60. CSE 120 Fall 2007 Midterm Examination. Name. Student ID

Virtual Memory. Virtual Memory. Demand Paging. valid-invalid bit. Virtual Memory Larger than Physical Memory

Operating Systems: Quiz2 December 15, Class: No. Name:

Problem Set 2. CS347: Operating Systems

What s An OS? Cyclic Executive. Interrupts. Advantages Simple implementation Low overhead Very predictable

Eastern Mediterranean University School of Computing and Technology Department of Information Technology. ITEC202 Operating Systems

Objectives and Functions Convenience. William Stallings Computer Organization and Architecture 7 th Edition. Efficiency

a process may be swapped in and out of main memory such that it occupies different regions

STUDENT NAME: STUDENT ID: Problem 1 Problem 2 Problem 3 Problem 4 Problem 5 Total

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad

CSc33200: Operating Systems, CS-CCNY, Fall 2003 Jinzhong Niu December 10, Review

Today: Protection! Protection!

CS 322 Operating Systems Practice Midterm Questions

Operating System Support

( B ) 4. Which is not able to solve the race condition? (A) Test and Set Lock (B) Shared memory (C) Semaphore (D) Monitor

TDDB68 Processprogrammering och operativsystem / Concurrent programming and operating systems

OPERATING SYSTEMS ECSE 427/COMP SECTION 01 WEDNESDAY, DECEMBER 7, 2016, 9:00 AM

Virtual Memory. User memory model so far:! In reality they share the same memory space! Separate Instruction and Data memory!!

CS4411 Intro. to Operating Systems Final Fall points 10 pages

Transcription:

University of Waterloo Midterm Examination Model Solution CS350 Operating Systems Fall, 2003 1. (10 total marks) Suppose that two processes, a and b, are running in a uniprocessor system. a has three threads. b has two threads. All threads in both processes are CU-intensive, i.e., they never block for I/O. he operating system uses simple round-robin scheduling. a. (5 marks) Suppose that all of the threads are user-level threads, and that user-level threads are implemented using a single kernel thread per process. What percentage of the processor s time will be spent running a s threads? For full credit, briefly justify your answer. 50% of the processor s time will be spent running a s threads. Each process has a single kernel thread. hreads never block, so they will always consume their entire scheduling quantum. One a thread has consumed its quantum, it will be preempted in to allow the thread from the other process to run. b. (5 marks) Suppose instead that all of the threads are kernel threads. What percentage of the processor s time will be spent running a s threads? For full credit, briefly justify your answer. 60% of the process s time will be spent running a s threads. In this case there are five kernel threads, each of which will receive 20% of the processor s time. hree of these are associated with process a. 2. (8 marks) In a system that uses simple paging and no LB, each page table entry includes a use (reference) bit, a dirty (modified) bit, a valid bit, and some protection bits. Complete the grid below to indicate how these bits are used by the operating system and by the MMU. In each grid cell, write - if the bit is neither read nor written, write R if the bit is read but not changed, and write W if the bit may be changed. For example, if you believe that the MMU does not use or change the protection bits, you should write - in the fourth row of the MMU column. Operating System Memory Management Unit (MMU) use bit W W dirty bit W W valid bit W R protection bits W R 3. (5 marks) Under what circumstances do page faults occur? Describe the actions taken by the operating system when a page fault occurs. A page fault occurs when a process accesses a page whose page table entry is marked as invalid. he OS takes the following actions: If necessary, choose a page to be replaced (to obtain a frame). If the chosen page is dirty (modified), write it to secondary storage. Bring the faulted page into the selected frame. Update the page table entries for the faulted and replaced pages, and return from the exception. CS350 1 of 6

4. (10 total marks) Consider a variation of the bounded buffer producer/consumer problem in which there are many concurrent producers and the items produced and consumed vary in size. he total capacity of the buffer is N. hese processes use two semaphores to synchronize access to the buffer: full is a counting semaphore with initial value 0 and empty is a counting semaphore with initial value N. Each producer executes the following code when it wishes to insert an item of size k (1 k N) into the buffer: for i from 1 to k do { (empty) } insert item of size k into buffer V(full) he consumer executes the following code when it wishes to remove an item from the buffer: (full) remove item of size k from the buffer for i from 1 to k do { V(empty) } In each of the code fragments shown above, i is an integer variable that is local to each process. Answer each of the following questions. In each case, you must (briefly) justify your answer to receive full credit. a. (2 marks) Does the code above ensure that producers do not insert items into the buffer unless the buffer has room to hold them? It does. Each producer claims k units of space from the buffer (via (empty)) before inserting an item of size k. b. (2 marks) Does the code above ensure that the consumer does not remove items from the buffer unless the buffer contains items to remove. It does. he value of the full semaphore equals the number of items in the buffer. he consumer does (full) before removing an item. c. (2 marks) Does the code above ensure only one process (producer or consumer) will use (insert or remove items from) the buffer at a time? It does not. As long as their is sufficient empty space in the buffer for both of their items, two producers may insert concurrently. Similarly, if the buffer contains items but is not full, a producer and a consumer may use the buffer concurrently. d. (4 marks) Does the code above ensure that processes using the buffer will not deadlock? It does not. For example, deadlock can occur if two producers try to insert items of size greater than N 2. Each producer may claim half of the empty space, at which point neither producer can proceed. CS350 2 of 6

5. (9 total marks) a. (3 marks) Briefly explain the difference between the user mode and the privileged mode of a CU. Why is that difference important to an operating system? User mode is used by application programs, privileged mode is used by the kernel. Certain operations, such as accessing protected memory and executing privileged instructions, can be performed only in privileged mode. he kernel takes advantage of this to retain control over system hardware and other resources, and to isolate itself from application programs. b. (3 marks) Briefly explain the difference between a system call and an interrupt. A system call occurs because of an action (usually, execution of a system call instruction) taken by an application program. An interrupt is generated by system hardware, such as a timer or a disk controller. c. (3 marks) Briefly explain the difference between a system call and a subroutine (or procedure or function or method or whatever you like to call them) call? A system call transfers control from the application to a fixed location in the OS. A procedure call transfers control within an application (or within the OS). A system call causes the CU to change from user to privileged mode. A procedure call does not. 6. (9 total marks) a. (3 marks) here are two types of internal events (events generated by the process itself) that may cause control to transfer from a running user program to the kernel. Name these types of events and briefly describe each one. system call: explicitly programmed by an application to request a service from the operating system exception: an error condition resulting from the execution of an instruction by a application program b. (2 marks) here is one type of external event that may cause control to transfer from a running user program to the kernel. Name and describe that type of event. An interrupt is an event caused by a hardware device. It causes control to transfer to an interrupt handler inside the operating system. CS350 3 of 6

c. (4 marks) Operating systems must track various types of information about the processes and threads that exist in the system. For each type of information listed in the following table, write if the OS tracks that type of information on a per-process basis. Write if the OS tracks that type of information on a per-thread basis. For example, if you believe that the operating system records a page table base register value for each thread, write on that line. If you believe instead that such a value is stored for each process, write. or saved value of program counter register saved value of stack pointer register open file table scheduling priority page table base register value page table limit register value saved values of general CU registers name of executable file 7. (16 marks) For both parts of this question, you should assume that there are three page frames available, and that the page reference string is as follows: 1 4 5 3 2 1 5 3 3 4 5 1 Each number in the reference string is a page number. For both parts of the question, you should assume that all three frames are initially empty. a. (8 marks) Complete the table below under the assumption that the optimal page replacement algorithm (O) is used. Your table should show what the content of each frame would be just after each reference. Use a - to indicate that a frame is empty. In the last row of the table, mark an X for each page reference that results in a page fault. 1 4 5 3 2 1 5 3 3 4 5 1 Frame 1 1 1 1 1 1 1 1 1 1 1 1 1 Frame 2-4 4 3 2 2 2 3 3 4 4 4 Frame 3 - - 5 5 5 5 5 5 5 5 5 5 Fault? x x x x x x x b. (8 marks) Complete the table below under the assumption that the least recently used page (LRU) replacement algorithm is used. Your table should show what the content of each frame would be just after each reference. Use a - to indicate that a frame is empty. In the last row of the table, mark an X for each page reference that results in a page fault. 1 4 5 3 2 1 5 3 3 4 5 1 Frame 1 1 1 1 3 3 3 5 5 5 5 5 5 Frame 2-4 4 4 2 2 2 3 3 3 3 1 Frame 3 - - 5 5 5 1 1 1 1 4 4 4 Fault? x x x x x x x x x x CS350 4 of 6

8. (11 total marks) Consider the following information about resources in a system: here are six classes of allocatable resource labelled R1 through R6 there are five processes labelled 1 through 5 there are two instances of each resource there are some resource instances already allocated to processes, as follows: one instance of R1 held by 1, another held by 2 one instance of R2 held by 3 one instance of R3 held by 3, another held by 4 one instance of R4 held by 3 one instance of R5 held by 3, another held by 4 two instances of R6 held by 5 some processes have requested additional resources, as follows: 1 wants one instance of R4 2 wants one instance of R1 and one instance of R2 3 wants one instance of R1 4 wants one instance of R6 5 wants one instance of R3 a. (5 marks) Draw the resource allocation graph for this system. Use the style of diagram from the lecture notes. b. (2 marks) What is the state (runnable, waiting) of each process? For each process that is waiting, indicate what it is waiting for. 1 is runnable and can acquire R4 2 is waiting for R1 and can acquire R2 3 is waiting for R1 4 is waiting for R6 5 is waiting for R3 CS350 5 of 6

c. (4 marks) Is this system deadlocked? If so, state which processes are involved. If not, give an execution sequence that eventually ends, showing resource acquisition and release at each step. here is no deadlock. A possible sequence: 1 acquires R4, runs to completion and releases R1 and R4 2 acquires R1 and R2, runs to completion and releases R1 (two instances) and R2 3 acquires R1, runs to completion and releases R1, R2, R3, R4 and R5 5 acquires R3, runs to completion and releases R3 and R6 (two instances) 4 acquires R6, runs to completion and releases R3, R5 and R6 9. (12 total marks) Consider an MMU which uses segmentation and paging combined, with the following characteristics: 4 GByte (2 32 byte) physical memory 8 KByte (2 13 byte) frame size maximum of 16 segments per process maximum segment size of 64 MByte (2 26 byte) a. (3 marks) What is size (in bits) of a virtual address in this system? What parts does it have, and how big (in bits) is each part? 30 bits: 4-bit segment number, 13-bit page number and 13-bit offset b. (3 marks) What is size (in bits) of a physical address in this system? What parts does it have, and how big is each part? 32 bits: 19-bit frame number and 13-bit offset c. (3 marks) What are the two address-translation components of a segment table entry, and how big (in bits) are they? page-table length: 13 bits physical address of page-table: 32 bits d. (3 marks) What is the address-translation component of a page table entry, and how big (in bits) is it? 19 bits for a frame number CS350 6 of 6