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

Similar documents
UNIT:2. Process Management

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

CSE 120 Principles of Operating Systems

CSE 153 Design of Operating Systems

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

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

CS 153 Design of Operating Systems Winter 2016

Lecture 9: Midterm Review

CHAPTER 2: PROCESS MANAGEMENT

Deadlocks. Dr. Yingwu Zhu

Midterm Exam. October 20th, Thursday NSC

The Deadlock Problem. A set of blocked processes each holding a resource and waiting to acquire a resource held by another process in the set.

CS153: Deadlock. Chengyu Song. Slides modified from Harsha Madhyvasta, Nael Abu-Ghazaleh, and Zhiyun Qian

Chapter 7: Deadlocks

Chapter 7: Deadlocks. Operating System Concepts with Java 8 th Edition

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

OPERATING SYSTEMS. Prescribed Text Book. Operating System Principles, Seventh Edition. Abraham Silberschatz, Peter Baer Galvin and Greg Gagne

Chendu College of Engineering & Technology

System Model. Types of resources Reusable Resources Consumable Resources

Chapter 7: Deadlocks. Operating System Concepts 8th Edition, modified by Stewart Weiss

OPERATING SYSTEMS. Deadlocks

CSI3131 Final Exam Review

Chapter 8: Deadlocks. The Deadlock Problem

The Deadlock Problem. Chapter 8: Deadlocks. Bridge Crossing Example. System Model. Deadlock Characterization. Resource-Allocation Graph

Last Class: Synchronization Problems. Need to hold multiple resources to perform task. CS377: Operating Systems. Real-world Examples

Operating Systems ECE344. Ding Yuan

COP 4610: Introduction to Operating Systems (Spring 2016) Chapter 7 Deadlocks. Zhi Wang Florida State University

Chapter 7: Deadlocks. Operating System Concepts 8 th Edition,

CMSC 412. Announcements

CLASS: II YEAR / IV SEMESTER CSE SUBJECT CODE AND NAME: CS6401 OPERATING SYSTEMS UNIT I OPERATING SYSTEMS OVERVIEW

Chapter 7: Deadlocks

QUESTION BANK UNIT I

Chapter 7: Deadlocks. Operating System Concepts 9 th Edition

CS140 Operating Systems and Systems Programming Midterm Exam

Chapter 7: Deadlocks. Operating System Concepts 8 th Edition,

The Deadlock Problem

Deadlock. Concurrency: Deadlock and Starvation. Reusable Resources

Chapter 7 : 7: Deadlocks Silberschatz, Galvin and Gagne 2009 Operating System Concepts 8th Edition, Chapter 7: Deadlocks

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Operating System Third Year CSE( Sem:I) 2 marks Questions and Answers UNIT I

The Deadlock Problem

Chapter 6: CPU Scheduling

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


The Deadlock Problem (1)

CPU Scheduling: Objectives

Chapter 7: Deadlocks. Chapter 7: Deadlocks. The Deadlock Problem. Chapter Objectives. System Model. Bridge Crossing Example

CS 318 Principles of Operating Systems

Silberschatz, Galvin and Gagne 2013! CPU cycles, memory space, I/O devices! " Silberschatz, Galvin and Gagne 2013!

CSCI-GA Operating Systems Lecture 3: Processes and Threads -Part 2 Scheduling Hubertus Franke

Last Class: Monitors. Real-world Examples

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

Properties of Processes

Lecture 7 Deadlocks (chapter 7)

Deadlocks. Operating System Concepts - 7 th Edition, Feb 14, 2005

CS307: Operating Systems

MC7204 OPERATING SYSTEMS

Main Points of the Computer Organization and System Software Module

Chapter 7: Deadlocks. Operating System Concepts 8 th Edition,! Silberschatz, Galvin and Gagne 2009!

Deadlocks. Minsoo Ryu. Real-Time Computing and Communications Lab. Hanyang University.

What is the Race Condition? And what is its solution? What is a critical section? And what is the critical section problem?

The Slide does not contain all the information and cannot be treated as a study material for Operating System. Please refer the text book for exams.

CS370 Operating Systems Midterm Review

UNIT-3 DEADLOCKS DEADLOCKS

Deadlocks. Prepared By: Kaushik Vaghani

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

