Introduction to operating systems What is an operating system? An operating system is a program that, from a programmer’s perspective, adds a variety of.

Slides:



Advertisements
Similar presentations
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Advertisements

Operating Systems Lecture Notes Deadlocks Matthew Dailey Some material © Silberschatz, Galvin, and Gagne, 2002.
Ceng Operating Systems Chapter 2.4 : Deadlocks Process concept  Process scheduling  Interprocess communication  Deadlocks Threads.
1 CMSC421: Principles of Operating Systems Nilanjan Banerjee Principles of Operating Systems Acknowledgments: Some of the slides are adapted from Prof.
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.
6/9/2015B.Ramamurthy1 Process Description and Control B.Ramamurthy.
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.
Page 1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
Modified from Silberschatz, Galvin and Gagne Lecture 13 Chapter 7: Deadlocks.
OS Spring 2004 Concurrency: Principles of Deadlock Operating Systems Spring 2004.
OS Fall’02 Concurrency: Principles of Deadlock Operating Systems Fall 2002.
Chapter 11 Operating Systems
Informationsteknologi Tuesday, October 9, 2007Computer Systems/Operating Systems - Class 141 Today’s class Scheduling.
1 Threads Chapter 4 Reading: 4.1,4.4, Process Characteristics l Unit of resource ownership - process is allocated: n a virtual address space to.
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.
Chapter 51 Threads Chapter 5. 2 Process Characteristics  Concept of Process has two facets.  A Process is: A Unit of resource ownership:  a virtual.
1 CPU Scheduling & Deadlock Operating Systems Lecture 4.
Chapter 6: CPU Scheduling
CS 153 Design of Operating Systems Spring 2015 Midterm Review.
Chapter 6 Scheduling. Basic concepts Goal is maximum utilization –what does this mean? –cpu pegged at 100% ?? Most programs are I/O bound Thus some other.
Scheduling Basic scheduling policies, for OS schedulers (threads, tasks, processes) or thread library schedulers Review of Context Switching overheads.
Chapter 41 Processes Chapter 4. 2 Processes  Multiprogramming operating systems are built around the concept of process (also called task).  A process.
Lecture Topics: 11/13 Semaphores Deadlock Scheduling.
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.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks Modified.
Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the.
Systems II San Pham CS /20/03. Topics Operating Systems Resource Management – Process Management – CPU Scheduling – Deadlock Protection/Security.
CE Operating Systems Lecture 7 Threads & Introduction to CPU Scheduling.
Uniprocessor Scheduling
CIS250 OPERATING SYSTEMS Chapter 6 - CPU Scheduling Basic Concepts The objective of multi-programming is have a program running at all times Maximize.
CS6502 Operating Systems - Dr. J. Garrido Deadlock – Part 2 (Lecture 7a) CS5002 Operating Systems Dr. Jose M. Garrido.
Group no.2 Presented to : Eng.Ahmed Hassan Sunday, March 04,2012.
Review for Quiz-2 Applied Operating System Concepts Chap.s 1,2,6,7 - ECE3055b, Spring 2005.
CSE 153 Design of Operating Systems Winter 2015 Midterm Review.
CS Spring 2009 CS 414 – Multimedia Systems Design Lecture 31 – Process Management (Part 1) Klara Nahrstedt Spring 2009.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program.
Slides created by: Professor Ian G. Harris Operating Systems  Allow the processor to perform several tasks at virtually the same time Ex. Web Controlled.
Deadlocks Mark Stanovich Operating Systems COP 4610.
Unit 4: Processes, Threads & Deadlocks June 2012 Kaplan University 1.
Deadlocks.  Deadlocks: Occurs when threads are waiting for resources with circular dependencies Often involve nonpreemptable resources, which cannot.
Process Control Management Prepared by: Dhason Operating Systems.
Copyright © Curt Hill More on Operating Systems Continuation of Introduction.
CPU Scheduling Operating Systems CS 550. Last Time Deadlock Detection and Recovery Methods to handle deadlock – Ignore it! – Detect and Recover – Avoidance.
1.1 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 1: Introduction What Operating Systems Do √ Computer-System Organization.
Process Management Deadlocks.
Applied Operating System Concepts -
ITEC 202 Operating Systems
Virtual Memory Networks and Communication Department.
Process management Information maintained by OS for process management
CS 143A – Winter 2013 Quiz 2 Solutions.
CPU Scheduling Basic Concepts Scheduling Criteria
Chapter 6: CPU Scheduling
Introduction What is an operating system bootstrap
So far…. Firmware identifies hardware devices present
Midterm review: closed book multiple choice chapters 1 to 9
Process Description and Control
Threads Chapter 4.
Process Description and Control
Process Description and Control
Process Description and Control
Process Description and Control
Process Description and Control
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
CS510 Operating System Foundations
Process Description and Control
Foundations and Definitions
CSE 153 Design of Operating Systems Winter 2019
Chapter 3: Process Management
Presentation transcript:

Introduction to operating systems What is an operating system? An operating system is a program that, from a programmer’s perspective, adds a variety of new instructions and features above and beyond what is provided by the Instruction Set Architecture (ISA). New instructions added by the operating system are called system calls. Main functions delivered by typical operating systems –Virtual memory –Virtual instruction for I/O processing –Virtual instructions for parallel processing

