Review: Process Management Objective: –Enable fair multi-user, multiprocess computing on limited physical resources –Security and efficiency Process: running.

Slides:



Advertisements
Similar presentations
1 Interprocess Communication 1. Ways of passing information 2. Guarded critical activities (e.g. updating shared data) 3. Proper sequencing in case of.
Advertisements

Chapter 3 Process Description and Control
Tutorial 5 Test1 Review. Q1: Which of the following is an operating system theme or model as defined in lectures?
Mutual Exclusion.
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.
Big Picture Lab 4 Operating Systems Csaba Andras Moritz.
CSC 501 Lecture 2: Processes. Von Neumann Model Both program and data reside in memory Execution stages in CPU: Fetch instruction Decode instruction Execute.
Thursday, June 08, 2006 The number of UNIX installations has grown to 10, with more expected. The UNIX Programmer's Manual, 2nd Edition, June, 1972.
Processes CSCI 444/544 Operating Systems Fall 2008.
Review: Process Communication Sequential Communication –Result of P1 becomes at termination the input to P2 –Tools: Redirect (>,>>) and Pipe (|) Concurrent.
Review: Operating System Manages all system resources ALU Memory I/O Files Objectives: Security Efficiency Convenience.
Synchronization Principles. Race Conditions Race Conditions: An Example spooler directory out in 4 7 somefile.txt list.c scores.txt Process.
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
1/28/2004CSCI 315 Operating Systems Design1 Operating System Structures & Processes Notice: The slides for this lecture have been largely based on those.
1/23/2008CSCI 315 Operating Systems Design1 Processes Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating.
Processes April 5, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
CPS110: Implementing threads/locks on a uni-processor Landon Cox.
Race Conditions CS550 Operating Systems. Review So far, we have discussed Processes and Threads and talked about multithreading and MPI processes by example.
A. Frank - P. Weisberg Operating Systems Introduction to Cooperating Processes.
Operating Systems (CSCI2413) Lecture 3 Processes phones off (please)
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.
Phones OFF Please Processes Parminder Singh Kang Home:
OPERATING SYSTEMS DESIGN AND IMPLEMENTATION Third Edition ANDREW S. TANENBAUM ALBERT S. WOODHULL Yan hao (Wilson) Wu University of the Western.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
CSC 501 Lecture 2: Processes. Process Process is a running program a program in execution an “instantiation” of a program Program is a bunch of instructions.
Object Oriented Analysis & Design SDL Threads. Contents 2  Processes  Thread Concepts  Creating threads  Critical sections  Synchronizing threads.
Implementing Processes and Process Management Brian Bershad.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Copyright © 1997 – 2014 Curt Hill Concurrent Execution of Programs An Overview.
Multiprogramming. Readings r Silberschatz, Galvin, Gagne, “Operating System Concepts”, 8 th edition: Chapter 3.1, 3.2.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Cooperating.
Computer Studies (AL) Operating System Process Management - Process.
Processes – Part I Processes – Part I. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Review on OSs Upon brief introduction of OSs,
We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
1 Lecture 6 Introduction to Process Management COP 3353 Introduction to UNIX.
1  process  process creation/termination  context  process control block (PCB)  context switch  5-state process model  process scheduling short/medium/long.
CS399 New Beginnings Jonathan Walpole. 2 Concurrent Programming & Synchronization Primitives.
Review for Quiz-2 Applied Operating System Concepts Chap.s 1,2,6,7 - ECE3055b, Spring 2005.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
1 Process Description and Control Chapter 3. 2 Process A program in execution An instance of a program running on a computer The entity that can be assigned.
What is a Process ? A program in execution.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
Processes 2 Introduction to Operating Systems: Module 4.
1 Critical Section Problem CIS 450 Winter 2003 Professor Jinhua Guo.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Overview: Using Hardware.
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
Big Picture Lab 4 Operating Systems C Andras Moritz
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
Process Synchronization. Concurrency Definition: Two or more processes execute concurrently when they execute different activities on different devices.
Multiprogramming. Readings r Chapter 2.1 of the textbook.
Chapter 3: Processes.
Process Management Process Concept Why only the global variables?
Chapter 3: Process Concept
Operating Systems (CS 340 D)
Chapter 3: Processes.
Process Virtualization. Process Process is a program that has initiated its execution. A program is a passive entity; whereas a process is an active entity.
More examples How many processes does this piece of code create?
Operating System Concepts
Processes Hank Levy 1.
Concurrency: Mutual Exclusion and Process Synchronization
Chapter 3: Processes.
- When you approach operating system concepts there might be several confusing terms that may look similar but in fact refer to different concepts:  multiprogramming, multiprocessing, multitasking,
CS510 Operating System Foundations
Processes Hank Levy 1.
Chapter 3: Processes Process Concept Process Scheduling
Chapter 3: Process Management
Presentation transcript:

Review: Process Management Objective: –Enable fair multi-user, multiprocess computing on limited physical resources –Security and efficiency Process: running program + context Process Control Block: Contains Process Context Register content Memory address space PC I/O Status

