Exam Review Operating Systems CS 550. Items of Interest Exam is Nov. 19, 2014 Focus on material since last exam, though knowledge of initial material.

Slides:



Advertisements
Similar presentations
Chapter 7: Deadlocks.
Advertisements

Operating Systems Lecture Notes Deadlocks Matthew Dailey Some material © Silberschatz, Galvin, and Gagne, 2002.
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community.
Concurrency: Deadlock and Starvation Chapter 6. Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate.
Deadlock Chapter 3 R1 R2 P2P1 Allocated Requested.
Review: Chapters 1 – Chapter 1: OS is a layer between user and hardware to make life easier for user and use hardware efficiently Control program.
Chapter 3: CPU Scheduling
1 Wednesday, June 28, 2006 Command, n.: Statement presented by a human and accepted by a computer in such a manner as to make the human feel that he is.
Deadlock CSCI 444/544 Operating Systems Fall 2008.
CS 450 OPERATING SYSTEMS DEADLOCKS Manju Muralidharan Priya.
CS 104 Introduction to Computer Science and Graphics Problems Operating Systems (2) Process Management 10/03/2008 Yang Song (Prepared by Yang Song and.
1 Concurrency: Deadlock and Starvation Chapter 6.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 7: Deadlocks.
Chapter 6 Concurrency: Deadlock and Starvation
Race Conditions CS550 Operating Systems. Review So far, we have discussed Processes and Threads and talked about multithreading and MPI processes by example.
1 Lecture 10: Uniprocessor Scheduling. 2 CPU Scheduling n The problem: scheduling the usage of a single processor among all the existing processes in.
Intro to OS CUCS Mossé Processes and Threads What is a process? What is a thread? What types? A program has one or more locus of execution. Each execution.
Concurrency: Deadlock and Starvation Chapter 6. Goal and approach Deadlock and starvation Underlying principles Solutions? –Prevention –Detection –Avoidance.
1 Concurrency: Deadlock and Starvation Chapter 6.
Exam Review cs550 Operating Systems. Preliminary Information Exam will focus on new content, but old content is still fair game. Exam format will be the.
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic,
CPU Scheduling Chapter 6 Chapter 6.
Chapter 6: CPU Scheduling
CS3530 OPERATING SYSTEMS Summer 2014 Processor Scheduling Chapter 5.
Chapter 6 CPU SCHEDULING.
More Scheduling cs550 Operating Systems David Monismith.
CS 153 Design of Operating Systems Spring 2015 Lecture 11: Scheduling & Deadlock.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Deadlocks.
SWE202 Review. Processes Process State As a process executes, it changes state – new: The process is being created – running: Instructions are being.
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.
Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the.
Operating Systems Part III: Process Management (Deadlocks)
Deadlocks Silberschatz Ch. 7 and Priority Inversion Problems.
OPERATING SYSTEMS - I. What is an Operating System OS is a program that manages the computer hardware It provides a basis for application programs and.
Chapter 5 Processor Scheduling Introduction Processor (CPU) scheduling is the sharing of the processor(s) among the processes in the ready queue.
1 Deadlock. 2 Concurrency Issues Past lectures:  Problem: Safely coordinate access to shared resource  Solutions:  Use semaphores, monitors, locks,
CS6502 Operating Systems - Dr. J. Garrido Deadlock – Part 2 (Lecture 7a) CS5002 Operating Systems Dr. Jose M. Garrido.
Review for Quiz-2 Applied Operating System Concepts Chap.s 1,2,6,7 - ECE3055b, Spring 2005.
Chapter 7 Deadlocks. 7.1 Introduction Deadlock Common approaches to deal with deadlock – Prevention – Avoidance – Detection and recovery.
CSE 153 Design of Operating Systems Winter 2015 Midterm Review.
Deadlocks System Model RAG Deadlock Characterization
CS333 Intro to Operating Systems Jonathan Walpole.
Styresystemer og Multiprogrammering Block 3, 2005 Deadlocks Robert Glück.
Lecture Topics: 11/15 CPU scheduling: –Scheduling goals and algorithms.
Deadlocks.  Deadlocks: Occurs when threads are waiting for resources with circular dependencies Often involve nonpreemptable resources, which cannot.
Chapter 8 Deadlocks. Objective System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection.
1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 6 Deadlocks Slide 1 Chapter 6 Deadlocks.
Deadlocks Introduction to Operating Systems: Module 7.
CE Operating Systems Lecture 8 Process Scheduling continued and an introduction to process synchronisation.
CPU Scheduling Operating Systems CS 550. Last Time Deadlock Detection and Recovery Methods to handle deadlock – Ignore it! – Detect and Recover – Avoidance.
Silberschatz, Galvin and Gagne ©2009 Edited by Khoury, 2015 Operating System Concepts – 9 th Edition, Chapter 7: Deadlocks.
Operating Systems Scheduling. Scheduling Short term scheduler (CPU Scheduler) –Whenever the CPU becomes idle, a process must be selected for execution.
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
NETW 3005 Monitors and Deadlocks. Reading For this lecture, you should have read Chapter 7. NETW3005 (Operating Systems) Lecture 06 - Deadlocks2.
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);
Process Management Deadlocks.
Applied Operating System Concepts -
Operating System: DEADLOCKS
Chapter 6: CPU Scheduling
Chapter 5: CPU Scheduling
Operating System Concepts
Concurrency: Mutual Exclusion and Process Synchronization
Andy Wang Operating Systems COP 4610 / CGS 5765
CSE 153 Design of Operating Systems Winter 2019
EECE.4810/EECE.5730 Operating Systems
CSE 542: Operating Systems
CSE 542: Operating Systems
Chapter 8: Deadlocks Deadlock Characterization
Presentation transcript:

