Operating Systems Chapter 3 Process Description and Control PDF

Document Details

CongratulatoryMimosa1138

Uploaded by CongratulatoryMimosa1138

Suez Canal University

William Stallings

Tags

operating systems process management computer science OS concepts

Summary

This document is a chapter from a textbook on operating systems. It covers the concepts of process description and control, including important details like process control blocks (PCBs), process states, and execution in an operating system. It provides an overview of the key elements of processes and how an OS manages them.

Full Transcript

Chapter 3 Process Description and Control...

Chapter 3 Process Description and Control Ninth Edition, Global Edition By William Stallings Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Summary of Earlier Concepts A computer platform The OS was developed consists of a to provide a convenient, collection of feature-rich, secure, and hardware resources consistent interface for applications to use Computer applications are We can think of the OS developed to perform some task as providing a uniform, abstract representation It is inefficient for of resources that can be applications to be requested and accessed written directly for a by applications given hardware platform Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. OS Management of Application Execution Resources are made available to multiple applications The processor is switched among multiple applications so all will appear to be progressing The processor and I/O devices can be used efficiently Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Process Elements Two essential elements of a process are: Program code which may be shared with other processes that are executing the same program A set of data associated with that code when the processor begins to execute the program code, we refer to this executing entity as a process Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Process Elements While the program is executing, this process can be uniquely characterized by a number of elements, including: Identifier Program State Priority counter Memory Context I/O status Accounting pointers data information information Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Process Control Block ▪Contains the process elements ▪It is possible to interrupt a running process and later resume execution as if the interruption had not occurred ▪Created and managed by the operating system ▪Key tool that allows support for multiple processes Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Process States Trace Dispatcher The behavior of an individual process by listing the Small program sequence of that switches instructions that the processor execute for that from one process process to another The behavior of the processor can be characterized by showing how the traces of the various processes are interleaved Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Process Execution Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Two-State Process Model Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Table 3.1 Reasons for Process Creation Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Process Creation Process Parent Child spawning process process When the Is the Is the new OS creates original, process a process at creating, the explicit process request of another process Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Process Termination There must be a means for a process to indicate its completion A batch job should include a HALT instruction or an explicit OS service call for termination For an interactive application, the action of the user will indicate when the process is completed (e.g. log off, quitting an application) Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Table 3.2 Reasons for Process Terminatio n (Table is located on page 111 in the textbook) Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Five-State Process Model Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Suspended Processes Swapping Involves moving part of all of a process from main memory to disk When none of the processes in main memory is in the Ready state, the OS swaps one of the blocked processes out on to disk into a suspend queue This is a queue of existing processes that have been temporarily kicked out of main memory, or suspended The OS then brings in another process from the suspend queue or it honors a new-process request Execution then continues with the newly arrived process Swapping, however, is an I/O operation and therefore there is the potential for making the problem worse, not better. Because disk I/O is generally the fastest I/O on a system, swapping will usually enhance performance Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Characteristics of a Suspended Process The process is not The process may or immediately available may not be waiting on for execution an event The process was The process may not placed in a suspended be removed from this state by an agent: state until the agent either itself, a parent explicitly orders the process, or the OS, for removal the purpose of preventing its Copyright execution © 2018 Pearson Education, Ltd. All Rights Reserved. Table 3.3 Reasons for Process Suspension Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Memory Tables Used to keep track of both main (real) and Must secondary (virtual) memory include: Allocation of main memory to processes Processes are maintained on Allocation of secondary memory to processes secondary memory Protection attributes of using some sort of blocks of main or virtual virtual memory or memory simple swapping Information needed to mechanism manage virtual memory Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. I/O Tables Used by the OS to manage the I/O devices and channels of the If an I/O operation is in computer system progress, the OS needs to know: At any given time, an I/O The status of the I/O operation device may be available The location in main memory or assigned to a being used as the source or particular process destination of the I/O transfer Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. File Tables These tables provide information about: Existence of files Location on secondary memory Current status Other attributes Information may be maintained and used by a file management system In which case the OS has little or no knowledge of files In other operating systems, much of the detail of file management is managed by the OS itself Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Process Tables Must be maintained to manage processes There must be some reference to memory, I/O, and files, directly or indirectly The tables themselves must be accessible by the OS and therefore are subject to memory management Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Process Control Structures To manage Where the and process is control a located The attributes process of the process the OS that are must necessary for its management know: Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Process Control Structures Process Location Process Attributes A process must include a Each process has associated program or set of programs to with it a number of attributes be executed that are used by the OS for process control A process will consist of at least sufficient memory to The collection of program, hold the programs and data of data, stack, and attributes is that process referred to as the process image The execution of a program typically involves a stack that Process image location will is used to keep track of depend on the memory procedure calls and parameter management scheme being passing between procedures used Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Table 3.4 Typical Elements of a Process Image Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Table 3.5 Typical Elements of a Process Control Block (page 1 of 2) (Table is located on page 125 in the textbook) Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Table 3.5 Typical Elements of a Process Control Block (page 2 of 2) (Table is located on page 125 in the textbook) Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Process Identification Memory tables may be Each process is assigned a organized to provide a map of unique numeric identifier main memory with an indication of which process is Otherwise there must be a assigned to each region mapping that allows the Similar references will OS to locate the appear in I/O and file tables appropriate tables based on the process identifier When processes communicate with one another, the process Many of the tables controlled identifier informs the OS of by the OS may use process the destination of a particular identifiers to cross-reference communication process tables When processes are allowed to create other processes, identifiers indicate the parent and descendents of each process Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Processor State Information User-visible Contains Consists registers condition codes of the Progra plus other status contents Control and m information of status status EFLAGS register processo registers is an example of a r word (PSW) PSW used by any registers Stack OS running on an pointers x86 processor Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Table 3.6 x86 EFLAGS Register Bits (Table is located on page 127 in the textbook) Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Process Control Information The additional information needed by the OS to control and coordinate the various active processes Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Role of the Process Control Block The most important data structure in an OS Contains all of the information about a process that is needed by the OS Blocks are read and/or modified by virtually every module in the OS Defines the state of the OS Difficulty is not access, but protection A bug in a single routine could damage process control blocks, which could destroy the system’s ability to manage the affected processes A design change in the structure or semantics of the process control block could affect a number of modules in the OS Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Modes of Execution User Mode System Mode Less-privileged More-privileged mode mode User programs Also referred to as typically execute in control mode or this mode kernel mode Kernel of the operating system Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Table 3.7 Typical Functions of an Operating System Kernel Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Process Creation Once the OS decides to create a new process it: Assigns a unique process identifier to the new process Allocates space for the process Initializes the process control block Sets the appropriate linkages Creates or expands other data structures Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Table 3.8 Mechanisms for Interrupting the Execution of a Process Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. System Interrupts Interrupt Trap Due to some sort of event An error or exception that is external to and condition generated within independent of the the currently running currently running process process Clock interrupt OS determines if the I/O interrupt condition is fatal Memory fault Moved to the Exit state and a process switch Time slice occurs The maximum amount Action will depend on the of time that a process nature of the error the can execute before design of the OS being interrupted Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Mode Switching If no interrupts are If an interrupt is pending the pending the processor: processor: Proceeds to the fetch stage and Sets the program counter to the fetches the next instruction of the starting address of an interrupt handler current program in the current process program Switches from user mode to kernel mode so that the interrupt processing code may include privileged instructions Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Change of Process State The steps in Update the process control Move the process a full Save the context block of the control block of process of the processor process currently this process to the switch are: in the Running state appropriate queue If the currently running process is to be moved to another state (Ready, Blocked, etc.), then the OS Select another must make substantial changes in its environment process for execution Restore the context of the processor to that which existed at the time the Update memory Update the selected process management data process control was last switched structures block of the out process selected Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Execution of the Operating System Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Execution Within User Processes Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Summary What is a process? Process control Background Modes of execution Processes and process control Process creation blocks Process switching Process states Execution of the operating system Two-state process model Nonprocess kernel Creation and termination Execution within user Five-state model processes Suspended processes Process-based operating system Process description Operating system control structures Process control structures Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Questions 1) A process is in the _________ state when it is in secondary memory and awaiting an event. 2) Two essential elements of a process are __________ and a set of data associated with that code. 3)The _________ tables provide information about the existence of files, their location on secondary memory, their current status, and other attributes. 4) A significant point about the __________ is that it contains sufficient information so that it is possible to interrupt a running process and later resume execution as if the interruption had not occurred. Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Questions 5) When the OS creates a process at the explicit request of another process, the action is referred to as __________. 6) The process is said to be operating in a _________ fashion if each process in the queue is given a certain amount of time, in turn, to execute and then returned to the queue, unless blocked. 7) A process in the _________ state is in main memory and available for execution. 8) _________ tables are used to keep track of both main (real) and secondary (virtual) memory. 9) The process control block information can be grouped into three general categories: process identification, __________ and process control information. 10) A __________ is the maximum amount of time that a process can execute before being interrupted. 11) The principal function of the OS is to create, manage, and ________ processes 12) The principal function of the OS is to create, manage, and ________ processes. Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. Questions 13) The portion of the operating system that selects the next process to run is called the _________. 14) The collection of program, data, stack, and attributes is referred to as the _________ 15) A process is in the _________ state when it is in main memory and awaiting an event. 16) We can characterize the behavior of an individual process by listing the sequence of instructions, referred to as a __________, that executes for that process. 17)An error or exception condition generated within the currently running process is __________. Copyright © 2018 Pearson Education, Ltd. All Rights Reserved.

Use Quizgecko on...
Browser
Browser