EECE.4810/EECE.5730: Operating Systems Spring Midterm Exam March 8, Name: Section: EECE.4810 (undergraduate) EECE.

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

CSC 716 Advanced Operating System Fall 2007 Exam 1. Answer all the questions. The maximum credit for each question is as shown.

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

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

OS 1 st Exam Name Solution St # (Q1) (19 points) True/False. Circle the appropriate choice (there are no trick questions).

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

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

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

Lecture 2 Process Management

CHAPTER 2: PROCESS MANAGEMENT

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

CS Mid term Exam Maximum points 100; Maximum time allowed: 75 minutes

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

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

Process Turnaround Time Total Wait Time P 1 12 ms 0 ms P 2 21 ms 12 ms P 3 23 ms 18 ms P 4 20 ms 17 ms

COMP 3361: Operating Systems 1 Final Exam Winter 2009

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

ALL the assignments (A1, A2, A3) and Projects (P0, P1, P2) we have done so far.

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

Process a program in execution; process execution must progress in sequential fashion. Operating Systems

Assignment 3 (Due date: Thursday, 10/15/2009, in class) Part One: Provide brief answers to the following Chapter Exercises questions:

Sample Questions. Amir H. Payberah. Amirkabir University of Technology (Tehran Polytechnic)

CMPT 300: Operating Systems I Assignment 1

King Saud University. College of Computer & Information Sciences. Information Technology Department. IT425: Operating Systems.

CS630 Operating System Design, First Exam, Spring 2017,

FCM 710: Architecture of Secure Operating Systems

CS-537: Midterm Exam (Spring 2001)

OS Assignment II. The process of executing multiple threads simultaneously is known as multithreading.

CS153: Midterm (Fall 16)

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

SAMPLE MIDTERM QUESTIONS

First Midterm Exam Solutions October 1, 2018 CS162 Operating Systems

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

Midterm Exam Amy Murphy 6 March 2002

Midterm Exam Solutions Amy Murphy 28 February 2001

Midterm Exam #1 February 28, 2018 CS162 Operating Systems

EECE.4810/EECE.5730: Operating Systems Spring 2017 Homework 1 Solution Due 3:15 PM, Wednesday, 2/1/17

University of Ottawa School of Information Technology and Engineering

COMP 3361: Operating Systems 1 Midterm Winter 2009

Review. Preview. Three Level Scheduler. Scheduler. Process behavior. Effective CPU Scheduler is essential. Process Scheduling

OPERATING SYSTEMS. UNIT II Sections A, B & D. An operating system executes a variety of programs:

Midterm Exam. October 20th, Thursday NSC

Preview. Process Scheduler. Process Scheduling Algorithms for Batch System. Process Scheduling Algorithms for Interactive System

CS370 Operating Systems Midterm Review. Yashwant K Malaiya Spring 2019

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

CS 322 Operating Systems Practice Midterm Questions

Homework Assignment #5

Department of Computer applications. [Part I: Medium Answer Type Questions]

York University Lassonde School of Engineering Department of Electrical Engineering and Computer Science

Processes. Process Concept

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

Q1. State True/false with jusification if the answer is false:

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

MC7204 OPERATING SYSTEMS

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

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

OS Structure. User mode/ kernel mode. System call. Other concepts to know. Memory protection, privileged instructions

Last class: Today: CPU Scheduling. CPU Scheduling Algorithms and Systems

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

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

Operating Systems. Engr. Abdul-Rahman Mahmood MS, PMP, MCP, QMR(ISO9001:2000) alphapeeler.sf.net/pubkeys/pkey.htm

Class average is Undergraduates are performing better. Working with low-level microcontroller timers

Processes and Threads

Properties of Processes

FCM 710: Architecture of Secure Operating Systems

Chapter 3: Processes. Operating System Concepts 8th Edition,

8: Scheduling. Scheduling. Mark Handley

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

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

EECE.4810/EECE.5730: Operating Systems Spring 2018 Programming Project 3 Due 11:59 PM, Wednesday, 4/18/18 Monday, 4/30/18

Operating Systems and Networks Assignment 2

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

1.1 CPU I/O Burst Cycle

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

There are 8 total numbered pages, 6 Questions. You have 60 minutes. Budget your time carefully!

CS370 Operating Systems

Operating Systems (1DT020 & 1TT802)

CSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Sample Midterm Exam Questions (document version 1.1)

