Typical Process State Diagram - PowerPoint PPT Presentation

1 / 27
About This Presentation
Title:

Typical Process State Diagram

Description:

Process is ready to execute waiting for CPU allocation OR Process is waiting ... Periodic execution after certain interval like a Screen Saver. Parent process request. ... – PowerPoint PPT presentation

Number of Views:149
Avg rating:3.0/5.0
Slides: 28
Provided by: hardwa
Category:

less

Transcript and Presenter's Notes

Title: Typical Process State Diagram


1
Typical Process State Diagram
New
Admit
Suspend / High Priority Job entries
Admit
Dispatch
No allocated Memory
Activate
Release
Ready Suspend
Ready
Running
Exit
Time Out
Event Occurs
Swap out Disk
Event Wait (I/O wait)
I/O Complete
Wait / Blocked
Activate
Event Occurs
Blocked Suspended
Swap out to Disk
No allocated Memory
2
Process State Diagram of UNIX
3
Thread State Diagram of WINDOWS
4
LINUX Thread State Diagram
5
Significance of States Transitions - 1
  • NEW gtCreate Process Id PCB.
  • NEW ? Ready or ? Ready / Suspend
  • gt Process is ready to execute waiting for
    CPU allocation OR Process is waiting only for
    main memory.
  • Ready / Suspend ? Ready gt Process is ready
    to run waiting to be scheduled/ dispatched.
  • Blocked gt Waiting for an event to Complete.

6
Significance of States Transitions - 2
  • Blocked ? Blocked/ Suspend gt used to make
    available more memory to the Ready processes
    and/ or to the Running Process.
  • Blocked/Suspend ? Ready Suspend gt Process
    waiting for event completion is over but no main
    memory is currently available.
  • Ready ? Ready/ Suspend adopted if that is the
    only way to make available more memory to a high
    priority / currently running process.

7
Significance of States Transitions - 3
  • Blocked /Suspend ? Blocked used to bring a high
    priority waiting process into memory.
  • Running ? Ready /Suspend implies completion
    of time quantum but no memory is currently
    available since a high priority process has
    either moved into the blocked state or has become
    unblocked.

8
Reasons for Process Creation
  • New batch job presented to O.S. for execution.
  • A new user logs on in an interactive system.
  • Spawned /Created by any existing process for
    purpose of modularity or to exploit parallelism.
  • e.g. User process calling an application by a
    command.
  • User process executing a
    Process Creation
  • Call (an SVC).

9
Process Creation Steps 1
  • State New -gt Create a new process. This
    involves the following
  • Assign an Unique Process Identifier (PID).
  • Allocate Space for the entire Process Image in
    the Virtual Memory. Space requirement information
    is obtained from
  • 1) Default based on the process type.
  • 2) Specified by user via Job
    Specification.
  • 3) Supplied by the Parent Process.

10
Process Creation Steps 2
  • Initialize the Process Control Block (PCB) in
    the following manner
  • 1) The processor state information
  • a) Instruction Pointer set to the
    code entry point.
  • b) System Stack pointers set to
    stack
  • boundaries.
  • c) All other registers Flags
    are initialised to
  • all zero .

11
Process Creation Steps 3
  • 2) Process Control Information Section is
    initialised
  • based on default values like
  • a) Process State New ? Ready (If Memory
    Available)
  • OR New ? Ready / Suspend
    otherwise.
  • b) Lowest priority / Specified at the
    time of creation /
  • Inherited from the parent.
  • c) No resources hold except for Disk Swap
    Space /
  • Explicit resource request/ Inherited
    from the parent.

12
Process Creation Steps 4
  • Set appropriate linkages / Put in the relevant
    Queue (Ready OR Ready/ Suspend).
  • Create or Expand other data structures like
    accounting / system log.

13
Reasons for Process Blocking/Waiting
  • Waiting for I/O to complete.
  • Waiting for User response.
  • Waiting for the required resource other than CPU
    memory.
  • Waiting for the spawned child process(s) to
    complete.

14
Reasons for process suspension
  • Swapped out to release main memory for high
    priority Process / Currently running process.
  • Suspended by O.S. (background process, utility).
  • Periodic execution after certain interval like a
    Screen Saver.
  • Parent process request.
  • User request.