Review: Process Management Multicomputing is achieved by timeslicing: Every process runs for a while until time is up Interrupt driven(2 Types), PCB is stored and retrieved 5 State model: new, running, ready, waiting,terminated multiple queues in which processes reside during lifetime

Diagram of Process States newterminated Queue: waiting Queue: readyrunning I/O or event wait I/O or event completion interrupt admitted exit scheduler

Review UNIX Commands telnet machine: login to UNIX computer ps: show all processes that were started –ps -u username : all processes started by user top: show all processes running on the computer kill id : Stop running process with id nohup: make process immune to high level interrupts nice +int process: change the priority of a process man command: get information about command

Inter Process Communication Passing information sequentially between 2 processes (simplest case) –Result of P1 becomes at termination the input to P2 Passing information concurrently between 2 running processes Use of shared resources (such as printer queue)

Tools for sequential communication Redirect –> saves the output (whatever would come to the screen) into a file –>> appends the output to a file –Example: print >tmp Pipe –| hands the output directly to the next process

Example See the 9823th line of a file –head -n file: command that shows the first n lines of file –head -n file: command that shows the last n lines of file 1) Store the first 9823 temporarily in a file and than look at the last line –head file>tmp –tail -1 tmp 2)Pass results directly using pipe –head file|tail -1

Communication between processes: Sharing Simplest method: any 2 processes can use shared file that both processes can access However, only one process at a time can have write access Parent-child processes can have shared variables –a C program can start of new processes (fork) that have access to all global variables

Use of shared resources Example: 2 unrelated processes want to print to the same printer Printer collects jobs in a printer queue (lpq -Pprinter shows you all entries in the queue) A queue works like an array. Each entry is a file that has to be printed. Processes can submit a file by appending it to the array. The printer takes jobs out from the lower end of the array. Global variable LAST keeps track of end of the array

Problem of Sharing: Inconsistency Multiprogramming can lead to inconsistency in case of shared resources P1 and P2 want to print, P1 is running and P2 is next in the ready queue P1 loads the current value of LAST into register R1 P1 gets interrupted by scheduler because time is up P2 starts running and loads LAST into R3 P2 stores filename in array(R3), increments R3 and stores R3 into LAST

Inconsistency II P2 gets interrupted by scheduler and P1 starts running (remember, OS will restore all register values) P1 will store its filename at array(R1) believing that R1 is the current value of LAST and overwrite the filename stored by P2 P1 increments R1 and saves the value to LAST P2’s file will never be printed!

Problems of Sharing: Deadlock Deadlock: Processes are waiting for resources held by another P1: lock(x) lock(y) P2: lock(y) lock(x) P1 can’t finish since it is waiting for resource y P2 can’t finish since it is waiting for resource x Neither of both ever unlocks the one it has

Race Conditions Whenever sharing of resources can lead to inconsistencies or deadlock Problem: Very hard to debug, not reproducible Heart of the problem is that between a test/load of a resource and the update there could be an interrupt Solution: atomic instruction or “uninterruptable” parts of code

The Dining Philosophers Plate with food Fork

Philosophers 5 Philosophers either think or eat If a philosopher gets hungry he tries sequentially to obtain 2 forks, one from his right, one from the left How do you make sure that they don’t starve?

Solutions 1: Test and Set Many processors offer a TSL instruction TSL R1, LOCKLAST It reads the value and during the same instruction sets it to 1. Now there can’t be an interrupt between the load and the store as we had in the printer queue If R1 is 1, the process will wait, if it is 0 it means that the resource is available and now locked by P1 This simple test can be used before altering LAST

Solution 2: Semaphores The concept of semaphores extends the idea of test and set to an integer value. A semaphore is a variable that can be incremented or decremented without interrupt

Solution 3: Critical Block If multiple resources are needed as in the deadlock case, we have to ensure, that either all resources are allocated or if only one missing none of them. This operation of locking all has to be immune to interrupts A critical block is a clock of instruction during which a program is immune to interrupts Note: this is a dangerous game and you don’t want to leave this to the user to implement! What happens if it contains a infinite loop?

Solution 4: Detect and Recover All previous attempts aimed at prevention Sometimes it is easier and safer to allow for the possibility of deadlocks Deadlock detection: Dependency graph of resources has cycles Graph for example: In case of deadlock, OS prevents second process to allocate resource that produces a cycle X Y P1 P2

Summary Solutions Inconsistency can be avoided by ensuring uninterrupted blocks of instructions Solutions might involve hardware support (if there is a test and set instruction that is supported by the CPU design) Software support can avoid an interrupt by changing the responsiveness to interrupts in critical sections Software can detect deadlock cases and resolve them

Appendix: More UNIX more file: show content of file ls: show all files in that directory head -n file: Show first n lines of file tail -n file: Show last n lines of file > redirect output into new file >> append redirected output to new file | pipe output into process