context switching steps

Upload: haritha

Post on 21-Feb-2018

232 views

Category:

Documents


1 download

TRANSCRIPT

  • 7/24/2019 Context Switching Steps

    1/13

    Context switching steps

  • 7/24/2019 Context Switching Steps

    2/13

    Introduction ContextSwitching

    Context switching is the process ofstoring the context of one processand switches to another process sothat the execution of the rst processcan be resumed later.

  • 7/24/2019 Context Switching Steps

    3/13

    Steps involved in contextswitching

    The entire process of contextswitching takes seven steps tocomplete.

    Let us assume processes task !and task ". The latter has higherpriorit#.

    Task " has alread# executedpreviousl# and is now is read# state.

    Task ! is currentl# executing

  • 7/24/2019 Context Switching Steps

    4/13

    Step $

    Task ! is executing.

    %C points to thenext instruction tobe executed.

    S% points to thestack of task !.

  • 7/24/2019 Context Switching Steps

    5/13

    Step

    &T'S tick occurs as theprocessor is about toexecute L(I &)* )

    The tick is a Softwaregenerated interrupt thatoccurs after thecompletion of a time slice.

    "efore execution of tickIS& routine* the %C valuegets pushed into stack

  • 7/24/2019 Context Switching Steps

    6/13

    Step + Tick IS& &outine

  • 7/24/2019 Context Switching Steps

    7/13

    Step + contd, %ort-S!/-C'0T/1T

    234 saves theexecution context oftask ! in the stackof task !

    Stack pointer of !will point to the topof context of !.

    This functioncompletes b#storing a cop# ofthe stack pointer.

  • 7/24/2019 Context Switching Steps

    8/13

    Step 5

    vTaskIncrementTick234 increments thetick value b# $ and as this occurs thetask " is in read# state.

    vTaskSwitchContext234 chooses thenext task that gets to use theprocessor resources.

  • 7/24/2019 Context Switching Steps

    9/13

    Step 6

    port-&/ST'&/-C'0T/1T234 executes.

    The rst operation isdoes is it restores the

    S% value of task ".

  • 7/24/2019 Context Switching Steps

    10/13

    Step 7

    0ext the contexts of

    task " are retrievedfrom the stack.

    The %C value stillremains in the stack.

  • 7/24/2019 Context Switching Steps

    11/13

    Step 8

    &/TI marks the endof the interrupt andso the value of %C isrestored from stackwhich is the value of%C of task ".

    Thus* the processorhas switched fromexecuting task ! totask ".

  • 7/24/2019 Context Switching Steps

    12/13

  • 7/24/2019 Context Switching Steps

    13/13

    T9!0: ;'