Multiprogramming. Readings r Chapter 2.1 of the textbook.

Slides:



Advertisements
Similar presentations
Processes Management.
Advertisements

CHAPTER 2 PROCESSOR SCHEDULING PART I By U ğ ur HALICI.
Processes CSCI 444/544 Operating Systems Fall 2008.
Figure 2.8 Compiler phases Compiling. Figure 2.9 Object module Linking.
1/27/2010CSCI 315 Operating Systems Design1 Processes Notice: The slides for this lecture have been largely based on those accompanying an earlier version.
1 Process Description and Control Chapter 3. 2 Process Management—Fundamental task of an OS The OS is responsible for: Allocation of resources to processes.
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
CSSE Operating Systems
CSE451 Processes Spring 2001 Gary Kimura Lecture #4 April 2, 2001.
Processes April 5, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
Process Concept An operating system executes a variety of programs
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Process by Dr. Amin Danial Asham. References Operating System Concepts ABRAHAM SILBERSCHATZ, PETER BAER GALVIN, and GREG GAGNE.
Operating Systems (CSCI2413) Lecture 3 Processes phones off (please)
Process Description and Control A process is sometimes called a task, it is a program in execution.
Implementing Processes and Process Management Brian Bershad.
Chapter 41 Processes Chapter 4. 2 Processes  Multiprogramming operating systems are built around the concept of process (also called task).  A process.
Chapter 3 Advanced Operating System
Chapter 3 Process Description and Control
Chapter 4 Processes. Process: what is it? A program in execution A program in execution usually usually Can also have suspended or waiting processes Can.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Scheduling Example 3 (1) Assume: FIFO Job Scheduling 100 K Main Memory Processor Sharing Process Scheduling (Cont…)
Process by Dr. Amin Danial Asham. References Operating System Concepts ABRAHAM SILBERSCHATZ, PETER BAER GALVIN, and GREG GAGNE.
Multiprogramming. Readings r Silberschatz, Galvin, Gagne, “Operating System Concepts”, 8 th edition: Chapter 3.1, 3.2.
Computer Studies (AL) Operating System Process Management - Process.
Chapter 2 Processes and Threads Introduction 2.2 Processes A Process is the execution of a Program More specifically… – A process is a program.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Process-Concept.
Concurrency & Context Switching Process Control Block What's in it and why? How is it used? Who sees it? 5 State Process Model State Labels. Causes of.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Process-Concept.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
Operating Systems (CS 340 D) Dr. Abeer Mahmoud Princess Nora University Faculty of Computer & Information Systems Computer science Department.
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.
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.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 4: Processes Process Concept Process Scheduling Types of shedulars Process.
Process Control Management Prepared by: Dhason Operating Systems.
Advanced Operating Systems CS6025 Spring 2016 Processes and Threads (Chapter 2)
Processes and threads.
Process concept.
Process Management Process Concept Why only the global variables?
Chapter 3: Process Concept
Operating Systems (CS 340 D)
Sujata Ray Dey Maheshtala College Computer Science Department
OPERATING SYSTEMS CS3502 Fall 2017
Lecture Topics: 11/1 Processes Process Management
Process Description and Control
Chapter 3: Processes.
Intro to Processes CSSE 332 Operating Systems
Operating Systems (CS 340 D)
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.
Process management Information maintained by OS for process management
Process & its States Lecture 5.
Chapter 3: Processes.
PROCESS MANAGEMENT Information maintained by OS for process management
Process Description and Control
Lecture Topics: 11/1 General Operating System Concepts Processes
Processes Hank Levy 1.
Processes and Process Management
Chapter 3: Processes.
October 7, 2002 Gary Kimura Lecture #4 October 7, 2002
CSE 451: Operating Systems Winter 2003 Lecture 4 Processes
Processes in Unix and Windows
CS510 Operating System Foundations
CSE 451: Operating Systems Autumn 2004 Module 4 Processes
CSE 153 Design of Operating Systems Winter 2019
Processes Hank Levy 1.
Chapter 3: Processes Process Concept Process Scheduling
Chapter 3: Process Management
Presentation transcript:

Multiprogramming

Readings r Chapter 2.1 of the textbook

Multiprogramming r Assume we have two programs P and Q. r Each is started up to make two processes p and q. r It is not the case that process p has have all its instructions finished before process q r Process p has an instruction that requires a read from disk r Reading from disk is slow r Why not have instructions from q execute while waiting r There are many issues to be addressed which we will discuss

Multiprogramming r Allow for the execution of multiple programs r Only one program active at any time r Example: Look at Microsoft Word m Microsoft Word has to go to the disk a lot m Program is often blocked until the data is retrieved

Multiprogramming r Allow for the execution of multiple programs r Only one program active at any time r Example: Look at Microsoft Word m Microsoft Word uses more disk space CPU m Often has to get more data from memory or disk m Program is often blocked until the data is retrieved

