Question about application of PendSV

Reading jyiu book on Cortex-M4 and general information about usage of PendSV exception type.

One application highlighted is of context switching in the RTOS wherein on a Systick timer interrupt, instead of context switching, it will set the PendSV bit. This will then execute the context switching at the lowest priority after all other interrupts have been handled. Again this is because the priority of PendSV will be kept the lowest.

However, is the same not possible if we just lower down the priority of Systick timer exception? In that case, if any interrupt is active, the systick timer exception handler will get executed after all other interrupts are done with.

If that is possible, then what is the major benefit in using PendSV?

Am I missing something?

Parents
  • Hello Gopal,

    my understanding of PendSV is it is a sort of the asynchronous trap.

    The word of the asynchronous means the trap does not occur immediately for the request and it will be pending until an appropriate time.

    Although I have not read the Mr. Joseph Yiu's book, I think the example would say that the SysTick interrupt requested the context switch but the context switch should be postponed until all other interrupt requests would be handled.

    Anyway, Mr. Joseph Yiu will give us clear answer.

    Best regards,

    Yasuhiko Koumoto.

  • Thank you yasuhikokoumoto

    Yes that is correct that it is kind of asynchronous trap/exception. But I wonder the same purpose may be achieved using low priority Systick. Or there may be some more uses of the pendsv which I have not understood.

    There is another example for non-OS based systems like you can split a long running ISR in two parts. First you execute the high priority work in the main ISR and then rest of the low priority work can be postponed to PendSV handler. This makes sense.

Reply
  • Thank you yasuhikokoumoto

    Yes that is correct that it is kind of asynchronous trap/exception. But I wonder the same purpose may be achieved using low priority Systick. Or there may be some more uses of the pendsv which I have not understood.

    There is another example for non-OS based systems like you can split a long running ISR in two parts. First you execute the high priority work in the main ISR and then rest of the low priority work can be postponed to PendSV handler. This makes sense.

Children
More questions in this forum