PROCESS MANAGEMENT Information maintained by OS for process management

Slides:



Advertisements
Similar presentations
Process management Information maintained by OS for process management  process context  process control block OS virtualization of CPU for each process.
Advertisements

Concurrency: Threads, Address Spaces, and Processes Sarah Diesburg Operating Systems COP 4610.
Why Concurrency? Allows multiple applications to run at the same time  Analogy: juggling.
CSC 501 Lecture 2: Processes. Von Neumann Model Both program and data reside in memory Execution stages in CPU: Fetch instruction Decode instruction Execute.
Processes CSCI 444/544 Operating Systems Fall 2008.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
OS Spring’03 Introduction Operating Systems Spring 2003.
Ceng Operating Systems Chapter 2.1 : Processes Process concept Process scheduling Interprocess communication Deadlocks Threads.
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
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.
Process Description and Control Chapter 3. Major Requirements of an OS Interleave the execution of several processes to maximize processor utilization.
Threads Many software packages are multi-threaded Web browser: one thread display images, another thread retrieves data from the network Word processor:
Implementing Processes and Process Management Brian Bershad.
Concurrency: Threads, Address Spaces, and Processes Andy Wang Operating Systems COP 4610 / CGS 5765.
Exec Function calls Used to begin a processes execution. Accomplished by overwriting process imaged of caller with that of called. Several flavors, use.
Chapter 3 Process Description and Control
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
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.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.
1 Chapter 2.1 : Processes Process concept Process concept Process scheduling Process scheduling Interprocess communication Interprocess communication Threads.
Process by Dr. Amin Danial Asham. References Operating System Concepts ABRAHAM SILBERSCHATZ, PETER BAER GALVIN, and GREG GAGNE.
OS, , Part II Processes Department of Computer Engineering, PSUWannarat Suntiamorntut.
Multiprogramming. Readings r Silberschatz, Galvin, Gagne, “Operating System Concepts”, 8 th edition: Chapter 3.1, 3.2.
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.
Concurrency, Processes, and System calls Benefits and issues of concurrency The basic concept of process System calls.
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.
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.
Embedded Real-Time Systems
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Multiprogramming. Readings r Chapter 2.1 of the textbook.
Processes and threads.
Process Tables; Threads
Process concept.
Process Management Process Concept Why only the global variables?
CSCS 511 Operating Systems Ch3, 4 (Part B) Further Understanding Threads Dr. Frank Li Skipped sections 3.5 & 3.6 
OPERATING SYSTEMS CS3502 Fall 2017
Protection of System Resources
Lecture Topics: 11/1 Processes Process Management
Day 08 Processes.
Day 09 Processes.
Process Realization In OS
Intro to Processes CSSE 332 Operating Systems
Concurrency: Threads, Address Spaces, and Processes
Process management Information maintained by OS for process management
Processes in Unix, Linux, and Windows
CSCI 511 Operating Systems Ch3, 4 (Part B) Further Understanding Threads Dr. Frank Li Skipped sections 3.5 & 3.6 
Concurrency: Threads, Address Spaces, and Processes
More examples How many processes does this piece of code create?
Process Tables; Threads
CSE 451: Operating Systems Spring 2012 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Process & its States Lecture 5.
Process Description and Control
Lecture Topics: 11/1 General Operating System Concepts Processes
Processes Hank Levy 1.
Operating System 3 PROCESS DESCRIPTION AND CONTROL
Processes and Process Management
Process Description and Control
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Operating Systems: A Modern Perspective, Chapter 6
Processes in Unix, Linux, and Windows
Processes in Unix and Windows
Processes Hank Levy 1.
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment. Phone:
Concurrency: Threads, Address Spaces, and Processes
Chapter 3: Process Management
Presentation transcript:

PROCESS MANAGEMENT Information maintained by OS for process management Process context Process control block OS virtualization of CPU for each process. Context switching Dispatching loop