OS Structure. User mode/ kernel mode (Dual-Mode) Memory protection, privileged instructions. Definition, examples, how it works?

Operating Systems. Figure: Process States. 1 P a g e

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

TDDB68 Processprogrammering och operativsystem / Concurrent programming and operating systems

CS 370 Operating Systems

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

Operating Systems EDA092, DIT 400 Exam

CSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Sample Exam 1 Questions (document version 1.1)

Processes-Process Concept:

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

Chapter 6: CPU Scheduling

3. CPU Scheduling. Operating System Concepts with Java 8th Edition Silberschatz, Galvin and Gagn

Starting the Threads

Midterm I October 12 th, 2005 CS162: Operating Systems and Systems Programming

CPS 110 Midterm. Out: Wednesday, October 8, 14:50 Due via Hardcopy: 16:05

MARUTHI SCHOOL OF BANKING (MSB)

CPS 110 Midterm. Spring 2011

Reminder. Exam QuesVon 1a. 1 st Midterm Exam Thursday February 18, 9.30am, in class Keep seat open between you and neighbor!

Midterm Exam Amy Murphy 19 March 2003

CPU Scheduling Algorithms

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

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

Transcription:

EECE.4810/EECE.5730: Operating Systems Spring 2017 Midterm Exam March 8, 2017 Name: Section: EECE.4810 (undergraduate) EECE.5730 (graduate) For this exam, you may use two 8.5 x 11 double-sided page of notes. All electronic devices (e.g., cell phones, calculators, laptops) are prohibited. If you have a cell phone, please turn it off prior to the start of the exam to avoid distracting other students. The exam contains 6 questions for a total of 100 points. Please answer the questions in the spaces provided. If you need additional space, use the back of the page on which the question is written and clearly indicate that you have done so. Please note that students enrolled in EECE.5730 must complete three extra problems, which are worth a total of 20 points: Question 1d, on page 4 Question 3c, on page 7 Question 6d, on page 15 You will have three hours to complete this exam. Q1: Process management / 19 + 6 Q2: Inter-process communication / 10 Q3: Multithreading / 11 + 6 Q4: Synchronization / 21 Q5: Scheduling / 20 Q6: Memory management / 19 + 8 TOTAL SCORE / 100 + 20 1

