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

Similar documents
Synchronization. CS 416: Operating Systems Design, Spring 2011 Department of Computer Science Rutgers University

ECE469 - Operating Systems Engineering Exam # March 25

Deadlock. Disclaimer: some slides are adopted from Dr. Kulkarni s and book authors slides with permission 1

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

Deadlock. Disclaimer: some slides are adopted from Dr. Kulkarni s and book authors slides with permission 1

Deadlock. Concurrency: Deadlock and Starvation. Reusable Resources

Deadlocks Characterization & Detection

PESIT Bangalore South Campus

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

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

Last Class: Deadlocks. Today

CSE 153 Design of Operating Systems

Synchronization. Disclaimer: some slides are adopted from the book authors slides 1

Synchronization. Heechul Yun. Disclaimer: some slides are adopted from the book authors and Dr. Kulkani

Synchronization Principles

CHAPTER 6: PROCESS SYNCHRONIZATION

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

Process Management And Synchronization

Synchronization. Disclaimer: some slides are adopted from the book authors slides 1

2 Threads vs. Processes

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

Fall 2015 COMP Operating Systems. Lab 06

CS370 Operating Systems Midterm Review. Yashwant K Malaiya Spring 2019

Chapter 6: Process Synchronization

Chapter 7: Deadlocks. Operating System Concepts 9 th Edition

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

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

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

Final Exam Preparation Questions

Last Class: Monitors. Real-world Examples

CSE 4/521 Introduction to Operating Systems. Lecture 27 (Final Exam Review) Summer 2018

Operating Systems ECE344

G52CON: Concepts of Concurrency

Lecture 3: Synchronization & Deadlocks

Chendu College of Engineering & Technology

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

AC59/AT59/AC110/AT110 OPERATING SYSTEMS & SYSTEMS SOFTWARE DEC 2015

Chapter 6: Process Synchronization

Chapter 6: Synchronization. Chapter 6: Synchronization. 6.1 Background. Part Three - Process Coordination. Consumer. Producer. 6.

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

Lecture 9: Midterm Review

More on Synchronization and Deadlock

Concurrency: Deadlock and Starvation. Chapter 6

2 nd Half. Memory management Disk management Network and Security Virtual machine

Operating Systems: William Stallings. Starvation. Patricia Roy Manatee Community College, Venice, FL 2008, Prentice Hall

Threading and Synchronization. Fahd Albinali

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

Sections 01 (11:30), 02 (16:00), 03 (8:30) Ashraf Aboulnaga & Borzoo Bonakdarpour

CPSC/ECE 3220 Summer 2018 Exam 2 No Electronics.

Semaphores INF4140. Lecture 3. 0 Book: Andrews - ch.04 ( ) INF4140 ( ) Semaphores Lecture 3 1 / 34

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

Chapter 8. Basic Synchronization Principles

Main Points of the Computer Organization and System Software Module

Opera&ng Systems ECE344

CS 318 Principles of Operating Systems

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

Synchronization Classic Problems

Contents. Chapter 8 Deadlocks

Chapter 6: Synchronization. Operating System Concepts 8 th Edition,

CS 143A - Principles of Operating Systems

CSE 120 Principles of Operating Systems

Last Class: Synchronization Problems!

Concurrency: Deadlock and Starvation

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING UNIT I

Chapter 6: Process Synchronization. Module 6: Process Synchronization

The deadlock problem

OPERATING SYSTEMS. Deadlocks

Deadlock Risk Management

Unit-03 Deadlock and Memory Management Unit-03/Lecture-01

System Model. Types of resources Reusable Resources Consumable Resources

MARUTHI SCHOOL OF BANKING (MSB)

IV. Process Synchronisation

Last Class: Deadlocks. Where we are in the course

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

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

The Deadlock Problem (1)

Semaphores. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

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

CSI3131 Final Exam Review

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

Operating Systems (1DT020 & 1TT802)

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

CSE 451: Operating Systems Spring Module 10 Semaphores, Condition Variables, and Monitors

CSE 120 PRACTICE FINAL EXAM, WINTER 2013

Synchronization I. Jo, Heeseung

MC7204 OPERATING SYSTEMS

CHAPTER NO - 1 : Introduction:

CSE 451: Operating Systems Winter Synchronization. Gary Kimura

CSE 120 Principles of Operating Systems Spring 2017

Process Synchronization

Synchronization Spinlocks - Semaphores

Operating Systems. Lecture 4 - Concurrency and Synchronization. Master of Computer Science PUF - Hồ Chí Minh 2016/2017

CSC501 Operating Systems Principles. Process Synchronization

Operating Systems CMPSC 473. Synchronization February 26, Lecture 12 Instructor: Trent Jaeger

COMP 3361: Operating Systems 1 Final Exam Winter 2009

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

