FreeRTOS Tick and Tick Handling
This post represents the fifth phase of porting FreeRTOS for AEMB processor.
The main concern of this phase is to get the FreeRTOS configured to demonstrate the Preemptive Multitasking. By far this phase deals with the following:
- Setting up the timer to generate the RTOS Tick
- Handling the RTOS Tick
In the previous post, cooperative multitasking was intoduced and successfully demonstrated. However in cooperative multitasking, the interrupt and the interrupt handling had not yet been implemented. As a result, there was no need for a time measurement to run the kernel.
In contrast to the cooperative kernel, preemptive kernel needs a time measurement so it preempts the running tasks at regular intervals in order to check if a context-switch is required. For that reason, a timer was set to generate an interrupt with a suitable interrupt frequency. FreeRTOS refers to the interrupt generated by the timer as Real-Time Operating System Tick (RTOS Tick).
When an interrupt occurs the AEMB saves the value of the MSR, program counter and other information. Right after that, the control jumps to the corresponding interrupt handler (In our project case, it jumps to the Tick handler or the Tick ISR). When the interrupt handler has completed it restores the status register, program counter and all the important information to go back to the point when the interrupt has happened.
So far the interrupt and the interrupt handler are ready and set to produce the preemptive scheduling yet the only thing left is to choose the proper time to enable the processor global interrupt. This will be one of the topics for my next post.
Don’t go away!! i will be back in no time 😀