1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?

Slides:



Advertisements
Similar presentations
Process Description and Control
Advertisements

Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Chapter 3 Process Description and Control
A. Frank - P. Weisberg Operating Systems Process Scheduling and Switching.
Introduction to Processes
6/9/2015B.Ramamurthy1 Process Description and Control B.Ramamurthy.
Process Description and Control
Process Description and Control Module 1.0. Major Requirements of an Operating System Interleave the execution of several processes to maximize processor.
Process Description and Control Chapter 3. Major Requirements of an Operating System Interleave the execution of several processes to maximize processor.
Figure 2.8 Compiler phases Compiling. Figure 2.9 Object module Linking.
Page 1 Processes and Threads Chapter 2. Page 2 Processes The Process Model Multiprogramming of four programs Conceptual model of 4 independent, sequential.
Page 1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
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.
CSCE 351: Operating System Kernels
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.
Processes and Resources
CSSE Operating Systems
UNIX Process Creation Every process, except process 0, is created by the fork() system call fork() allocates entry in process table and assigns a unique.
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
Process Description and Control Chapter 3. Major Requirements of an OS Interleave the execution of several processes to maximize processor utilization.
Process Description and Control
Operating System 3 PROCESS DESCRIPTION AND CONTROL.
CSNB224 – AAG 2007 Process Description and Control Chapter 3.
Chapter 3 Process Description and Control Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Chapter 3 Process Description and Control
Chapter 3 Process Description and Control Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
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
Operating System 3 PROCESS DESCRIPTION AND CONTROL.
Chapter 3 Process Description and Control
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Chapter 3 Process Description and Control Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic, N.Z.
Threads G.Anuradha (Reference : William Stallings)
Politecnico di Milano © 2001 William Fornaciari Operating System Processes Lecturer: William Fornaciari Politecnico di Milano
Process Description and Control
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.
1 A Seven-State Process Model. 2 CPU Switch From Process to Process Silberschatz, Galvin, and Gagne  1999.
1 Process Description and Control Chapter 3. 2 Requirements of an Operating System Interleave the execution of multiple processes to maximize processor.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
Process Description and control G.Anuradha (Referred from william stallings and galvin 8 th edition)
CSNB224 – AAG 2007 Process Description and Control Chapter 3.
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.
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Process Description and Control
Process concept.
Structure of Processes
Process & its States Lecture 5.
Process Description and Control
Process Description and Control
Process Description and Control
Operating System 3 PROCESS DESCRIPTION AND CONTROL
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Process Description and Control
Process Description and Control
Process Description and Control
Process Description and Control
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Processes in Unix and Windows
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
Process Description and Control
Process Description and Control
Process Description and Control in Unix
Process Description and Control in Unix
Presentation transcript:

1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?

2 Processes vs. Programs Dynamic vs. Static A process is a dynamic execution of instructions from one or more programs A program is a static list of instructions and data Processes own resources (CPU, memory, files, I/O devices, etc.) Many-to-many relationship Multiple executions of one program create multiple processes One process may contain instructions from more than one program

3 OS Requirements for Processes Manage processes Create/destroy processes Maintain process information Allocate/release resources Interleave the execution of processes Schedule processes Support inter-process communication (IPC)

4 A Five-State Process Model

5

6 Dispatcher (short-term scheduler) An OS program that moves the processor from one process to another It prevents a single process from monopolizing processor time It decides who goes next according to a scheduling algorithm (Chapter 9) The CPU will always execute instructions from the dispatcher while switching from process A to process B

7 State Transitions

8 Managing Process Execution Two queues: ready queue and blocked queue When an event occurs, the OS scans the entire blocked queue, searching for those processes waiting on that event This could be slow when the blocked queue is long

9 Multiple Blocked Queues Ready queue without priorities (ex: FIFO) When event n occurs, the corresponding queue is moved into the ready queue

10 A Seven-state Process Model

11 New state transitions Blocked -> blocked suspend When all processes are blocked, the OS will make room to bring a ready process in memory Blocked suspend -> ready suspend When the event for which it has been waiting occurs Ready suspend -> ready When there are no more ready processes in main memory Ready -> ready suspend (unlikely) When there are no blocked processes and must free memory for adequate performance

12 Summary of What a Process is A process is an execution of a program A process has five basic states: New, ready, running, blocked, and exit A process can be suspended by the OS Two new process states Ready, Suspend and Blocked, Suspend are introduced The process execution can be managed through different queues (ready queues and blocked queues) Questions?

13 Process images in virtual memory Each process image is in virtual memory May be big or small depending on the size of the program May not occupy a contiguous range of addresses (depends on the memory management scheme used) Process Image

14 Process images in virtual memory Process Image

15 Process List Structures

16 Summary of Process Representation A process consists of a process image, resources, and a process control block (PCB) A process control block (PCB) consists of: Process Identification Process id, user id, … Processor State Information CPU registers, program status word Process Control Information Process state, priority, waiting events, IPC information, memory information, I/O resources, … Questions?

17 How to Control Processes Process creation Process protection (modes of execution) Mode switching Process switching Relationship between OS and user processes

18 Process Creation Allocate a PCB entry in the process table Allocate space for the process image, load the process image into the allocated space Initialize process control block Assign a unique process identifier Many default values (ex: state is New, no I/O devices or files...) Put the PCB into a queue according to its state

