Close

(TECHNICAL) The all-new multitasking watchdog!

A project log for Open Source Minimalist Phone

A modern, minimalist device that doesn't break the bank.

Johnny SteneJohnny Stene 01/09/2021 at 05:580 Comments

As part of the rewrite, I'm working on some improvements to the multitasking system in arcticOS. There are two main "threads" - the main thread runs the bulk of the code, and the second thread runs smaller sub-processes. The issue is that these sub-processes can't be interrupted - the only context switching is switching between the main and secondary threads. This means that you need to wait for all of them to finish running before the main thread can continue running. But what if a sub-process takes too long? That's where the new watchdog comes into play.

If a task takes too long, the new watchdog will wait for it to finish, and then save the position in the process list. Then, it will skip the remaining sub-processes and drop back into the main thread to let it continue executing. The next time the second thread runs, the watchdog will skip to the task after the one that was causing the block, so the rest of the sub-processes can finish running. This lets the main thread get more CPU time in the event of slow processes in the secondary thread, therefore increasing system speed.


Discussions