Interrupt Routines in an RTOS Environment - Part 2

Figure below shows what really happens, at least in the worst case. If the higher-priority task is blocked on the mailbox, then as soon as the interrupt routine writes to the mailbox, the RTOS unblocks the higher-priority task. Then the RTOS (knowing nothing about the interrupt routine) notices that the task that it thinks is running is no highest-priority task that is ready to run. Therefore, instead of returning to the interrupt routine (which the RTOS thinks is part of the lower priority task), the RTOS switches to the higher-priority task. The interrupt routine doesn’t get to finish until later.

RTOSs use various methods for solving this problem, but all require your cooperation. Figure shows the first scheme. In it, the RTOS intercepts all the interrupts and then calls your interrupt routine. By doing this, the RTOS finds out when an interrupt routine has started. When the interrupt routine later writes to mailbox, the RTOS knows to return to the interrupt routine and not to switch tasks, no matter what task is unblocked by the write to the mailbox. When the interrupt routine is over, it returns, and the RTOS gets control again. The RTOS scheduler then figures out what task should now get the microprocessor.

If your RTOS uses this method, then you will need to call some function within the RTOS that tells the RTOS where your interrupt routines are and which hardware interrupts correspond to which interrupt routines.

 

Figure shows an alternative scheme, in which the RTOS provides a function that the interrupt routines call to let the RTOS know that an interrupt routine is running. After the call to that function, the RTOS knows that an interrupt routine is in progress, and when the interrupt routine writes to the mailbox the RTOS always returns to the interrupt routine, no matter what task is ready, as in the figure. When the interrupt routine is over, it jumps to or calls some other function in RTOS, which calls the scheduler to figure out what task should now get the microprocessor. Essentially, this procedure disables the scheduler for the duration of the interrupt routine.

 

In this plan, your interrupt routines must call the appropriate RTOS functions at the right moments.

About Us

  • Micromagine Embedded System Design
    3rd Floor,
    Triveni Sangam Appartment,
    Opp. Divyabhaskar Office,
    Kishan Para Chowk,
    Rajkot - 360001

  • info@micromagine.com
    info@micromagine.com

  • (+91) 9429160113

Services & Support

Premium Joomla Templates