Multiprogramming. Readings r Silberschatz, Galvin, Gagne, “Operating System Concepts”, 8 th edition: Chapter 3.1, 3.2.

Slides:



Advertisements
Similar presentations
Processes Management.
Advertisements

Process management Information maintained by OS for process management  process context  process control block OS virtualization of CPU for each process.
Processes CSCI 444/544 Operating Systems Fall 2008.
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.
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.
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
1/23/2008CSCI 315 Operating Systems Design1 Processes Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating.
CSSE Operating Systems
CSE451 Processes Spring 2001 Gary Kimura Lecture #4 April 2, 2001.
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
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.
Processes in Unix, Linux, and Windows CS-502 Fall Processes in Unix, Linux, and Windows CS502 Operating Systems (Slides include materials from Operating.
Introduction to Processes CS Intoduction to Operating Systems.
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
Multiprogramming CSE451 Andrew Whitaker. Overview Multiprogramming: Running multiple programs “at the same time”  Requires multiplexing (sharing) the.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.
1 RTOS Design Some of the content of this set of slides is taken from the documentation existing on the FreeRTOS website
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.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
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.
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: Processes.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Process-Concept.
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.
1  process  process creation/termination  context  process control block (PCB)  context switch  5-state process model  process scheduling short/medium/long.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
Process Description and Control Chapter 3. Source Modified slides from Missouri U. of Science and Tech.
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.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 4: Processes Process Concept Process Scheduling Types of shedulars Process.
Advanced Operating Systems CS6025 Spring 2016 Processes and Threads (Chapter 2)
Multiprogramming. Readings r Chapter 2.1 of the textbook.
Process concept.
Chapter 3: Processes.
Process Management Process Concept Why only the global variables?
Operating Systems (CS 340 D)
OPERATING SYSTEMS CS3502 Fall 2017
Lecture Topics: 11/1 Processes Process Management
Chapter 3: Processes Source & Copyright: Operating System Concepts, Silberschatz, Galvin and Gagne.
Chapter 3: Processes.
Intro to Processes CSSE 332 Operating Systems
Operating Systems (CS 340 D)
Process management Information maintained by OS for process management
Process & its States Lecture 5.
PROCESS MANAGEMENT Information maintained by OS for process management
Lecture Topics: 11/1 General Operating System Concepts Processes
Processes Hank Levy 1.
Processes and Process Management
Chapter 3: Processes.
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
Processes Hank Levy 1.
Chapter 3: Processes Process Concept Process Scheduling
Presentation transcript:

Multiprogramming

Readings r Silberschatz, Galvin, Gagne, “Operating System Concepts”, 8 th edition: Chapter 3.1, 3.2

Example r Let’s say that you had a program that initialized the value of x to 0 and then incremented x by 1 r What if you printed the value of x to the screen? r What if you printed the value of x to a file? r Does it make a big difference in time?

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 all its instructions finished before process q r Process p has an instruction that requires a read/write from/to disk (or terminal) r Reading from disk is slow r Why not have instructions from q execute while p is waiting?

Why Multiprogramming? r Take an editor such as Emacs or a word processor such as Word m These program often have to get more data from disk m Program is blocked until the data is retrieved m There is a gap between CPU speed and disk speed

Multiprogramming r Multiprogramming allows for the execution of multiple processes r But only one process active at any time

Why Multiprogramming? r Operating systems allow for interleaved execution m On a single-processor system, no more than one process ever runs. 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 in order to maximize CPU utilization.

Modeling Multiprogramming The more I/O the less CPU is utilized unless you have 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 This is referred to as context switching

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 (for scheduling purposes) m etc

Process Control Block (PCB)

13 Context 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 …

14 Context 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

15 Context 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

16 Context 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 …

PCB Representation in Linux r The process control block is represented by the C structure task_struct r Some of the fields in task_struct include: pid_t pid; /* process identifier*/ long state; /*state of the process*/ unsigned int time_slice; /*scheduling information */ struct task_struct sibling; /*this process’s siblings */ struct list_head children; /* this process’s children */ struct files_struct *files; /*list of open files*/

Process Representation in Linux r All active processes are represented using a doubly linked list of task_struct r The kernel maintains a pointer, current, to the process currently executing on the system r Example of the kernel manipulating one the fields in the task_struct is this: current->state = new_state

Process Execution States r As a process executes, it changes execution state r The execution 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 execution 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 Execution 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 When the wait for I/O is over there is a return to the Ready state 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  P ready queue

Process Execution 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 When the wait for I/O is over there is a return to the Ready state 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  P 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 a 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

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

Ready Queue and Various I/O Device Queues

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