CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:50 645-4739

Slides:



Advertisements
Similar presentations
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community.
Advertisements

Concurrency: Mutual Exclusion and Synchronization Chapter 5.
MODERN OPERATING SYSTEMS Third Edition ANDREW S
DPNM Lab. Dept. of CSE, POSTECH
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE116: Introduction to Computer Science 2 Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE115: Introduction to Computer Science I
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
5.6 Semaphores Semaphores –Software construct that can be used to enforce mutual exclusion –Contains a protected variable Can be accessed only via wait.
5.6 Semaphores Semaphores –Software construct that can be used to enforce mutual exclusion –Contains a protected variable Can be accessed only via wait.
Concurrent Processes Lecture 5. Introduction Modern operating systems can handle more than one process at a time System scheduler manages processes and.
Deadlock Prevention CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han.
Chapter 7.1: Deadlocks.
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
Interprocessor arbitration
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Ch 7: Deadlock Dr. Mohamed Hefeeda.
CSE 116 Introduction to Computer Science For Majors II Carl Alphonce 219 Bell Hall.
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
Core 3: Communication Systems. On any network there are two types of computers present – servers and clients. By definition Client-Server architecture.
Managing Local and Network Printer Chapter 11 powered by dj.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3: Operating Systems Computer Science: An Overview Eleventh Edition.
CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall 1.
SWE202 Review. Processes Process State As a process executes, it changes state – new: The process is being created – running: Instructions are being.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Mutual Exclusion.
Lecture 18: Operating Systems Intro to IT COSC1078 Introduction to Information Technology Lecture 18 Operating Systems James Harland
Cpr E 308 Spring 2004 Real-time Scheduling Provide time guarantees Upper bound on response times –Programmer’s job! –Every level of the system Soft versus.
1 Announcements The fixing the bug part of Lab 4’s assignment 2 is now considered extra credit. Comments for the code should be on the parts you wrote.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Mutual Exclusion.
1 Deadlocks Chapter Resource 3.2. Introduction to deadlocks 3.3. The ostrich algorithm 3.4. Deadlock detection and recovery 3.5. Deadlock avoidance.
Operating Systems Part III: Process Management (Deadlocks)
Chapter 3: Operating Systems
Chapter 7 -1 CHAPTER 7 PROCESS SYNCHRONIZATION CGS Operating System Concepts UCF, Spring 2004.
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 6 Deadlocks Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 14, 2005 Chapter 7: Deadlocks The Deadlock.
Chapter 3 Operating Systems. © 2005 Pearson Addison-Wesley. All rights reserved 3-2 Chapter 3 Operating Systems 3.1 The Evolution of Operating Systems.
Introduction Contain two or more CPU share common memory and peripherals. Provide greater system throughput. Multiple processor executing simultaneous.
Deadlock. Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 6: Deadlocks.
Computer Networks.  Which is the best definition of a circuit switched network?  An electric circuit where the connections get switched based on who.
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
Lecture 6 Deadlock 1. Deadlock and Starvation Let S and Q be two semaphores initialized to 1 P 0 P 1 wait (S); wait (Q); wait (Q); wait (S);. signal (S);
Chapter 3: Operating Systems
IS310 Hardware & Network Infrastructure Ronny L
143a discussion session week 3
Deadlock avoidance Deadlock detection Resource Allocation Graphs
Chapter 7: Deadlocks.
Outline Distributed Mutual Exclusion Introduction Performance measures
Lecture 2 Part 2 Process Synchronization
DPNM Lab. Dept. of CSE, POSTECH
Deadlocks Session - 13.
Chapter 3: Operating Systems Computer Science: An Overview
Presentation transcript:

CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:

cell phones off (please) 2

Announcements Exam 1 handback HW3 starts tomorrow, due March 5. Second exam is March 17 (week after spring break) 3

Today’s Agenda Operating Systems –Resource contention –Semaphores Networking 4

Resource contention Two processes want to use same resources Control access with flag Test flag – is resource available Set flag – mark resource as unavailable Clear flag – mark resource as available Test-interrupt-Test-Set-work-interrupt-Set-work 5

Semaphore Use a semaphore to control access to critical region Critical region: –Code that may be executed by only one process at a time Semaphore can enforce mutual exclusion 6

How to resolve? Test-and-set (single instruction, atomic) Interrupt disable 7

Example: writing to a file semaphore is clear P1 and P2 both want to write to F 8

Example: writing to a file semaphore is set by P1 P1 and P2 both want to write to F P1 tests-and-sets semaphore, and enters critical region 9

Example: writing to a file semaphore is set by P1 P1 and P2 both want to write to F P1 tests-and-sets semaphore, and enters critical region Context switch occurs 10

Example: writing to a file semaphore is set by P1 P1 and P2 both want to write to F P1 tests-and-sets semaphore, and enters critical region Context switch occurs P2 tests semaphore, finds it set, can’t enter critical region 11

Example: writing to a file semaphore is set by P1 P1 and P2 both want to write to F P1 tests-and-sets semaphore, and enters critical region Context switch occurs P2 tests semaphore, finds it set, can’t enter critical region Context switch occurs 12

Example: writing to a file semaphore is set by P1 P1 and P2 both want to write to F P1 tests-and-sets semaphore, and enters critical region Context switch occurs P2 tests semaphore, finds it set, can’t enter critical region Context switch occurs P1 exits critical region, clears semaphore 13

Example: writing to a file semaphore is clear P1 and P2 both want to write to F P1 tests-and-sets semaphore, and enters critical region Context switch occurs P2 tests semaphore, finds it set, can’t enter critical region Context switch occurs P1 exits critical region, clears semaphore Context switch occurs 14

Example: writing to a file semaphore is set by P2 P1 and P2 both want to write to F P1 tests-and-sets semaphore, and enters critical region Context switch occurs P2 tests semaphore, finds it set, can’t enter critical region Context switch occurs P1 exits critical region, clears semaphore Context switch occurs P2 tests-and-sets semaphore, and enters critical region 15

Deadlock P1 has R1, needs R2 to finish P2 has R2, needs R1 to finish Example: –P1 has access to file F1, needs access to file F2 –P2 has access to file F2, needs access to file F1 –Neither will give up their file access… 16

Conditions for deadlock There is competition for non-sharable resources Resources can be requested piecemeal Once allocated, cannot be stolen 17

Resolving a deadlock Remove one of three necessary conditions: 1.There is competition for non-sharable resources –deadlock avoidance scheme 2.Resources can be requested piecemeal –deadlock avoidance scheme 3.Once allocated, cannot be stolen –deadlock detection and correction scheme 18

1. Resource sharing Make unsharable resource appear sharable Deadlock avoidance Printer queue (spooling) 19

2. All resources must be acquired at once Prevents deadlock from occuring P1 cannot hold only R1 if R2 is not available. P2 can come along and get both R1 and R2. 20

3. Resource stealing Retrieve previously allocated resource Deadlock resolution –Let deadlock occur –Resolve deadlock after the fact 21

Networking What sorts of networks do we use? –Wired networks (in the labs) –Wireless (WIFI) networks (right now?) –Wireless cell phone networks –Wireless bluetooth (“personal area networks”) 22

Configurations Bus network –Devices connected to a common communications channel –Devices are peers –Ex. Typical wired network Star network –Devices connected to a central machine –Devices communicate only via central machine –Ex. Typical wifi network (access point) 23