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

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

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

CHAPTER 2: PROCESS MANAGEMENT

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

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

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

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

Lecture 2 Process Management

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

Lecture 17: Threads and Scheduling. Thursday, 05 Nov 2009

CS 370 Operating Systems

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

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

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

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

SAMPLE MIDTERM QUESTIONS

Properties of Processes

Homework Assignment #5

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

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

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

1.1 CPU I/O Burst Cycle

MARUTHI SCHOOL OF BANKING (MSB)

Mid Term from Feb-2005 to Nov 2012 CS604- Operating System

OPERATING SYSTEMS: Lesson 4: Process Scheduling

Subject: Operating System (BTCOC403) Class: S.Y.B.Tech. (Computer Engineering)

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

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

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

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

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

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

CS604 - Operating System Solved Subjective Midterm Papers For Midterm Exam Preparation

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

Chapter 5: CPU Scheduling

(MCQZ-CS604 Operating Systems)

University of Ottawa School of Information Technology and Engineering

Chapter 5: CPU Scheduling

Course Syllabus. Operating Systems

CS3733: Operating Systems

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

CPU Scheduling Algorithms

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

COMP 3361: Operating Systems 1 Final Exam Winter 2009

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

8: Scheduling. Scheduling. Mark Handley

TDIU25: Operating Systems II. Processes, Threads and Scheduling

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

Exam Guide COMPSCI 386

B. V. Patel Institute of Business Management, Computer &Information Technology, UTU

Problem Set: Processes

QUESTION BANK UNIT I

UNIT 2 Basic Concepts of CPU Scheduling. UNIT -02/Lecture 01

