-->
Page 1 of 2

Does ESP8266 with Arduino IDE support multi-threading?

PostPosted: Tue Aug 03, 2021 11:03 pm
by CarmeloLabadie
Dears,
was wondering if ESP8266 with Arduino IDE supports multi-threading to run multiple tasks/functions simultaneously? If it does, please help to provide the working example code.

any advise is highly appreciated.

Re: Does ESP8266 with Arduino IDE support multi-threading?

PostPosted: Fri Aug 06, 2021 10:41 am
by QuickFix
In short: no.

The ESP core does some multi-tasking (one for the WiFi stack and one for the main program) on its own, but multi-threading is, for as far as I know, not possible, I don't even think multi-threading is even possible with Arduino in general or specifically single core controllers. :?

If you want something similar, you could always use interrupts or write some proto-thread like code, I guess.

Re: Does ESP8266 with Arduino IDE support multi-threading?

PostPosted: Tue Aug 10, 2021 11:05 pm
by williamhenrick
No microcontrollers can't perform multiple functions at the same time. For that, you have to use a microprocessor like the raspberry pi.

I have once worked on Myrio from LabView that allows multiple functions, as its programmed using LabVIEW software.

Re: Does ESP8266 with Arduino IDE support multi-threading?

PostPosted: Wed Aug 11, 2021 4:28 am
by btidey
I don't understand that distinction being made between microcontrollers and microprocessors with respect to multithreading.

Multithreading is a software programming model where a process can create multiple threads of execution that operate independently. It can be applied to any general computing device limited only by the resources available to that device and that includes microcontrollers.

Performing operations truly simultaneously is a different thing and will require architectures that have multiple hardware resources like processing cores that can operate in parallel.

There are different forma of multithreading with one of the characteristics being how threads are scheduled for execution; cooperative or preemptive.

A simple example of cooperative multithreading in an arduino environment is
https://github.com/bmellstrom/esp8266-arduino-threads