PROCESS A program in execution We should know about processes by now. How does the OS correctly run multiple processes concurrently? What kind of information to be kept? What does the OS have to do in order to run processes correctly.

PROCESS CONTEXT Contains all states necessary to run a program MAX stack Contains all states necessary to run a program The information the process needs to do the job: code, data, stack, heap. This is known as User level context. heap data text (code) Process in memory

USER LEVEL CONTEXT … int aa; char buf[1000]; void foo() { int a; } MAX (b, *p) - main (a) - foo … int aa; char buf[1000]; void foo() { int a; } main() { int b; char *p; p = new char[1000]; foo(); stack heap (p) (char[1000]) data (aa, buf) text (code) Process memory

PROCESS CONTEXT Contains all states necessary to run a program Is the user level context sufficient? Only if the system runs through one program at a time The system typically needs to switch back and forth between programs. R0 = 1 R0 = 2 R2 = R0 + 1 R2 = R0 R2 in P1 is wrong. How to make It correct? Save R0 in P1 before switching Restore R0 in P1 when switching from P2 to P1. Registers should be a part of process context: the register context!

Process context: User level context Code, data, stack, heap Register context (R0, R1,…, PC, stack pointer, PSW, etc). What else? OS resources. E.g open files, signal related data structures, etc.

WHY IS PROCESS CONTEXT IMPORTANT? To run a process correctly, the process instructions must be executed within the process context!

Where is the process context stored? User level context is in memory. Other context information is stored in a data structure called process control block. The OS has a process control block table. For each process, there is one entry in the table. Process control block also contains other information that the OS needs to manage the processes. Process status (running, waiting, etc) Process priority ……

An example PCB Figure 3.3

OS CPU ABSTRACTION Hardware reality: OS abstraction: One CPU runs the fetch-execute algorithm OS abstraction: Each process has one CPU, running the fetch-execute algorithm for the process. Each process executes within its context. Load PC; IR = MEM[PC]; While (IR != HALT) { PC ++; Execute IR; }

OS CPU ABSTRACTION What does the OS have to do? Embed the process instruction sequence into hardware instruction sequence. Process X instructions: x0, x1, x2, …. Process Y instructions: y0, y1, y2, … Process Z instructions: z0, z1, z2, … Hardware instructions? x0, x1, x2, y0, y1, y2, z0, z1, z2, x3, x4, x5, … Does this embedding work? No!! Instructions in a process should only be executed within the process’s context to be correct.

OS CPU ABSTRACTION Process X instructions: x0, x1, x2, …. Process Y instructions: y0, y1, y2, … Process Z instructions: z0, z1, z2, … x0, x1, x2, [store X’s context], [restore Y’s context] y0, y1, y2… OS must do this to keep programs execute within its context: Context switching

DISPATCHING LOOP The hardware view of the system execution: dispatching loop LOOP Run process Save process states Choose a new process to run Load states for the chosen process Context Switch: Dispatcher code Scheduling

SIMPLE? NOT QUITE… How does the dispatcher (OS) regain control after a process starts running? What states should a process save? How does the dispatcher choose the next thread?

HOW DOES THE DISPATCHER REGAIN CONTROL? Two ways: Internal events A process is waiting for I/O A process is waiting for some other process Yield—a process gives up CPU voluntarily External events Interrupts—a complete disk request Timer—it’s like an alarm clock

WHAT STATES SHOULD A PROCESS SAVE? Anything that the next process may trash Program counter Registers Etc.

HOW DOES THE DISPATCHER CHOOSE THE NEXT PROCESS? The dispatcher keeps a list of processes that are ready to run If no processes are ready Dispatcher just loops Otherwise, the dispatcher uses a scheduling algorithm to find the next process.

PROCESS STATES A process is typically in one of the three states Running: has the CPU Blocked: waiting for I/O or another thread Ready to run: on the ready list, waiting for the CPU

Figure 3.2