Pages: [1]   Go Down
Author Topic: "Hypethreading"  (Read 1215 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26485
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"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.

0
Offline Offline
Edison Member
*
Karma: 67
Posts: 1654
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: