The official Arduino team this week announced the introduction of Arduino multitasking and is seeking help from the community by joining the GitHub discussion. “We are sharing our API proposal along with a fully working implementation,” explains that the Arduino team would like to know what you think about finalizing the new Arduino multitasking feature. The ultimate goal is to define a standardized API that can be ported to all architectures.
“With the advanced capabilities of Arduino and other microcontroller boards, including faster clocks or even multiple cores, the need to multitask at the same time is more common than in the past. For example, you often want to control motors, update a display, and monitor user actions at the same time, or perform tasks that take different times, or wait for external events.
The traditional way to do this is to write nonblocking code so that the loop() function can run as fast as possible, updating the state variables and calling the millis() function to ensure proper timing (see the Blink Without Delay example Learn more). However, this approach results in bloated code that is difficult to debug and maintain, and does not support multicore.
The scheduler library already allows you to write cleaner code by dividing a sketch into several looping functions so that each of them can focus on a specific task. However, this approach is called cooperative multitasking, which means you still need to avoid blocking commands yourself. Also, it doesn’t support multiple cores, and even if it did, it won’t protect you from accessing the same variables from multiple threads. Last but not least, it’s based on the traditional “busy loop” paradigm, which doesn’t really help for low power applications where you want threads to rest as long as possible waiting for an event or incoming data.”
Headings: Technology news, Main news