CS370 Operating Systems Midterm Review. Yashwant K Malaiya Spring 2019

Chapter 7: Deadlocks. Operating System Concepts 9 th Edition! Silberschatz, Galvin and Gagne 2013!

CS 318 Principles of Operating Systems

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

Chapter 8: Deadlocks

Chapter 8: Deadlocks. The Deadlock Problem. System Model. Bridge Crossing Example. Resource-Allocation Graph. Deadlock Characterization

Deadlocks. Deadlock Overview

CS307 Operating Systems Deadlocks

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Deadlocks. Bridge Crossing Example. The Problem of Deadlock. Deadlock Characterization. Resource-Allocation Graph. System Model

Principles of Operating Systems

Chapter 7: Deadlocks

Module 7: Deadlocks. The Deadlock Problem. Bridge Crossing Example. System Model

Bridge Crossing Example

CS420: Operating Systems. Deadlocks & Deadlock Prevention

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

Uniprocessor Scheduling. Basic Concepts Scheduling Criteria Scheduling Algorithms. Three level scheduling

CS3733: Operating Systems

Chapter 8: Deadlocks. Bridge Crossing Example. The Deadlock Problem

Chapter 7: Deadlocks. Operating System Concepts 9th Edition DM510-14

Processes-Process Concept:

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

Readings and References. Deadlock. Deadlock. Simple Traffic Gridlock Example. Reading. CSE Computer Systems November 30, 2001.

CSE 120. Summer, Inter-Process Communication (IPC) Day 3. Inter-Process Communication (IPC) Scheduling Deadlock. Instructor: Neil Rhodes

UNIT-5 Q1. What is deadlock problem? Explain the system model of deadlock.

COMP 3713 Operating Systems Slides Part 3. Jim Diamond CAR 409 Jodrey School of Computer Science Acadia University

CSE Opera+ng System Principles

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

Chapter 5: CPU Scheduling

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

Chapter 8: Deadlocks. The Deadlock Problem

LECTURE 3:CPU SCHEDULING

Lecture 2 Process Management

Module 6: Deadlocks. Reading: Chapter 7

Timers 1 / 46. Jiffies. Potent and Evil Magic

Transcription:

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

Class Midterm: Grading 2 Grading Midterm: 25% Theory Part 60% (1h 30m) Programming Part 40% (1h) Theory Part (Closed Books): Similar to your assignments Questions will cover all topics Programming Part (Open Books): Debug given code & Add functionality (Select C or Java) Explain your changes Emphasis on logic not on syntax

Midterm Topics 3 Introduction, Threads and Processes Inter-process Communication, Synchronization CPU Scheduling Deadlocks

Parallel Systems 4 Multiprocessor systems with more than one CPU in close communication. Tightly coupled system processors share memory and a clock; communication usually takes place through the shared memory. Advantages of parallel system Increased throughput Economy of scale Increased reliability graceful degradation fault-tolerant systems

Parallel Systems (Cont.) 5 Symmetric multiprocessing (SMP) All processors are peers Kernel routines can execute on different CPUs, in parallel Asymmetric multiprocessing Master/slave structure The kernel runs on a particular processor Other CPUs can execute user programs and OS utilities.

Parallel Systems (Cont.) 6 Multi-core architectures Include multiple computing cores on a single chip Faster and more energy-efficient than multiple chips with single cores

Processes 7 Process Concept Process States Process Creation and Termination Process Scheduling Process Communication

Process Concept 8 Process: a program in execution process execution must progress in sequential fashion. A program is a passive entity, whereas a process is an active entity with a program counter and a set of associated resources.

The Process (Cont.) 9 Each process has its own address space: Text section (text segment) contains the executable code Data section (data segment) contains the global variables Stack contains temporary data (local variables, return addresses..) A process may contain a heap, which contains memory that is dynamically allocated at run-time. The program counter and CPU registers are part of the process context.

CPU Switch From Process to Process 10

Context Switch 11 When CPU switches to another process, the system must save the state of the old process and load the saved state for the new process. Context-switch time is pure overhead; the system does no useful work while switching. Overhead dependent on hardware support (typically 1-1000 microseconds).