Why Multiprogramming? r Take an editor such as Emacs or a word processor such as Word m These programs make more use of disk space and memory than CPU cycles m They often have to get more data from memory or disk m Program is blocked until the data is retrieved m There is a gap between CPU speed and memory speed as well as between CPU speed and memory speed

Example r Let’s say that you had a program that computed the sum of the square roots of numbers from 0 to N e.g., for (i=0; i < num_iterations; i++) sum = sum + sqrt((double) i); r What if we periodically printed intermediate values of the variable sum to the terminal or to a file? r Does it make a big difference in time?

Why Multiprogramming? r Operating systems allow for interleaved execution m On a single-processor system, no more than one process ever runs at the same time. m However, one process’s instructions may be executed before the completion of the instructions from another process r The objective is to have some process running at all times, to maximize CPU utilization.

Modeling Multiprogramming

Process Switching r Current process executes an I/O operation r OS needs to be able to suspend current process so that another process can execute r Referred to as context switching

11 Process Switching r Program instructions operate on operands in memory and (temporarily) in registers Memory Prog1 Code Prog1 Data CPU ALU SPPC Prog2 State Prog1 has CPU Prog2 is suspended Prog2 Code Prog2 Data Load A1, R1 Load A2, R2 Add R1, R2, R3 Store R3, A3 …

12 Process Switching r Saving all the information about a process allows a process to be temporarily suspended and later resumed from the same point Memory Prog1 Code Prog1 Data CPU ALU SPPC Prog1 State OS suspends Prog1 Prog2 Code Prog2 Data Prog2 State

13 Process Switching r Saving all the information about a process allows a process to be temporarily suspended and later resumed Memory Prog1 Code Prog1 Data CPU ALU SPPC Prog1 State OS resumes Prog2 Prog2 Code Prog2 Data Prog2 State

14 Process Switching r Program instructions operate on operands in memory and in registers Memory Prog1 Code Prog1 Data CPU ALU SPPC Prog1 State Prog2 has CPU Prog1 is suspended Prog2 Code Prog2 Data Load A1, R1 Load A2, R2 Sub R1, R2, R3 Store R3, A3 …

Process Switching r OS needs to be able to suspend current process r OS captures information about a process r Information captured must be sufficient to restore the hardware to the same configuration it was in when the process was switched out.

Characterizing a Process r Each process is represented in the OS by a process control block (PCB) which contains all the state for a program in execution including (but not limited to): m Pointer to text, data and stack segment information m An execution stack encapsulating the state of procedure calls m The program counter (PC) indicating the next instruction m Current values of the set of general-purpose registers m A set of operating system resources e.g., open files, network connections m Process identifier (PID) m Process priority m etc

Process States r As a process executes, it changes state r The state of a process is defined in part by the current activity of the process r A process may be in one of the following states: m New: The process is being created m Running: Instructions are being executed m Waiting: The process is waiting for some event to occur (such as an I/O completion or reception of signal) m Ready: The process is waiting to be assigned to a processor m Exit: The process has finished executing r Only one process can be running on any processor at any instant r Many processes may be ready and waiting

Process States NewReadyRunningExit Waiting When you run a program, a new process is created If the system has sufficient memory, then the new process is loaded into memory and placed in ready queue CPU scheduler takes a process from the head of a ready queue to execute (Sometimes, there may be multiple ready queues.) Admit Dispatch Timeout Event Occurs Event Wait After finish execution, exit If processes are scheduled in a round robin manner, then when time quantum expires, the process is returned to ready queue If processes are scheduled in a round robin manner, then when time quantum expires, the process is returned to ready queue Process may be blocked by: - I/O (wait for I/O to complete) - semaphore wait - sleep - etc. When the waiting is over  An interrupt is generated  Process is then returned to ready queue

Question Why is there no arrow from waiting to running? When should a process be preempted?

Scheduling r The purpose of multiprogramming is to have some process running at all times r The objective of time sharing is to switch the CPU among processes so frequently that users can interact with each process r The process scheduler selects an available process r There may be multiple processes to select from

Scheduling Queues r As processes enter the system, they are put into a job queue, which consists of all processes in the system r The processes that are residing in main memory and are ready and waiting to execute are kept on a list called the ready queue r Queues are implemented using linked list r A ready queue header contains pointers to the first and last final process control blocks in the list r Each PCB includes a pointer field that points to the next PCB in the ready queue

Process Control Block (PCB) Pointer (linked list) Process state Program counter CPU registers Memory limits Open files Accounting info (e.g., running time)

Other Queues r When a process is allocated the CPU, it executes for a while and eventually quits, is interrupted, or waits for the occurrence of a particular event, such as the completion of an I/O request r The list of processes waiting for a particular I/O device is called a device queue

Question What happens to a process’s PCB when it is waiting in a device queue?

Issues Related to Multiprogramming r Shell m Creating new processes (already discussed) r Threads m A “lighter weight” process r Scheduling m Determining when a process should run r Booting m How do we get the first process

Summary r Discussed the need for multiprogramming r Process representation