-->
Page 1 of 1

ESP8266-12F multi-threading / scheduler, with Arduino IDE

PostPosted: Wed Apr 06, 2016 11:46 am
by Geoffrey
Hello~

Could anyone advise if ESP8266-12F or ESP8266 supports multi-threading / scheduler, with Arduino IDE, to run multiple tasks simultaneously

Any working example code to demonstrate how to use the library and APIs would be highly appreciated

Best Regards,
Geoffrey

Re: ESP8266-12F multi-threading / scheduler, with Arduino ID

PostPosted: Fri Apr 08, 2016 9:19 am
by mrburnette
with Arduino IDE, to run multiple tasks simultaneously - See more at: viewtopic.php?f=32&t=9386#sthash.TiMhzzQh.dpuf


Unlike PC/server products as Jave applications, the ArduinoIDE and libraries are not written to support multitasking. The best we can pull-off is FreeRTOS which allows the illusion of multitasking, but is really just a task scheduler... there is only 1 computing core in the uC, so concepts applied in the enterprise environment are not map-able into the uC world at this level of device. There is already a scheduler in the Arduino implementation that splits the time between the Arduino C++ code and the ESP8266 RF functions.

Ray

Re: ESP8266-12F multi-threading / scheduler, with Arduino ID

PostPosted: Tue May 10, 2016 9:22 pm
by malachi
Actually, it is very possible - in theory. Any CPU with some stack space to spare can engage in "cooperative multitasking". It's a big topic, but long story short you as the programmer have to do a bit of extra work (not much) to notify the CPU when it's OK to multitask. Here's a place to start: https://en.wikipedia.org/wiki/Computer_multitasking

Arduino (AVR, SAM) has a nice library to do just this: https://github.com/mikaelpatel/Arduino-Scheduler. Unfortunately, due to the lack of setjmp/longjmp implementation in ESP8266, libs such as this are not compatible. setjmp/longjmp can work on an ESP8266 - just nobody's implemented it yet. See: https://github.com/esp8266/Arduino/issues/910