Multithreading 12 When a multithreaded process is run on a single CPU system, the threads take turns running. All threads in the process have exactly the same address space. Per Process Items Address Space Global Variables Open Files Accounting Information Per Thread Items Program Counter Registers Stack State

Process Communication 13 Mechanism for processes to communicate and to synchronize their actions. Two models: Communication through a shared memory region Communication through message passing

Communication Models 14 Message Passing Shared Memory

Process Synchronization 15 Race Conditions The Critical Section Problem Synchronization Hardware Semaphores Classical Problems of Synchronization Monitors

Concurrent Access to Shared Data 16 Suppose that two processes A and B have access to a shared variable Balance : PROCESS A: PROCESS B: Balance = Balance - 100 Balance = Balance - 200 Further, assume that Process A and Process B are executing concurrently in a time-shared, multi-programmed system.

CPU Scheduling 17 Basic Concepts Scheduling Criteria Scheduling Algorithms First-Come-First-Served Shortest-Job-First, Shortest-remaining-Time-First Priority Scheduling Round Robin Multi-level Queue Multi-level Feedback Queue

Non-preemptive vs. Preemptive Scheduling 18 Under non-preemptive scheduling, each running process keeps the CPU until it completes or it switches to the waiting (blocked) state. Under preemptive scheduling, a running process may be also forced to release the CPU even though it is neither completed nor blocked. In time-sharing systems, when the running process reaches the end of its time quantum (slice) In general, whenever there is a change in the ready queue.

Starvation 19 Starvation occurs when a job cannot make progress because some other job has the resource it require We ve seen locks, Monitors, Semaphores, etc. The same thing can happen with the CPU! Starvation can be a side effect of synchronization Constant supply of readers always blocks out writers Well-written critical sections should ensure bounded waiting Starvation is usually a side effect of the scheduling algorithm: A high priority process always prevents a low priority process from running on the CPU One thread always beats another when acquiring a lock

Multilevel Feedback Queue 20 Multilevel feedback queue scheduler is defined by the following parameters: number of queues scheduling algorithms for each queue method used to determine when to upgrade a process method used to determine when to demote a process method used to determine which queue a process will enter when that process needs service The scheduler can be configured to match the requirements of a specific system.

Deadlock Definition 21 Deadlock is a problem that can arise: When processes compete for access to limited resources When processes are incorrectly synchronized Definition: Deadlock exists among a set of processes if every process is waiting for an event that can be caused only by another process in the set.

Conditions for Deadlock 22 Deadlocks can exist if and only if four conditions hold: 1) Mutual exclusion: At least one resource must be held in a non-sharable mode. (I.e., only one instance) 2) Hold and wait: There must be one process holding one resource and waiting for another resource 3) No preemption: Resources cannot be preempted (I.e., critical sections cannot be aborted externally) 4) Circular wait: There must exist a set of processes {P 1, P 2, P 3,,P n } such that P 1 is waiting for a resource held by P 2, P 2 is waiting for P 3,, and P n for P 1

Resource Allocation Graph 23 Deadlock can be described using a resource allocation graph (RAG) The RAG consists of sets of vertices P = {P 1, P 2,, P n } of processes and R = {R 1, R 2,, R m } resources A directed edge from a process to a resource, Pi Rj, implies that Pi has requested Rj A directed edge from a resource to a process, R j P i, implies that Rj has been acquired by Pi Each resource has a fixed number of units If the graph has no cycles, deadlock cannot exist If the graph has a cycle, deadlock may exist

Deadlock Avoidance 24 SAFE: R1 is assigned to P1 with priority UNSAFE: (P1 requests R2)-> cycle

Deadlock Detection 25 Detection Traverse the resource graph looking for cycles If a cycle is found, preempt resource (force a process to release) Expensive Many processes and resources to traverse Only invoke detection algorithm depending on How often or likely deadlock is How many processes are likely to be affected when it occurs

Deadlock Summary 26 Deadlock occurs when processes are waiting on each other and cannot make progress Cycles in Resource Allocation Graph (RAG) Deadlock requires four conditions Mutual exclusion, hold and wait, no resource preemption, circular wait Four approaches to dealing with deadlock: Ignore it Living life on the edge Prevention Make one of the four conditions impossible Avoidance Banker s Algorithm (control allocation) Detection and Recovery Look for a cycle, preempt or abort