15
Reasons for Process Termination - 1
  • Normal Completion.
  • Max. time limit exceeded.
  • Memory unavailable.
  • Bounds of memory violation (illegal unauthorized
    memory access).
  • Protection exception e.g. Bypass the allowable
    access mode of a file.
  • Arithmetic error e.g. division by zero.
  • Wait overdue. Waiting for too long.
  • I/O failure.

16
Reasons for Process Termination - 2
  • Executing invalid instruction / non existing
    instructions.
  • Trying to execute privileged instructions.
  • Accessing improper data / invalid type / not
    initialized.
  • Operator intervention e.g. too large a print
    out, infinite looping.
  • O.S. intervention to prevent deadlock from
    occurring.
  • Terminated by the parent process.
  • Termination requested by the parent process.

17
Possible Reasons for Context Switching of the
Processor (CPU)
  • 1) Timer Interrupt (Time Quantum over for
    the
  • currently running process).
  • 2) A process having higher priority has
    become
  • ready .
  • 3) The currently running process has
    become blocked or
  • has Terminated which leaves the CPU
    idle (triggered
  • by a Mode Switch) thereby
    necessitating
  • a new process to be scheduled.
  • 4) Main Memory has become FULL /
    AVAILABLE.

18
Context Switching of the Processor (Salient
Features)
  • Brings in the following Operating system
    processes into stand alone execution
  • a) The Context Switcher to accomplish
    saving old
  • Execution status Thread loading
    new Status .
  • b) The Dispatcher / Scheduler for picking
    out
  • the next process to be allotted the
    CPU (usually
  • from the Ready Queue) based on a
    predefined
  • short term scheduling policy (to be
    illustrated later).
  • c) The Enqueuer / Dequeuer for updating
    various
  • process queues at different states.

19
Context Switching / Change of a Process State (
The Steps Involved )
  • Save the current Processor Context Currently
    running Process context The Current Thread in
    relevant (User ) Stack
  • Update the PCBs of all those processes that are
    changing state.
  • Move the requisite PCBs in the relevant Queue.
  • Update Memory Management data structures to
    facilitate address translation.
  • Restore / Reload Processor Context Some Prev.
    /A New Thread

20
Types Modes of Execution
  • Two types of processes
  • User Processes.
  • Supervisor/ Monitor/ Kernel Process.
  • In most contemporary Operating Systems like
    UNIX / Windows 2000 , in the context of the same
    process the computation changes mode from user to
    kernel mode , then execution continues at a
    higher priority and privilege level subsequently
    it comes back to user mode.

21
The Kernel the User Relationships

22
Mode Switching Scenario - 1
  • User Mode to Kernel Mode caused by one of the
    following
  • 1) User process asks for an O.S. Service
    via a Supervisor Call /
  • Software Interrupt.
  • 2) A trap / Exception occurs in an
    instruction while executing in
  • the user mode.
  • 3) A device interrupt occurs .
  • In ALL cases , however, the state of
    the currently running
  • process almost always changes (from
    Running -gt Ready
  • OR ? Ready /Suspended OR ? Terminated OR
    alternately from
  • Running --gt Blocked ) followed by a
    Context Switch to invoke
  • the Dispatcher / Scheduler.

23
Mode Switching of any Process ( from User to
Kernel ) Steps performed in Kernel Mode
  • Save the context of the currently running
    program (the current thread) in the relevant
    stack (usually in the System Stack).
  • Set up appropriate flag(s) properly in the
    Processor status Register to indicate mode
    switching.
  • Transfers control to the start position of the
    relevant System Set Up Routine.
  • Initiate necessary State Transitions in the
    System (if needed).

24
Mode Switching Scenario - 2
  • Kernel Mode to User Mode normally happens
    either
  • 1) By executing some privileged instruction.
  • 2) By an ordinary RETURN instruction after
  • completion of service.

25
Process State Diagram of UNIX
26
Thread State Diagram of WINDOWS
27
LINUX Thread State Diagram
Write a Comment
User Comments (0)
About PowerShow.com