Go Down

Topic: "Hypethreading" (Read 1 time) previous topic - next topic

maui7003

Hey,

Is it's possible to have multiple C "subthreads"? If no, why not?
I know it is not a hardware feature ;-)

I would like to run a display, analog input and some serial data (temp&humidity sensor) every 0.2 s at the same time, without a big delay.

Ryugeist

Hey maui,

Protothreads could be what you are looking for.

http://dunkels.com/adam/pt/

Quote
"Protothreads provide sequential flow of control without complex state machines or full multi-threading." -- Adam Dunkles



AWOL

Quote
I would like to run a display, analog input and some serial data (temp&humidity sensor) every 0.2 s at the same time, without a big delay.

So, remove all the calls to "delay".
Only multicore processors can run things "at the same time", but you can do things fast enough that they appear to be at the same time.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

fat16lib

Multi-threaded Real-time Operating Systems (RTOS) are the common solution to this problem.  Many RTOSes are available and I have ported two free open source systems to Ardruino.

FreeRTOS http://www.freertos.org/ is very popular and ChibiOS http://www.chibios.org/dokuwiki/doku.php has some nice technical features.

You can download Arduino versions of these systems here http://code.google.com/p/beta-lib/downloads/list as FreeRTOSBeta20121215.zip and ChibiOSBeta20121212.zip.  Install them and run the examples.

Here is a nice paper on FreeRTOS http://stiff.univ-brest.fr/~boukhobza/images/stories/Documents/Teachings/OSM/expo/FreeRTOS_Melot.pdf.

Go Up