1. (19 + 6 points) UProcess management Parts (a) and (b) of this problem refer to the following program: int main() { pid_t pid1, pid2; pid1 = fork(); if (pid1 == 0) { pid2 = fork(); if (pid2 > 0) { wait(null); printf("1\n"); else execlp("/bin/ls", "ls", NULL); else if (pid1 > 0) { printf("2\n"); return 0; a. (9 points) How many unique processes does this program create, including the initial process? Draw a process tree to support your answer. 2

1 (continued) Program to which part (b) refers: int main() { pid_t pid1, pid2; pid1 = fork(); if (pid1 == 0) { pid2 = fork(); if (pid2 > 0) { wait(null); printf("1\n"); else execlp("/bin/ls", "ls", NULL); else if (pid1 > 0) { printf("2\n"); return 0; b. (5 points) Will any of the created processes become zombie processes after their termination? If so, explain which one(s) and why; if not, explain why not. 3

1 (continued) c. (5 points) How does the operating system differentiate between processes in the ready and waiting states? d. (6 points, EECE.5730 only) Suppose a single parent process creates five different child processes. When each child terminates, the parent process should handle each one in a different, specific way. Describe how the parent process can determine which child terminates so it can handle each one appropriately. 4

2. (10 points) Inter-process communication a. (6 points) Describe how the two major classes of inter-process communication use memory. In your answer, describe (i) what types of data or data structures are used to exchange information, and (ii) in which address space these data are stored. b. (4 points) Explain why indirect communication is often favored over direct communication for message passing inter-process communication. 5

3. (11 + 6 points) Multithreading a. (6 points) Explain why each thread in a multithreaded process needs its own (i) program counter, (ii) register copies, and (iii) stack. b. (5 points) Given the two threads below, is it possible for x to be equal to 4 and y to be equal to 2 when both threads are done? If so, explain how; if not, explain why not. Thread 1 Thread 2 x = 4 y = 5 x = y + 2 y = x - 2 6

3 (continued) c. (6 points, EECE.5730 only) Explain how (i) two threads in the same process could easily share data, and (ii) how each of those two threads can protect its data from the other thread. Your answer should not require any special mechanisms for sharing placing the data appropriately should be sufficient. 7

4. (21 points) Synchronization a. (5 points) Explain what busy waiting is and how it is typically avoided when processes need to wait for access to a synchronization primitive (lock, condition variable, etc.) 8

4 (continued) b. (8 points) The example code below shows a pair of processes (one reader, one writer) that use semaphores to allow (i) multiple reader processes to run simultaneously, while also ensuring (ii) the writer process can only enter its critical section if no readers are executing. Assuming the two semaphores rwsem and rcsem are initialized to 1, and rdcnt is initialized to 0, explain how the two semaphores enable conditions (i) and (ii) above. Reader process do { down(rcsem); rdcnt++; if (rdcnt == 1) down(rwsem); up(rcsem); /* read shared data */ Writer process do { down(rwsem); /* write shared data up(rw_mutex); while (true); down(rcsem); rdcnt--; if (read_count == 0) up(rwsem); up(rcsem); while (true); 9

4 (continued) c. (8 points) Consider a multithreaded bank software package in which the following function is used to transfer money. Assume that the program contains a global array of locks, locks[], with one entry per account number, such that locks[i] is the lock for account number i. void transfer_money(int src_acct, int dest_acct, int amt) { locks[src_acct].lock(); // Lock account sending money locks[dest_acct].lock(); // Lock account receiving money <transfer money> locks[dest_acct].unlock(); locks[src_acct].unlock(); Explain how this function can deadlock if called in multiple threads, and rewrite (in pseudo-code or actual code) the function to remove the deadlock condition. 10

5. (20 points) Scheduling Consider the following set of processes, with the length of the CPU burst time given in milliseconds. Processes may begin executing 1 ms after they arrive (i.e., a process arriving at time 5 could start executing at time 6). Any process arriving at time 0 is in the ready queue when the scheduler makes a decision about the first process to run. Process Burst Priority Arrival time P1 10 1 0 P2 3 4 0 P3 7 2 2 P4 1 2 4 P5 5 3 6 Determine the turnaround time for each process using each of the following scheduling algorithms: (i) first-come, first-serve (FCFS), (ii) shortest job first (SJF), (iii) shortest time to completion first (STCF), (iv) round-robin (RR) with time quantum = 1 ms, and (v) a nonpreemptive priority scheme in which lower numbers indicate higher priority. To break ties between processes (same burst time/priority), use first-come, first-serve ordering. You may use space on both this page and the following page to solve this problem. The list of processes is copied on the next page for your reference. 11

5 (continued) List of processes: Process Burst Priority Arrival time P1 10 1 0 P2 3 4 0 P3 7 2 2 P4 1 2 4 P5 5 3 6 12

6. (19 points) Memory management a. (4 points) Describe one benefit of base and bounds memory management over segmentation, and one benefit of segmentation over base and bounds. b. (5 points) Say the currently running process has 16 active pages, P0-P15, all of which have their reference bits set to 1. If the operating system uses the clock algorithm for page replacement, the pages are ordered numerically around the clock (P0 is first, P1 is second, etc.), and the clock hand currently points to P6, which page will be replaced if a frame is needed to bring in a new page? Explain your answer for full credit. 13

6 (continued) c. (10 points) A portion of the currently running process s page table is shown below: Virtual Reference Valid bit page # bit Dirty bit Frame # 7 1 1 1 3 8 0 0 0 -- 9 1 0 1 4 10 0 0 0 -- 11 1 1 0 0 12 1 1 0 1 Assume the system uses 20-bit addresses and 16 KB pages. The process accesses four addresses: 0x25FEE, 0x2B149, 0x30ABC, and 0x3170F. Determine (i) which address would cause a page to be evicted if there were no free physical frames, (ii) which one would mark a previously clean page as modified, if the access were a write, and (iii) which one accesses a page that has not been referenced for many cycles. For full credit, show all work. 14

6 (continued) d. (8 points, EECE.5730 only) Consider a system with 48-bit virtual addresses and 32-bit physical addresses. The system uses 4 KB pages. Assume each page table entry requires 4 bytes to store. Also, assume the currently running process is using only 16 KB of physical memory the lowest-addressed 8 KB of its virtual address space, and the highest-addressed 8 KB of its virtual address space. If this process uses a two-level page table, and the first- and second-level page tables each use the same number of entries, how much space will that page table require given all of the information above? Show all of your work for full credit. 15