CPU Scheduling. Operating Systems (Fall/Winter 2018) Yajin Zhou ( Zhejiang University

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

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

So far. Next: scheduling next process from Wait to Run. 1/31/08 CSE 30341: Operating Systems Principles

Processes-Process Concept:

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

Chapter 5: Process Scheduling

MC7204 OPERATING SYSTEMS

CSE 153 Design of Operating Systems

CMPT 300: Operating Systems I Assignment 1

CS370 Operating Systems Midterm Review

Processes. Overview. Processes. Process Creation. Process Creation fork() Processes. CPU scheduling. Pål Halvorsen 21/9-2005

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

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

Processes and Threads

518 Lecture Notes Week 3

Chapter 5 CPU scheduling

CPU Scheduling. Daniel Mosse. (Most slides are from Sherif Khattab and Silberschatz, Galvin and Gagne 2013)

Chapter 5: CPU Scheduling. Operating System Concepts 8 th Edition,

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

Problem Set: Processes

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

Chapter 6: CPU Scheduling. Operating System Concepts 9 th Edition

UNIT - II PROCESS MANAGEMENT

CPU Scheduling. Rab Nawaz Jadoon. Assistant Professor DCS. Pakistan. COMSATS, Lahore. Department of Computer Science

Chapter 6: CPU Scheduling

Process Concept Process in Memory Process State new running waiting ready terminated Diagram of Process State

Operating Systems. Scheduling

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

Chendu College of Engineering & Technology

OPERATING SYSTEMS. After A.S.Tanenbaum, Modern Operating Systems, 3rd edition. Uses content with permission from Assoc. Prof. Florin Fortis, PhD

SNS COLLEGE OF ENGINEERING

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

Operating Systems. Process scheduling. Thomas Ropars.

Unit 3 : Process Management

Operating Systems. Lecture 05

CPU Scheduling. Basic Concepts. Histogram of CPU-burst Times. Dispatcher. CPU Scheduler. Alternating Sequence of CPU and I/O Bursts

Student Name:.. Student ID... Course Code: CSC 227 Course Title: Semester: Fall Exercises Cover Sheet:

Process Scheduling. Copyright : University of Illinois CS 241 Staff

CS370 Operating Systems

Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras

CS4411 Intro. to Operating Systems Exam 2 Fall 2009

Operating Systems (1DT020 & 1TT802)

Lecture 5 / Chapter 6 (CPU Scheduling) Basic Concepts. Scheduling Criteria Scheduling Algorithms

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

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

Midterm Exam. October 20th, Thursday NSC

Transcription:

CS 470 - Mid term Exam Maximum points 100; Maximum time allowed: 75 minutes Name: Note: Answer all questions. Your answers should be brief and precise to the point. Note that a statement is true means it is always true, false means it is sometimes true or never true 1. For each of the following statements, state whether it is true or false. (10 points) (a) I/O devices and CPU can execute concurrently (b) Each device controller maintains a local buffer storage and a set of special purpose registers. (c) Under Blocking I/O, after I/O starts, control returns to user program only upon I/O completion. (d) A multi-threaded process has one program counter per thread. (e) Operating system ensures efficient operation of the system. (f) Services provided by the operating system are accessed from user programs through system calls. (g) Under layered approach for designing operating system, operating system is divided into a number of layers, each built on top of lower layers. (h) Operating system helps in protecting unauthorized access to resources. (i) Operating system allocates resources to processes. (j) Operating system provides an user-interface to use the computer system. 1

2. (5+10+15=30 points) (a) Describe briefly the functions of the following : (i) long term scheduler. (ii) short term scheduler, (iii) medium term scheduler (b) For each of the following statements, state whether it is true or false. i. fork() system call creates a new process whose address space is identical to its parent process. ii. fork() system call returns 0 in parent and process id of the child in the child process. iii. fork() system call returns 2 if it fails. iv. exec() system call and it variations replace the new process memory space with a new program. v. exec() system call never returns. vi. Multithreading an interactive application increases responsiveness to the user. vii. Threads have their own registers and stack. viii. Threads share memory and other resources of the process they belong. ix. Multithreaded programming provides a mechanism for more efficient use of the multiple cores in current day desktops. x. Process creation is more expensive than thread creation. xi. Two or more processes can be executing concurrently even if there is only one processor. xii. Two or more processes can be executing in parallel even if there is only one processor. 2

(c) Consider the following program: #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/wait.h> main() { int id1,id2,id; if ((id2=fork())==0){ execlp("pwd", "pwd",null); printf("hello World 0 \n"); if ((id1=fork())==0){ id=fork(); execlp("ls", "ls",null); printf("hello World 1 \n"); id= fork(); id=fork(); printf("hello World 2 \n"); Suppose foo is the executable file for this program. What is one possible output you will get when foo is executed (assume that the directory in which the executable file of this program, called foo lies is the directory /fun and foo is the only file in the directory /fun )? Will it produce the same output (i.e., in the same order) on all machines and under all runs? Justify your answer. How many processes are created when you run foo? Draw the parent child relationship diagram among the processes created as a result of its execution. (Note that pwd is the Linux command for outputting the present working directory and ls is the Linux command for listing the contents of current directory.) 3

3. (10+10+10+10=40 points) (a) If concurrent access to shared resource is not synchronized, shared resource may be left in an inconsistent state. Explain with an example clearly why this statement is true. (b) Explain the three requirements a solution to the critical section problem needs to satisfy? 4

(c) A parking garage has space for parking 100 vehicles. Write a semaphore-based solution to control access to the garage. Make the following assumptions: The Full light sign at the entrance is turned on when the garage is full. Assume that you have two built-in commands turn on Full sign and turn off Full sign for turning the Full sign on or off. A driver enters the garage when the Full sign is off after swiping her/his Decal into the machine at the entrance. When the driver leaves the garage he/she swipes the card at the exit and leaves. The machine at the entrance runs the Enter process and the machine at the exit runs the Exit process. Write the code for the two processes. Use as many semaphores and shared variables as you need. Shared Data Structures: Process Enter: do{ Wait until someone swipes her/his Decal; Process Exit: do{ Wait until someone swipes her/his Decal; while(1); while(1); 5

(d) Write a monitor-based solution for the following problem: The two ends of a rope are tied to the top of the two trees on opposite banks of a river. Monkeys on each side of the river use this rope to cross the river. The rope can be used by monkeys crossing from only one side of the river at any given time. At any given time, any number of monkeys are allowed to use the rope as long as they are all crossing the river in the same direction. Write a monitor-based solution for synchronizing the Monkeys access to the rope. Your solution has to ensure mutual exclusion (i.e, it should not allow monkeys to cross in both directions simultaneously) and progress property. It does not have to satisfy the bounded waiting property. If you like, you can use the following incomplete code: monitor M { enum direction {Left_To_Right, Right_To_Left Procedure GrabTheRope(direction d){ Procedure ReleaseTheRope (direction d){ Initialization: Monkey crossing Left To Right Monkey crossing Right To Left { { M.GrabTheRope(Left_To_Right) M.GrabTheRope(Right_To_Left) Cross the river; Cross the river; M.ReleaseTheRope(Left_To_Right) M.ReleaseTheRope(Right_To_Left) 6

4. For each of the following statements, state whether it is true or false. (5 points) (a) A CPU scheduling algorithm should strive for minimizing CPU utilization. (b) A CPU scheduling algorithm should strive for maximizing turnaround time. (c) FCFS scheduling algorithm has convoy effect. (d) Shortest job first (SJF) scheduling algorithm is a priority based scheduling algorithm (e) Priority based scheduling algorithm can cause starvation. 5. Load balancing counteracts the benefits of processor affinity. Explain why? (5 points) 7

6. (10 points) Consider the following set of processes that arrive at the times indicated, with the length of CPU-burst time given (all in milliseconds). Processes Burst Time Arrival time Priority ========== ========== ============ ======== P1 30 0 5 P2 15 5 10 P3 20 10 15 Calculate the average waiting time and average turn-around time under each of the following scheduling algorithms: (i) Non-Preemptive Shortest Job First scheduling. (Note that priority is not used in this) (ii) Round Robin (with 20 ms time slice). (Note that priority is not used in this) (iii) Priority based scheduling (higher number means higher priority; if a higher priority process arrives while a lower priority process is executing, the lower priority process will be preempted). 8