Closed
Description
In order to avoid CPU hogging by the main thread (loop()
of *.ino
file) it is necessary to add rtos::ThisThread::yield();
to ArduinoCore-mbed as shown below:
for (;;) {
loop();
if (arduino::serialEventRun) arduino::serialEventRun();
+ rtos::ThisThread::yield();
}
For all *.inot
defined threads this is automatically done by this code executed after calling the thread's loop()
function.
Since this is currently not the case rtos::ThisThread::yield();
is currently called within the main thread of each example (i.e. here) and I think we should rather avoid exposing the raw mbed API to the wider public.
Any side effects you can think of @facchinm?