19 Modes of Execution To provide protection to OS data, most processors support at least 2 execution modes: Kernel mode (a.k.a. system mode, privileged mode) manipulating control registers, primitive I/O instructions, memory management, … User mode For this the CPU provides a mode bit (or a few mode bits) which may only be set by an interrupt or trap or OS call

20 When to Switch to Kernel Mode? Supervisor Call explicit request by the program (ex: file open) Trap An error resulted from the last instruction. It may cause the process to be moved to the Exit state Interrupt The cause is external to the execution of the current instruction. Control is transferred to interrupt handler

21 Examples of interrupt processing Clock: happens periodically process has expired its time slice and is transferred to the ready state I/O: happens when an I/O operation finishes first move the processes that were waiting for this event to the ready (or ready suspend) state then resume the running process or choose a process of higher priority Memory fault: happens when referenced address is not in physical memory OS must bring corresponding block into main memory thus move this process to a blocked state (waiting for the I/O to complete)

22 Mode Switching When an interrupt or trap or OS call occurs, the processor mode moves from user mode to kernel mode When the OS finishes processing the interrupt or trap or OS call, the processor mode moves from kernel mode to user mode These are called mode switching Only the processor state information needs to be saved on stack Less overhead than process switching: no need to update the PCB

23 Process Switching Is also called context switching Performed by the OS dispatcher May happen when a mode switch happens If the process switch doesn’t happen on a mode switch, the running user process will continue to run after the processor mode changes back to user mode

24 Steps in Process Switching Save context of processor, including program counter and other registers Update the PCB of the running process with its new state and other associated info Move PCB to appropriate queue - ready, blocked Select another process for execution Update PCB of the selected process Restore CPU context from that of the selected process

25 Relationship Between OS and User Processes The dispatcher of the OS is executed outside of any process How about the other parts of the OS? Are they processes? or Are they also outside of any user process? The answer depends on the OS design

26 Non-process Kernel The concept of process applies only to user programs OS code is executed as a separate entity in privileged mode OS code never gets executed within a process

27 Execution within User Processes Virtually all OS code gets executed within the context of a user process On interrupts, traps, system calls: the CPU switches to kernel mode to execute the OS routine within the context of the user process (mode switch) Control passes to dispatcher (outside processes) only when needed

28 Execution within User Processes OS code and data are in the shared address space and are shared by all user processes Separate kernel stack for calls/returns when the process is in kernel mode Within a user process, both user and OS programs may execute (more than 1)

29 Process-based Operating System The OS is a collection of system processes major kernel functions are separate processes small amount of process switching functions is executed outside of any process This is a design that easily accommodates multiprocessors

30 Comparing the Three OS Designs No # of kernel processes Process switching Process-based- kernel Yes # of user processes Mode switching Within-user- process-kernel No1 Process switching Non-process- kernel Limit the size of user processes # of kernel stacks Cost of OS call

31 Summary of How to Control Processes Most work in process creation is filling the PCB The processes can be protected from different modes supported by the CPU Mode switching happens when the execution changes between user processes and the OS OS controls the process switching when it gains control of CPU through interrupt or trap OS may execute outside of all user processes, in user processes, or as separate processes depending on the OS design Questions?

32 Case Study: UNIX SVR4 Process Management System process and user process Process creation Process states

33 UNIX SVR4 Process management Most of OS executes within user processes Uses two categories of processes: System processes run in kernel mode for housekeeping functions (memory allocation, process swapping...) User processes run in user mode for user programs run in kernel modes for system calls, traps, and interrupts

34 UNIX SVR4 Process States Similar to our 7 state model 2 running states: User and Kernel transitions to other states (blocked, ready) must come from kernel running Sleeping states (in memory, or swapped) correspond to our blocking states A preempted state is distinguished from the ready state (but they form one queue) Preemption can occur only when a process is about to move from kernel to user mode

35 UNIX Process State Diagram

36 UNIX Process Creation Every process, except process 0, is created by the fork() system call fork() allocates an entry in the process table and assigns a unique PID to the child process child gets a copy of process image of parent: both child and parent are executing the same code following fork() but fork() returns the PID of the child to the parent process and returns 0 to the child process

37 UNIX System Processes Process 0 is created at boot time and becomes the “swapper” after forking process 1 (the INIT process) When a user logs in: process 1 creates a process for that user

38 UNIX Process Image User-level context Process Text (i.e. code: read-only) Process Data User Stack (calls/returns in user mode) Shared memory (for IPC) only one physical copy exists but, with virtual memory, it appears as it is in the process’s address space Register context

39 UNIX Process Image System-level context Process table entry the actual entry for this process in the Process Table maintained by OS  Process state, UID, PID, priority, event awaiting, signals sent, pointers to memory holding text, data… U (user) area additional process info needed by the kernel when executing in the context of this process  effective UID, timers, limit fields, files in use, … Kernel stack (calls/returns in kernel mode) Per Process Region Table (used by memory manager)

40 Summary of Process Description and Control A process is an execution of a program A seven-state process model can describe the life time of a process The PCB is an important data structure to represent and manage processes Process switching Relationship between OS and user processes UNIX SVR4 Questions?