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

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

Chapter 5: CPU Scheduling

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

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

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

CSE 120 Principles of Operating Systems Spring 2017

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

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

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

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

CSL373: Lecture 6 CPU Scheduling

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

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

Operating Systems (1DT020 & 1TT802)

CSE 153 Design of Operating Systems

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

Lecture Topics. Announcements. Today: Uniprocessor Scheduling (Stallings, chapter ) Next: Advanced Scheduling (Stallings, chapter

COSC243 Part 2: Operating Systems

CHAPTER 2: PROCESS MANAGEMENT

CS370 Operating Systems

UNIT:2. Process Management

Operating System Concepts Ch. 5: Scheduling

CSE 120. Fall Lecture 8: Scheduling and Deadlock. Keith Marzullo

CSE 120 Principles of Operating Systems

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

Lecture 2 Process Management

1.1 CPU I/O Burst Cycle

CPU Scheduling Algorithms

Properties of Processes

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

8: Scheduling. Scheduling. Mark Handley

CSE120 Principles of Operating Systems. Prof Yuanyuan (YY) Zhou Scheduling

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

OPERATING SYSTEMS: Lesson 4: Process Scheduling

Last Class: Processes

SMD149 - Operating Systems

Chapter 6: CPU Scheduling

CPU Scheduling (1) CPU Scheduling (Topic 3) CPU Scheduling (2) CPU Scheduling (3) Resources fall into two classes:

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

CPU Scheduling. CSE 2431: Introduction to Operating Systems Reading: Chapter 6, [OSC] (except Sections )

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

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

Operating Systems. Lecture Process Scheduling. Golestan University. Hossein Momeni

Unit 3 : Process Management

Midterm Exam Amy Murphy 6 March 2002

Process- Concept &Process Scheduling OPERATING SYSTEMS

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

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

Operating Systems. Process scheduling. Thomas Ropars.

Announcements/Reminders

CS3733: Operating Systems

CS 322 Operating Systems Practice Midterm Questions

COMP 3361: Operating Systems 1 Final Exam Winter 2009

CPU Scheduling: Part I ( 5, SGG) Operating Systems. Autumn CS4023

CSCE Operating Systems Scheduling. Qiang Zeng, Ph.D. Fall 2018

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

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

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

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

Operating System Review Part

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

CS 326: Operating Systems. CPU Scheduling. Lecture 6

CPU Scheduling. Schedulers. CPSC 313: Intro to Computer Systems. Intro to Scheduling. Schedulers in the OS

CS 318 Principles of Operating Systems

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

Job Scheduling. CS170 Fall 2018

Scheduling of processes

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

FCM 710: Architecture of Secure Operating Systems

I/O Systems. Amir H. Payberah. Amirkabir University of Technology (Tehran Polytechnic)

Course Syllabus. Operating Systems

Main Points of the Computer Organization and System Software Module

Lecture 9: Midterm Review

Advanced Operating Systems (CS 202) Scheduling (1)

CPU scheduling. Alternating sequence of CPU and I/O bursts. P a g e 31

Topic 4 Scheduling. The objective of multi-programming is to have some process running at all times, to maximize CPU utilization.

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

Maximum CPU utilization obtained with multiprogramming. CPU I/O Burst Cycle Process execution consists of a cycle of CPU execution and I/O wait

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

QUESTION BANK UNIT I

Chapter 6: CPU Scheduling

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

Scheduling. Scheduling. Scheduling. Scheduling Criteria. Priorities. Scheduling

CISC 7310X. C05: CPU Scheduling. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 3/1/2018 CUNY Brooklyn College

Chapter 5 CPU scheduling

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

EECS 482 Introduction to Operating Systems

Midterm Exam Solutions Amy Murphy 28 February 2001

FCM 710: Architecture of Secure Operating Systems

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

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

CPSC/ECE 3220 Summer 2017 Exam 2

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

Process Scheduling Part 2

Scheduling. The Basics

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

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

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

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

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

Transcription:

Sample Questions Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 1 / 29

Question 1 Suppose a thread is running in a critical section of code, meaning that it has acquired all the locks through proper arbitration. Can it get context switched? Why or why not? Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 2 / 29

Answer 1 Yes, it can get context switched. Locks (especially user-level locks) are independent of the scheduler. Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 3 / 29

Question 2 What is a thread? What is a process? Describe how to create each of these. Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 4 / 29

Answer 2 A thread is a piece of an executing program. It contains a program counter (PC), processor registers and a stack. A process consists of one or more threads in an address space. Threads are created by allocating a new stack and Thread Control Block (TCB), initializing the registers in the TCB properly, then placing the new TCB on the ready queue. A process is created by allocating a new Process Control Block (PCB), address space descriptor/page tables, and a new thread. In UNIX, processes are created by a fork() system call which also creates a complete copy of the parent process for the new (child) process. Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 5 / 29

Question 3 What is a thread-join operation? Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 6 / 29

Answer 3 Thread-join is issued by one thread when it wants to stop and wait for the termination of another thread. On termination of the target thread, the original thread resumes execution. Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 7 / 29

Question 4 What is an interrupt? What happens when an interrupt occurs? What is the function of an interrupt controller? Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 8 / 29

Answer 4 An interrupt is an external signal. When interrupt occurs and is enabled, then the processor will stop the current running code, save the Program Counter (PC), disable interrupts, and jump to an appropriate interrupt handler. The function of the interrupt controller is to provide some control over which hardware interrupt signals are enabled and what their priority is. Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 9 / 29

Question 5 What is a monitor? Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 10 / 29

Answer 5 A monitor is a synchronization mechanism that abstracts away protection and scheduling access to shared data through the use of a lock and zero or more condition variables. Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 11 / 29

Question 6 Six jobs are waiting to be run. Their expected running times are 10, 8, 6, 3, 1, and X. In what order should they be run to minimize average completion time? State the scheduling algorithm that should be used and the order in which the jobs should be run. (Your answer will depend on X ). Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 12 / 29

Answer 6 Shortest Job First or Shortest Remaining Processing Time X 1: X, 1, 3, 6, 8, 10 1 < X 3: 1, X, 3, 6, 8, 10 3 < X 6: 1, 3, X, 6, 8, 10 6 < X 8: 1, 3, 6, X, 8, 10 8 < X 10: 1, 3, 6, 8, X, 10 X > 10: 1, 3, 6, 8, 10, X Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 13 / 29

Question 7 Name and describe 4 different scheduling algorithms. What are the advantages and disadvantages of each? Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 14 / 29

Answer 7 (1/4) FCFS (FIFO): The first process that arrives gets to run all the way to completion + Simple and quick to choose the next thread + Fair in the sense that jobs run in the order they arrived - Long wait times for short jobs that get stuck behind long jobs - Not fair for jobs that can finish very quickly but must wait a long tim Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 15 / 29

Answer 7 (2/4) Round Robin: Scheduler rotates through all threads, allowing each to run for some time quantum + Fair because gives every thread a chance to run - Potentially large overhead from frequent context switching - Can result in large completion times, especially for threads with similar run times Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 16 / 29

Answer 7 (3/4) Scheduler runs the shortest job first, non- Shortest Job First: preemptive + Results in low average completion time - Long jobs can et stuck behind short jobs - Requires knowledge of the future, hard to predic Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 17 / 29

Answer 7 (4/4) Shortest Remaining Processing Time: Works like SJF, but preemptive +/- Same as SJF Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 18 / 29

Question 8 Here is a table of processes and their associated running times. All of the processes arrive in numerical order at time 0. Show the scheduling order for these processes under 3 policies: First Come First Serve (FCFS), Shortest-Remaining-Time-First (SRTF), Round-Robin (RR) with timeslice quantum = 1. Process ID CPU Running Time 1 2 2 6 3 1 4 4 5 3 Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 19 / 29

Answer 8 Time slot FCFS SRTF RR 0 1 3 1 1 1 1 2 2 2 1 3 3 2 5 4 4 2 5 5 5 2 5 1 6 2 4 2 7 2 4 4 8 3 4 5 9 4 4 2 10 4 2 4 11 4 2 5 12 4 2 2 13 5 2 4 14 5 2 2 15 5 2 2 Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 20 / 29

Question 9 For each process in each schedule above, indicate the queue wait time and completion time (otherwise known as turnaround time, TRT). Note that wait time is the total time spend waiting in queue (all the time in which the task is not running): Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 21 / 29

Answer 9 Scheduler P1 P2 P3 P4 P5 FCFS wait 0 2 8 9 13 FCFS TRT 2 8 9 13 16 SRTF wait 1 10 0 6 3 SRTF TRT 3 16 1 10 6 RR wait 4 10 2 10 9 RR TRT 6 16 3 14 12 Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 22 / 29

Question 10 What are three methods of dealing with the possibility of deadlock? Explain each method and its consequences to programmer of applications. Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 23 / 29

Answer 10 Ignore it: do nothing about it. Application programmers have to deal with deadlock or not care if it happens Prevent it: use Bankers Algorithm and only allow allocations that cannot possibly lead to deadlock. Application programmer has to specify maximum possible resource needs Detect it and recover: check dependency graph for cycles and kill a thread in the cycle. Application programmer has to deal with their threads possibly getting killed. Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 24 / 29

Question 11 Suppose that we have several processes and several resources. Name three ways of preventing deadlock between these processes. Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 25 / 29

Answer 11 Atomically acquire all resources at the start of execution Use the Banker s Algorithm Acquire all resources in a specified order Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 26 / 29

Question 12 Suppose that we have the following resources: A (12 instances), B (9 instances), C (12 instances) and four threads T1, T2, T3, T4. Further, assume that the processes have the following maximum requirements and current allocations. Is the system potentially deadlocked (i.e., unsafe)? In making this conclusion, you must show all your steps, intermediate matrices, etc. Maximum Thread ID A B C T1 4 3 4 T2 5 3 3 T3 6 4 3 T4 4 1 2 Current Allocation Thread ID A B C T1 2 1 3 T2 1 2 3 T3 5 4 3 T4 2 1 2 Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 27 / 29

Answer 12 Available A B C 2 1 1 Need Thread ID A B C T1 2 2 1 T2 4 1 0 T3 1 0 0 T4 2 0 0 Available after running Thread ID A B C T4 4 2 3 T3 9 6 6 T2 10 8 9 T1 12 9 12 No. Running the Bankers Algorithm, we see that we can give T4 all the resources it might need and run it to completion. Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 28 / 29

Questions? Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 29 / 29