Arduino Looks to Add True Multitasking as It Canvases the Technical Community for Input on an API

Arduino's upcoming multitasking feature is designed to abstract the complexities of threads and messaging away from the user.

Gareth Halfacree
2 years ago β€’ HW101

The Arduino platform looks set to gain another string in its bow, as its development team seeks feedback on adding a major new feature: fully-functional multitasking, accessible to the user without having to worry about threads or semaphores, allowing a sketch to execute multiple tasks at the same time without fear of blocking or power wastage.

"With the increased capabilities of Arduino and other microcontroller boards, including faster clocks or even multiple cores, the need to handle multiple tasks simultaneously arises more often than in the past," explains Arduino's Alessandro Ranellucci. "For instance, you often want to control motors, update a display and detect user interactions at the same time, or perform tasks that have different timing or wait for external events."

Typically, there are two approaches to doing so. The first is entirely manual, relying on the sketch author to write specifically non-blocking code in such a way that the main loop executes as quickly as possible β€” resulting in, Ranellucci admits, "bloated code" and an inability to handle microcontrollers with more than one core.

The second approach uses Arduino's Scheduler library, which allows for multiple looping functions rather than a single main loop. It results in cleaner code, but still requires that the author knows to avoid blocking code which would bring everything to a screeching halt β€” and wastes power by keeping loops busy when the device could otherwise be sleeping.

The solution: Adding true multitasking. "The goal is to define a standardized API [Application Programming Interface] that can be ported across all architectures and that, in line with the Arduino philosophy, will make complex things easy for anyone," Ranellucci explains. "Multitasking is a hard concept, so here we have plenty of margin to bring the Arduino approach to make this available to everyone."

The Arduino development team isn't attacking the problem alone, but asking technically-minded community members to weigh in and provide insight into how the feature should look and how it should be exposed to the user β€” and to kick the discussion off is a proposed API alongside a working implementation for experimentation.

Those interested in trying the feature out or contributing to its further development can find additional information in the GitHub discussion.

Gareth Halfacree
Freelance journalist, technical author, hacker, tinkerer, erstwhile sysadmin. For hire: freelance@halfacree.co.uk.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles