+ Post New Thread
Results 1 to 7 of 7
  1. #1
    Junior Member level 2
    Points: 332, Level: 3

    Join Date
    Mar 2017
    Posts
    24
    Helped
    0 / 0
    Points
    332
    Level
    3

    Interrupt during the context switching

    Hi,

    If a high priority interrupt triggers while context switch for the low priority interrupt is in process(not completed), what will happen?

    For the following scenario.

    main program executing..
    low priority interrupt triggers..
    PC pushed to stack
    Status register moved to Stack
    How priority interrupt triggers..


    What will happen now..

    •   Alt9th February 2018, 18:35

      advertising

        
       

  2. #2
    Super Moderator
    Points: 59,034, Level: 59
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    12,038
    Helped
    2787 / 2787
    Points
    59,034
    Level
    59

    Re: Interrupt during the context switching

    Hi,

    No problem.
    The new PC is pushed onto stack
    New SR is puhed onto stack
    High priority ISR is executed
    SR is fetched from stack
    PC is fetched from stack
    ..and it will continue low priority ISR
    ...

    Klaus
    Please don´t contact me via PM, because there is no time to respond to them. Thank you.



    •   Alt9th February 2018, 23:47

      advertising

        
       

  3. #3
    Junior Member level 2
    Points: 332, Level: 3

    Join Date
    Mar 2017
    Posts
    24
    Helped
    0 / 0
    Points
    332
    Level
    3

    Re: Interrupt during the context switching

    Quote Originally Posted by KlausST View Post
    Hi,

    No problem.
    The new PC is pushed onto stack

    Klaus
    Since the PC is not loaded with the vector address of low priority interrupt(low priority isr has not yet started to execute), how does it will be pushed into stack?



    •   Alt12th February 2018, 18:20

      advertising

        
       

  4. #4
    Super Moderator
    Points: 59,034, Level: 59
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    12,038
    Helped
    2787 / 2787
    Points
    59,034
    Level
    59

    Re: Interrupt during the context switching

    Hi,

    Pushing the PC to stack usually is a hardware process. There is no instruction involved. It can not be interrupted.

    So either the the low priority has been started yet....then the PC is already pushed on the stack ... or not.

    Klaus
    Please don´t contact me via PM, because there is no time to respond to them. Thank you.


    1 members found this post helpful.

  5. #5
    Junior Member level 2
    Points: 332, Level: 3

    Join Date
    Mar 2017
    Posts
    24
    Helped
    0 / 0
    Points
    332
    Level
    3

    Re: Interrupt during the context switching

    Quote Originally Posted by KlausST View Post

    So either the the low priority has been started yet....then the PC is already pushed on the stack ... or not.

    Klaus
    I am not getting it. Can you pls elaborate it..

    - - - Updated - - -

    Quote Originally Posted by KlausST View Post

    So either the the low priority has been started yet....then the PC is already pushed on the stack ... or not.

    Klaus
    I am not getting it. Can you pls elaborate it..



  6. #6
    Super Moderator
    Points: 59,034, Level: 59
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    12,038
    Helped
    2787 / 2787
    Points
    59,034
    Level
    59

    Re: Interrupt during the context switching

    Hi,

    main program executing..
    low priority interrupt triggers..
    PC pushed to stack
    Status register moved to Stack
    How priority interrupt triggers..
    ..then the actual PC again is pushed on stack.

    If this is not what you need to know, then draw a timing diagram...with reference to the system clock
    Maybe it's a good idea to say what controller you are talking about.

    Klaus
    Please don´t contact me via PM, because there is no time to respond to them. Thank you.



    •   Alt13th February 2018, 08:13

      advertising

        
       

  7. #7
    Advanced Member level 3
    Points: 6,315, Level: 18

    Join Date
    Jan 2015
    Posts
    921
    Helped
    291 / 291
    Points
    6,315
    Level
    18

    Re: Interrupt during the context switching

    Handling an interrupt is a 'hardware' thing that the processor does.
    Typically when the hardware sees the signal that an interrupt needs to be serviced, it will complete the current instruction, push the PC and status register (whichever that is for your device - normally holds the current state of the CPU in some way) onto the stack and then loads the ISR address into the PC and configures the status register to show that it is processing an interrupt.
    IT is similar to a subroutine call *BUT* more is pushed to the stack. This is why the compiler/assembler needs to told that it is handling an ISR as there is a separate 'return from interrupt' instruction that needs to be executed to restore the PC and the CPU state to that before the interrupt is serviced.
    If you have a processor that has multiple priority interrupts then the process is exactly the same except that a high priority interrupt is allowed to interrupt a lower priority one. If a lower priority interrupt is executing then, when the higher priority one is triggered, the 'status' register that is saved will remember the lower priority state and that is the state that will be restored when the higher priority ISR completes.
    Susan



--[[ ]]--