Continuing from the previous test, an in depth look is taken on the output on AEMB.

one thread crash

The GTKWave shows that the AEMB actually stop running anything at all on one thread . This is a huge error and means that the task not only stop running, but the FreeRTOS stops as well. A further investigation found that there are two interrupts that happen concurrently. During the first interrupt, another interrupt happen before the previous interrupt ended. The dark blue line is where the interrupt starts while the dotted line is where it ends.

interrupt nested

before interrupt interrupt thread after interrupt
028F 0 007C
00B0 1 028F
1338 0 00B0
028F 1 1338
00B0 0 028F
100C 1 00B0
028F 0 100C
00B0 1
007E 0
1 028F
028F 1
0 007E
007E 0
1 028F
028F 1
0 007E
1 028F
1278 0 028F
028F 1 1278
028F 0 028F

Thread 1 has first encounter an interrupt after thread 0 interrupt finished. Thread 0 starts to continue task 1 from previous interrupt while thread 1 runs the interrupt service routine. At one point, thread 0 runs the coding of portENABLE_INTERRUPTS() and soon after a few lines thread 0 encounter an interrupt. However, the interrupt of thread 1 is still ongoing. When thread 1 finishes the interrupt service routine, the next interrupt happen in thread 1 instead of thread 0 since the hardware interrupts are alternating. This messes the interrupts and the infinite loop (00B0) disappears completely at the beginning of this mess.

both run idle

Once the interrupts revert to normal, the idle task (028F) is run on both threads. The idle task was created twice, possibly due to the two interrupts clashing and wanting to restore the idle task at the beginning of the mess. Thus, the usage of portENABLE_INTERRUPTS() is not possible to solve the previous problem of the task breaking out of the loop.

To see if the problem persist with more task, the following program is tested.

Task 1 (Priority 1) Task 2 (Priority 1)

Following the behavior of the newer AEMB, the infinite loop will be consider as the third task with priority 1.

output

As seen from the output, the FreeRTOS starts to show unrecognizable symbols after one of the task switches. After going through the long output waveform, the results of that part are found as below.

interrupt start
interrupt resume
assembly

The line 0CC2 was suppose to branch to 076A before the interrupt but when it was resume after 3 interrupts later, it did not branch but continue the next line of code sequentially. The assembly shows that this part of coding is from function _vfiprintf_r which is called by the iprintf() function that display the messages on screen. Therefore, the display coding got messed up due to the failure of branching caused by an interrupt. This is similar to the previous problem of not returning or not looping.

Another program is also tested, this time only disabling interrupts in tasks but not resuming the interrupts.

output2

Both task run smoothly, but this also means that no interrupt will happen as they are run. This might be alright for only 2 continuous tasks but will not apply for more than 2 tasks.


0 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.