Lect 06 Process

download Lect 06 Process

of 21

Transcript of Lect 06 Process

  • 8/13/2019 Lect 06 Process

    1/21

    OPERATING SYSTEMS(CS C372 & IS C362)

    LECTURE 6: PROCESS

  • 8/13/2019 Lect 06 Process

    2/21

  • 8/13/2019 Lect 06 Process

    3/21

    Process concept In multi programming / multi tasking environment

    number of processes can reside in the system

    At any instance of time processes can be in differentstate such as Ready, Blocked, Running etc. and

    processes move from one state to another state

    depending upon certain conditions.

    Processes use available system resources

    OS is responsible for managing all the processes in

    the system

    9 August 2011 3Biju K Raveendran@BITS Pilani.

  • 8/13/2019 Lect 06 Process

    4/21

    Process Concept Program has just code NOT Live entity

    Process with data, work-space Stack

    Heap

    Open files File descriptors

    Other primitives

    ipc, memory,

    Execution snapshots Register content

    Program counter General purpose registers

    9 August 2011 Biju K Raveendran@BITS Pilani. 4

  • 8/13/2019 Lect 06 Process

    5/21

    Process in Memory

    9 August 2011 5Biju K Raveendran@BITS Pilani.

  • 8/13/2019 Lect 06 Process

    6/21

    Linux process run-time memory

    Fig courtesy: Computer Systems: a programmers perspective9 August 2011 6Biju K Raveendran@BITS Pilani.

  • 8/13/2019 Lect 06 Process

    7/21

    Example ExecutionMain MemoryAddressDispatcher

    Process A

    Process B

    Process C

    Program Counter0

    100

    5000

    8000

    8000

    12000

    Figure 3.2 Snapshot of Example Execution (Figure 3.4)

    at Instruction Cycle 13

    9 August 2011 7Biju K Raveendran@BITS Pilani.

  • 8/13/2019 Lect 06 Process

    8/21

  • 8/13/2019 Lect 06 Process

    9/21

    A simple scenario: Two-State Process Model

    Process may be in one of two states

    Running

    Not-running

    9 August 2011 9Biju K Raveendran@BITS Pilani.

  • 8/13/2019 Lect 06 Process

    10/21

    Not-Running Process in a Queue

    What processes are in queue?

    Process timed outProcess gone for I/OBoth are 2 different scenarios

    9 August 2011 10Biju K Raveendran@BITS Pilani.

  • 8/13/2019 Lect 06 Process

    11/21

    Process Not-running

    Ready to run given chance

    Blocked/waiting for event

    Why not three states then?

    9 August 2011 11Biju K Raveendran@BITS Pilani.

  • 8/13/2019 Lect 06 Process

    12/21

    Three state model

    Ready Running

    Blocked

    Admit

    Time out

    Dispatch

    Release

    9 August 2011 12Biju K Raveendran@BITS Pilani.

  • 8/13/2019 Lect 06 Process

    13/21

    Three state model: Queuing Diagram

    9 August 2011 13Biju K Raveendran@BITS Pilani.

  • 8/13/2019 Lect 06 Process

    14/21

    Multiple Blocked Queues

    Event 1 Wait

    Event 2 Wait

    Event nWait

    Dispatch

    ReleaseReady QueueAdmit

    Processor

    Timeout

    Event 1 Queue

    Event 1

    Occurs

    Event 2

    Occurs

    Event n

    Occurs

    Event 2 Queue

    Event nQueue

    (b) Multiple blocked queues

    9 August 2011 14Biju K Raveendran@BITS Pilani.

  • 8/13/2019 Lect 06 Process

    15/21

  • 8/13/2019 Lect 06 Process

    16/21

    Why do we need New state New job submission OS creates data structure for keeping track of the

    process context

    OS tries to load the process.

    Load a new process only if

    System have enough memory to hold the process

    System have enough resources to executeprocesses in efficient manner

    To efficiently execute processes, system mayput a maximum limit on processes in readyqueue

    9 August 2011 16Biju K Raveendran@BITS Pilani.

  • 8/13/2019 Lect 06 Process

    17/21

    Five State Model 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

    9 August 2011 17Biju K Raveendran@BITS Pilani.

  • 8/13/2019 Lect 06 Process

    18/21

    Diagram of Process State

    9 August 2011 18Biju K Raveendran@BITS Pilani.

  • 8/13/2019 Lect 06 Process

    19/21

    Process Scheduling Queues

    Job queue set of all processes in the

    system

    Ready queue set of all processes residingin main memory, ready and waiting to execute

    Device queues set of processes waiting for

    an I/O device

    Processes migrate among the various queues

    9 August 2011 19Biju K Raveendran@BITS Pilani.

  • 8/13/2019 Lect 06 Process

    20/21

    Ready Queue And Various I/O Device Queues

    9 August 2011 20Biju K Raveendran@BITS Pilani.

  • 8/13/2019 Lect 06 Process

    21/21

    Representation of Process Scheduling

    9 August 2011 21Biju K Raveendran@BITS Pilani.