Computing stuff tied to the physical world

Fascinating concurrency

In AVR, Software on Feb 4, 2010 at 00:01

There is a new language for the Arduino / JeeNode / ATmega328, called Occam-π.

I found out about it yesterday, at http://concurrency.cc/ – it’s high level, and it supports parallel programming. The current development environment release is for Mac OS X, with Windows and Linux coming soon.

Here is a complete program with 4 blinking LED’s, one on each DIO pin of the JeeNode ports:

Screen shot 2010-02-03 at 01.13.19.png

That’s it. Compiles to roughly 2 Kb. Each extra blink adds just 20 bytes, btw.

And yes, it really makes four LEDs blink at an independent rate:

DSC_1167.jpg

There is slightly more to it than that, but this is mind-blowing stuff. The “parallelism” is simulated, of course. Looks like the ATmega can do around 6000 context switches per second (i.e. parallel task switches).

There is a roughly 20 Kb interpreter part that needs to be uploaded once (which is why this requires at least an ATmega328). After that, the IDE will upload just the bytecode for your program, i.e. 2 Kb in the above case.

B R I L L I A N T .

Imagine hooking up the RF12 driver to this – there’s plenty of room for the extra 3 Kb or so. And for doing all sorts of things… in parallel! My earlier complaint post about how awful it is to do several things at once on an ATmega board might just have been wiped off the table.

Looks like I’ve got some very serious learning ahead of me to try and get to grips with all this.

  1. humm… nice, this new language. But if I need multi-tasking on my AVR I’ll stick to something like Femto OS. It already does it, it has been around for a while (reliable) and it is small.
    http://www.femtoos.org/
    Unless someone gives me a good reason to change ;-)

    • No good reasons to change. The occam compiler prevents race hazards, and our runtime detects deadlock.

      But I’m not interested in sales; our premise is that it’s better to write concurrent code in a language that lets you express it directly, instead of having to translate fundamentally parallel notions into sequential code yourself. That, and we’re interested in teaching how to directly express parallel ideas in code, not how to *implement* these things in a sequential language. Hence, our tools have a specific purpose.

  2. Very interesting, thanks for the heads up! Will check out Femto as well — any other multi-tasking tools ofr AVR?

  3. In the WinAVR web site you can find some info on the possible OS’s.
    http://winavr.sourceforge.net/WinAVR-user-manual.html
    Look for the point 5.1 Operating Systems.
    Look out for the Elektor of February 2010 (at least the French edition) in page 14 you have a nice article on Femto OS.

Comments are closed.