Exam Review Operating Systems CS 550

Items of Interest Exam is Nov. 19, 2014 Focus on material since last exam, though knowledge of initial material (threads, processes, interthread/interprocess communication, etc.) is required Synchronization techniques – Semaphores – Other locking tools – Readers Writers Problem – Producer-Consumer Problem Deadlock – Prevention – Avoidance – Detect and Recover – Ignore Scheduling – Gantt Charts for FCFS, Round Robin, SJF, SRTN – Dynamic Scheduling File Systems – File Basics Memory Management – Contiguous/Non-contiguous – Paging and Virtual Memory

Synchronization Basics Mutual exclusion – only one process is allowed access to a shared resource, all others must wait Critical section – section of code in a process where a shared resource is accessed To provide mutual exclusion on a critical section a process must also have absence of starvation and absence of deadlock

Semaphores Abstract data type that provides locking mechanism to provide mutual exclusion Methods are invoked by processes needing access to a critical section Binary or counting Methods/functions include – Acquire or wait – Release, post, or signal Can be used to enter and exit a critical section or to order events

Producer-Consumer Problem Two types of processes – Producer – makes data items and puts them into a buffer one at a time – Consumer – removes data items from the buffer and consumes them one at a time Both continuously need access to shared buffer Buffer has N slots, keep track of which are full or empty Consumer cannot remove items from an empty buffer Producer cannot insert items to a full buffer Problem can be solved using a mutual exclusion semaphore, a counting semaphore for full slots, and a counting semaphore for empty slots

Readers Writers Problem Two types of processes – Readers – access data only – Writers – access data resource to update the data Any number of readers can access the shared resource simultaneously If a writer has access to the shared data, it has exclusive access Need two levels of mutual exclusion – Group exclusive access to shared resource – Individual exclusive access to shared resource Many solutions – Reader priority – Writer priority

Monitors A monitor is another mechanism to provide mutual exclusion Operates on a higher level than a semaphore Makes use of encapsulation to integrate data and operations to provide shared data protection Only one process can execute an operation of the monitor at a time Processes must wait at an entry queue to gain access to the monitor After entering processes can be suspended and reactivated via additional queues Condition queues may also exist for various condition variables within the monitor Checks on condition variables may be made with methods wait and signal similar to those used for a semaphore

Atomic Operations Used when multiple data values need to be modified within a critical section Want the data values to have the appearance of occurring as one transaction Locking mechanism can allow for this but issues occur with system failures Two options to deal with system failure – Checkpoint-restart Periodically record checkpoints and restore system from checkpoint after failure – Transaction logging Log transactions prior to each atomic transaction Use log file to undo incomplete transactions after system failure

CPU Scheduling OS scheduler must allow for allocation and de- allocation of CPU(s) to processes and threads Must be efficient and effective Many policies exist to decide which process/thread should be moved from ready to run first Effectively the scheduler decides when and how to carry out a context switch

Functions of the Scheduler 3 Main Functions Insertion of process that want to use the CPU into a ready queue – Linked list of PCBs – Queue is usually a FIFO list, set of lists, or priority list – Carried out by enqueuer – a part of the scheduler Context switching – Carried out by context switcher – Saves context of current process and deallocates the CPU from that process – This operation has a significant overhead cost Selection of the next process to run – Select a process from the ready queue and load its context – Carried out by the dispatcher – Allocate the CPU to the newly selected process

