Chapter 3 – Process Concepts PDF

Summary

This document is a chapter on process concepts in computer science. It defines what a process is, explaining how they are managed via operating systems and their different states. The document covers process creation, process operations and how they relate to the operating systems that manage them.

Full Transcript

1 Chapter 3 – Process Concepts  2004 Deitel & Associates, Inc. All rights reserved. 2 3.1 Introduction Computers perform operat...

1 Chapter 3 – Process Concepts  2004 Deitel & Associates, Inc. All rights reserved. 2 3.1 Introduction Computers perform operations concurrently – For example, compiling a program, sending a file to a printer, rendering a Web page, playing music and receiving e-mail – Processes enable systems to perform and track simultaneous activities  2004 Deitel & Associates, Inc. All rights reserved. 3 3.1.1 Definition of Process Process: a program in execution; process execution must progress in sequential fashion. No parallel execution of instructions of a single process – A process has its own address space consisting of: Text region – Stores the code that the processor executes Data region – Stores variables and dynamically allocated memory Stack region containing temporary data ,Function parameters, return addresses, local variables, containing global variables – Stores instructions and local variables for active procedure calls – The contents of the stack grow as a process issues nested procedure calls and shrink as called procedures return. Heap containing memory dynamically allocated during run time  2004 Deitel & Associates, Inc. All rights reserved. 4 Program is passive entity stored on disk (executable file); process is active – Program becomes process when an executable file is loaded into memory Execution of program started via GUI mouse clicks, command line entry of its name, etc. One program can be several processes – Consider multiple users executing the same program  2004 Deitel & Associates, Inc. All rights reserved. Memory Layout of a C Program  2004 Deitel & Associates, Inc. All rights reserved. Process State As a process executes, it changes state – New: The process is being created – Running: Instructions are being executed – Waiting: The process is waiting for some event to occur – Ready: The process is waiting to be assigned to a processor – Terminated: The process has finished execution  2004 Deitel & Associates, Inc. All rights reserved. Diagram of Process State  2004 Deitel & Associates, Inc. All rights reserved. 8 3.2 Process States: Life Cycle of a Process The OS maintains a ready list and a blocked list to store references to processes not running – The ready list is maintained in priority order, so that the next process to receive a processor is the first one in the list (i.e., the process with the highest priority). – The blocked list is typically unordered processes do not become unblocked (i.e., ready) in priority order; rather, they unblock in the order in which the events they are waiting for occur.  2004 Deitel & Associates, Inc. All rights reserved. 9 3.3 Process Management Operating systems provide fundamental services to processes including: – Creating processes – Destroying processes – Suspending processes – Resuming processes – Changing a process’s priority – Blocking processes – Waking up processes – Dispatching processes – Interprocess communication (IPC)  2004 Deitel & Associates, Inc. All rights reserved. 10 3.3.1 Process States and State Transitions To prevent any one process from monopolizing the system, either accidentally or maliciously, the operating system sets a hardware interrupting clock (also called an interval timer) to allow a process to run for a specific time interval or quantum. The OS may use an interval timer to allow a process to run for a specific time interval or quantum State Transitions – At this point, there are four possible state transitions When a process is dispatched, it transitions from ready to running When the quantum expires, it transitions from running to ready When a process blocks, it transitions from running to blocked When the event occurs, it transitions from blocked to ready  2004 Deitel & Associates, Inc. All rights reserved. 11 3.3.2 Process Control Blocks (PCBs)/Process Descriptors PCBs maintain information that the OS needs to manage the process – Typically include information such as Process identification number (PID) Process state Program counter: a value that determines which instruction the processor should execute next Scheduling priority: Credentials: data that determines the resources this process can access A pointer to the process’s parent process: the process that created this process Pointers to the process’s child processes: processes created by this process Pointers to locate the process’s data and instructions in memory Pointers to allocated resources: such as files Register contents, called the execution context, of the processor on which the process was last running when it transitioned out of the running state.  2004 Deitel & Associates, Inc. All rights reserved. 12 3.3.2 Process Control Blocks (PCBs)/Process Descriptors Process table – The OS maintains pointers to each process’s PCB in a system- wide or per-user process table – Allows for quick access to PCBs – When a process is terminated, the OS removes the process from the process table and frees all of the process’s resources – When a process transitions from one state to another, the operating system must update information in the process’s PCB.  2004 Deitel & Associates, Inc. All rights reserved. 13 3.3.2 Process Control Blocks (PCBs)/Process Descriptors Figure 3.2 Process table and process control blocks.  2004 Deitel & Associates, Inc. All rights reserved. 14 3.3.3 Process Operations A process may spawn a new process – The creating process is called the parent process – The created process is called the child process – Exactly one parent process creates a child – When a parent process is destroyed, operating systems typically respond in one of two ways: Destroy all child processes of that parent Allow child processes to proceed independently of their parents  2004 Deitel & Associates, Inc. All rights reserved. 15 3.3.3 Process Operations Figure 3.3 Process creation hierarchy.  2004 Deitel & Associates, Inc. All rights reserved.

Use Quizgecko on...
Browser
Browser