Virtual memory What is a virtual memory? Virtual memory loosely describes a hierarchical storage system of at least two levels, which is managed by an operating system to appear to a user like a single large directly addressable main memory.

Virtual memory cont. Rationale for introduction of virtual memory –To free users from the need to carry out storage allocation –To make programs independent of the configuration and capacity of the memory systems used during their execution –To permit efficient sharing of memory space among different users (processes) and achieve the high access rates and low cost per bit that is possible with a memory hierarchy

Virtual I/O instructions Why virtual I/O instructions –Handling I/O operations at the ISA level is extremly tedious and complex –Virtual I/O instructions allow to operate on abstractions like files and directories –Virtual I/O instructions allow to implement necessary safety and security mechanisms

Virtual instructions for parallel processing Why virtual instructions for parallel processing? –many problems yield themselves to be efficiently processed by two or more processes running in parallel –parallel processing may be viewed as an answer to both technological and economical limitations connected with computing –in order for several processes to work together in parallel certain virtual instructions are needed

Virtual instructions for parallel processing Typical virtual instructions for parallel processing Process creation, termination, synchronization, communication, etc. Process vs Thread –Process, simply stated, is a program in execution, it is characterized by Separate program counter, CPU registers, address space for code and data –Thread (lightweight process) is characterized by Separate program counter, CPU registers, stack space Shared address space for code and data, OS resources like files, signals, etc.

Concurrent Execution vs Multitasking time Process 1 Process 2 Process 3 time Process 1 Process 2 Process 3

Scheduling – states of a process new ready running waiting terminated Admitted Interrupt I/O or event completion Scheduler dispatch I/O or event wait Exit

Scheduling criteria CPU utilization – ratio of in-use time to total observation time Throughput – number of processes completed per time unit Turnaround time – amount of time from a submission of a process for execution to its completion Waiting time – amount of time a process spends waiting for execution Response time – amount of time from issuing a request to observing a response

Scheduling policies –Non-preemptive First Come First Served Shortest Job First –Preemptive Round-Robin Priority-based –Multi-level queues Queue of different priorities with possibly different scheduling algorithm for each queue –Multi-level queues with feedback Possibility of process migration among queues on the basis of its execution characteristics

Problems connected with concurrent (multitasked) execution of processes (threads) Data corruption Determining if data can be corrupted by concurrent access from more than one process (thread), and if so, designing mechanisms to prevent it from happening (safety analysis). Deadlock Determining whether the application will be alive (liveness analysis). Safety analysis and liveness analysis form correctness analysis

Bernstein’s conditions 1.If process P i writes to memory location M i, no process P j can read memory location M i 2.If process P i reads from memory location M i, no process P j can write to memory location M i 3.If process P i writes to memory location M i, no P j can write to memory location M j

Problem of data corruption void *thread_function1( void *ptr ) { int i = 0; for(i = 0; i < 1000; i++) { X++; } pthread_exit(0); } void *thread_function2( void *ptr ) { int i = 0; for(i = 0; i < 1000; i++) { X++; } pthread_exit(0); } What will be a value of X after completion of the whole program?

Problem of data corruption We need to establish some mechanism to shield X from being accessed concurrently from the two processes (threads) –re-design the program –use synchronization mechanisms –use atomic instructions

Problem of deadlock "In concurrent systems, liveness means that if something is supposed to happen then eventually it will happen.... The word 'eventually'... means exactly that: within an unspecified but finite length of time.” M. Ben-Ari, Principles of Concurrent Programming

Problem of deadlock cont. Deadlock A deadlock, very simply, is a condition in which two or more threads wait for each other to release a shared resource before resuming their execution. Four conditions for deadlock –mutual exclusion – processes have exclusive control of resources –hold and wait – processes have some resources and wait for more –no preemption – resources cannot be removed from a process –circular wait – a circular chain of processes exists in which each process holds one or more resources requested by the next process in the chain

Illustration of the problem of deadlock with Resource Allocation Graphs (RAGs) Resource 1 Process 1 Resource 2 Process 2 Process 1 has acquired Resource 1 Process 2 has acquired Resource 2 Process 1 requests Resource 2 Process 2 requests Resource 1

Dealing with deadlock Deadlock prevention –one-shot algorithm, where you must acquire all resources or none –hierarchical algorithm, acquire resources in a preset order, acquire low priority resources before high priority ones Deadlock avoidance –Dijkstra's Banker Algorithm, assumes foreknowledge of all processes (useless in practice) Deadlock detection and recovery –deadlock occurs and then some processes are terminated and the mess is cleaned up (posthumous way)

Detecting deadlock Resource Allocation Graphs –For any state that a given process is in, it can be determined whether the system is deadlocked or not Computing invariants –Method of detecting possible deadlocks, which uses a set of statements that hold true, no matter what states the set of processes is in (Lectures of Prof. Węgrzyn) –Problem: the computation may not be effective. Analysis of deadlock scenario –It is decidable whether a scenario that is identified as a deadlock can be reached given a certain initial state of processes –Sometimes, much more efficient than a mechanical execution of an algorithm