FCFS Implemented with FIFO queue Arrival order determines the selection of the next process to run Single class, non-preemptive policy Assume context switch time is negligible Example shows algorithm is fair but performance might not be the best Gantt chart is used for comparison P1P2P3P4P

SJF SJF is an improvement with respect to turnaround and average wait time when compared to FCFS CPU utilization is 100% for both with Gantt chart is as follows Average turnaround is and average wait is With FCFS average turnaround is and average wait is P3P2P5P1P4

Round Robin Preemptive time sharing policy for processes/threads Each process is allowed access to the CPU for a time slice that is most often shorter than the average CPU burst time Processes/threads move from the run state to ready as their time slices expire Works well for interactive systems Poor performance but fair access to the CPU

Shortest Remaining Time Next Preemptive scheduling policy that requires a priority queue Picks the job with the shortest remaining CPU burst time to enter the run state from the ready state Newly arriving processes may interrupt currently running processes if running process requires more burst time Provides better performance, but starvation is possible

Dynamic Scheduling Process/thread priorities may change over time Varying priority based upon a heuristic such as increased priority with increased number of IO device accesses May require a priority queue Preemptive, may or may not be fair Heuristic algorithm

Longest Job First (LJF) Same concept as SJF except using the longest job first Uses a priority queue Non-preemptive, not fair compared to FCFS Example with five processes having CPU burst times of 148ms, 135ms, 125ms, 102ms, and 56ms P1P2P3P4P5

Deadlock Deadlock is indefinite wait cause by processes competing for shared resources or attempted communication Resource allocation graphs are important to express deadlock Certain conditions must exist for deadlock to occur – Mutual exclusion – only one process may access a shared resource at a time with exclusive access – Hold and wait – processes acquire resources and request additional resources – Circular wait – closed path (cycle) exists within the resource allocation graph – No preemption – process cannot be interrupted and forced to release resources

Deadlock Prevention Four conditions necessary for deadlock – No preemption – Hold and wait – Mutual exclusion – Circular wait Disallow one of the four conditions to prevent deadlock Often disallow hold and wait or circular wait as no preemption and mutual exclusion are often necessary to protect shared resources

Deadlock Avoidance Allocate resources only when certain deadlock will not occur Analyze current system state to ensure current resource allocations are a safe state Keep track of maximum claims for each process – Most resources a process will ever request Avoid unsafe states by finding an allocation order that will allow all processes to complete Utilize Banker’s algorithm to check if current resource allocation state is safe with the following data – Vector C – number of instances of every resource type in the system – Matrix A – number of resource instances of every resource type allocated to every process – Matrix M – maximum claim of every resource type declared by every process Given the needs of each process as additional data, determine if the state is safe

Deadlock Detection and Recovery Utilize a cycle detection algorithm to determine if deadlock exists within a system. Easy if only one resource of each type More difficult with more than one resource of each type Keep track of several sets of data – Vector of resources containing the total number of resources of each type in the system – Vector of available resources of each type – Matrix of allocated resources of each type to each process – Matrix of requested resources of each type for each process Check for cycles in the graph Hard to choose a heuristic for frequency of detection algorithm runs Recovery possible by aborting processes or rollback

Dining Philosophers Synchronization problem 5 plates and 5 chopsticks Philosophers must have access to two chopsticks to eat Access to chopsticks is limited to the chopsticks to the immediate left and right of the philosopher To solve the shared resource problem must disallow one of the four conditions for deadlock to occur – Prefer disallow circular wait or disallow hold and wait – Even so, starvation could still occur – Fairness is important, too

MPI Function Calls MPI_Init MPI_Finalize MPI_Comm_world MPI_Comm_size MPI_Send MPI_Recv MPI_Wait/MPI_Waitall/MPI_Waitsome MPI_Irecv MPI_Barrier

File Basics Definitions of a File and Directory File permissions Reading, writing, opening, and closing File pointers Stdin, stdout, stderr Fragmentation and free space management

File Systems and Operations Types of file systems – FAT/FAT32 – NTFS – Ext4 – Lustre Mounting and unmounting Direct Memory Access

Disk Drives and Disk IO Scheduling Drive Parts – Arm, Spindle, Platters, Tracks, Blocks I/O Scheduling – First Come First Served – Shortest Seek Time First – Elevator (SCAN) – Circular Scan

Memory Management Partitions Contiguous vs. Non-contiguous allocations Frames Pages Segments Internal and External Fragmentation Process address space Virtual memory Paging Policies – Fetching – Demand vs Prepaging – Replacement – Least Recently Used, FIFO, Optimal