Semaphore. Originally called P() and V() wait (S) { while S <= 0 ; // no-op S--; } signal (S) { S++; }

Module 6: Process Synchronization

Virtual Memory. CSCI 315 Operating Systems Design Department of Computer Science

Chapter 8: Deadlocks. The Deadlock Problem

Transcription:

CS 4410 Operating Systems Review 1 Summer 2016 Cornell University 1

A modern computer system keyboard disks mouse printer monitor CPU Disk controller USB controller Graphics adapter memory OS device driver device driver app app app 2

HW-OS interface device device controller CPU memory OS device driver application 3

OS-App interface device device controller CPU memory OS device driver application 4

From program code to a process Program code Written in a high-level language Disk if Disk (x>0) y:=1 else y:=2 Compilation Disk Executable image Sequence of machine instructions and data 00011101 Disk 11110000 10101000 11110010 The OS copies the executable into memory, and reserves memory for stack and heap. Memory Process Instance of a program, ready to be executed by CPU. instructions data heap stack

From a process to threads code data files code data files registers stack registers registers registers stack stack stack single-threaded process multi-threaded process

Scheduling Algorithms Simplicity Low overhead FIFO Lateness Turnaround time SJF RR Response time Starvation freedom 7

A Multi-level System I/O bound jobs priority CPU bound jobs timeslice 8

Need for synchronization For a multithreaded program to be correct, some restrictions on accessing shared data by threads should be satisfied. Threads access to shared resources should be coordinated. Threads should coordinate on their own their access to shared data. All threads should still be able to make progress! 9

Share Counting with lock bills_counter = 0 lock = released Thread A while (machine_a_has_bills) acquire (lock) r1 = bills_counter r1 = r1 +1 bills_counter = r1 release (lock) Critical Section Thread B while (machine_b_has_bills) acquire (lock) r2 = bills_counter r2 = r2 +1 bills_counter = r2 release (lock) 10

Producer-Consumer Problem Shared data: buffer, In, Out Shared Semaphores: mutex, empty, full; mutex = 1; /* for mutual exclusion*/ empty = N; /* number empty buf entries */ full = 0; /* number full buf entries */ Producer do { P(empty); P(mutex); //produce item //update In V(mutex); V(full); } while (true); Consumer do { P(full); P(mutex); //consume item //update Out V(mutex); V(empty); } while (true); 11

Readers-Writers Problem mutex = Semaphore(1) wrt = Semaphore(1) readcount = 0; Reader do{ P(mutex); readcount++; if (reardcount == 1) Writer do{ P(wrt); /*writing is performed*/ V(wrt); }while(true) P(wrt); V(mutex); /*reading is performed*/ P(mutex); readcount--; if (readcount == 0) V(wrt); V(mutex); }while(true) 12

Monitor A data abstraction mechanism, which consists of: state and procedures. The state is modeled by shared variables. The procedures are the only means by which the state is manipulated. Mutual exclusion: only one thread can execute a monitor procedure at any time. Monitor monitor_name { // shared variable declarations procedure P1(...) {... }... procedure PN(...) {... } initialization_code(... ) {... } }

Monitor EventTracker { int numburgers = 0; condition hungrycustomer; A Simple Monitor void customerenter() { while (numburgers == 0) hungrycustomer.wait() numburgers -= 1 } } void produceburger() { ++numburgers; hungrycustomer.signal(); } 14

Synchronization: abstraction layers Locks (acquire, release), semaphores (Init,P, V), condition variables (wait, signal) Spinlocks, queuing locks TestAndSet, disable interrupts 15

Synchronization primitives Decreasing programming effort to encode predicates Locks (acquire, release) Semaphores (init, P, V) Condition Variables (wait, signal) All can encode any predicate on shared data. Each primitive can be used to implement another primitive.

Deadlock semaphore: mutex1 = 1 /* protects file */ mutex2 = 1 /* protects printer */ Process A code: { /* initial compute */ P(mutex1) P(mutex2) /* use file & printer*/ Process B code: { /* initial compute */ P(mutex2) P(mutex1) /* use file & printer */ } V(mutex2) V(mutex1) } V(mutex1) V(mutex2) 17

Four Conditions for Deadlock Mutual Exclusion Hold and wait No preemption Circular wait 18

Banker s Algorithm For a request R of additional resources issued by process P, which is the next process scheduled to run: 1. If R does not exceed P s maximum claim, go to 2. Otherwise, error. 2. If R does not exceed the available resources, go to 3. Otherwise, P should wait. 3. Pretend that R is granted to P. Update the state of the system. If the state is safe, then give requested resources to P. Otherwise, P should wait and the old state is restored.

Memory: allocation strategy Should processes have contiguous space of physical addresses in memory? Is memory partitioned into fixed- or variablesized segments? If variable-sized segments, which allocation algorithm is used? First fit: allocate first hole that is big enough. Best fit: allocate the smallest hole that is big enough. Worst fit: allocate the largest hole.

Address translation The CPU understands virtual addresses. The memory unit understands physical addresses. The OS and specialized hardware are responsible for translating virtual addressed into physical addresses. The translation mechanism gives protection. 21

Paging Divide physical memory into frames: Fixed-sized blocks. Size is power of 2, between 512 bytes and 8,192 bytes. Divide virtual memory into pages. Same size as frames. Page table translates virtual to physical addresses. 22

Address Translation Scheme 23

Hierarchical Paging 24

Page Replacement Algorithms FIFO: the page brought it earliest is evicted OPT: evict page that will not be used for longest period of time LRU: evict page that has not been used the longest MRU: evict the most recently used page LFU: evict least frequently used page

Coming up Next lecture: File System Interface Exam2: tomorrow last 30mis