-->
Page 1 of 1

Is yield() still necessary if Arduino uses RTOS SDK?

PostPosted: Wed Aug 17, 2016 8:10 am
by helpme
Am I right to say if Arduino switches to RTOS SDK, there is no longer the need to use yield()? If Arduino uses RTOS SDK, will the risk of ESP8266 resetting due to certain processes running for too long be negligible?

Re: Is yield() still necessary if Arduino uses RTOS SDK?

PostPosted: Wed Aug 17, 2016 8:35 am
by martinayotte
There is not much chance we will see an Arduino ported under current RTOS SDK.
Maybe when final RTOS for ESP32 will be there, ESP8266 RTOS will be revamp, and then Arduino RTOS could becomes reality.

Re: Is yield() still necessary if Arduino uses RTOS SDK?

PostPosted: Mon Aug 22, 2016 11:22 am
by mrburnette
helpme wrote:Am I right to say if Arduino switches to RTOS SDK, there is no longer the need to use yield()? If Arduino uses RTOS SDK, will the risk of ESP8266 resetting due to certain processes running for too long be negligible?



Were there a "real" RTOS implementation, the context switching would be beneath your sketch level, so you would not know that you were in a virtual thread.

But that is not today. Today, every repetition of loop() calls into the low-level RF section and "pets" the WDT.

As I just mentioned to another user complaining about yield(); IMO there is simply no excuse for a programmer to not know where her/his code is consuming uC cycles. Profiling with millis() the entry-exit of complex or 'loopy' code will give you the information you require about using delay(0) or yield(). I shoot for 30mS maximum but I have read that the worst-case can go up to about 50mS - but there is no reason to get that close to a reset IMO.

Or course, you could do like I do and simply write the sketch and test for a few hours (or days) to see if the WDT becomes annoyed with the sketch! Then place yields() where they are needed. Proactive is a better approach, however.

Ray