Episode 3 – 136.000 Processes on a ‘Pi!

In Episode 2, we hinted that this video would contain some distributed Erlang fun but since we are still (eagerly) waiting for the postman to deliver the rest of our Raspberry Pi boards, we thought it would be cool to spend more time playing with concurrency.

Ed, one of the Erlang hackers in our London office (also our resident Thai food expert), joins us in this video to talk about the process ring demo he’s coded:

“More blinkenlights?!”

It’s true that blinking an LED is not the most computationally challenging task but it certainly is a nice way of demonstrating program activity. In this demo, LEDs are used to visualise tokens being passed around a ring of processes. Each LED will toggle it’s state once a token gets passed around 100 times around the ring. For example, the red LED will toggle state once the token gets passed around 100 times over 1000 processes and it will blink after two revolutions (since a blink is essentially two ‘toggles’).

We managed to spawn up to 136.000 processes without any tricks, other than increasing the maximum number of concurrent processes allowed by the runtime using the +P parameter, which by default is set to 32768, after which we started running out of memory — an impressive figure considering that this is on a credit-card sized computer that costs $35!

As always, you can grab a copy of the code at our GitHub repository.

We will be busy getting ready for the Erlang User Conference 2012 that’s happening at the end of the month so the next video might be a bit late but we promise it will be worth it 😉

Episode 2 – Concurrent Blinkenlights!

We published a new episode of our Erlang Embedded video series a couple of days ago. Here it is, in its full glory:

(bonus behind-the-scenes tweet)

So what is the significance of a few flashing lights?

Instead of directly bashing bits and twiddling registers in a ‘main’ loop, we are representing each LED connected to the Raspberry Pi as an Erlang process. This means that we can send messages to it and provide a nice, high-level abstraction. We feel that representing peripherals within the system to act as a process (or a set of processes) and using those processes as compositional units is an interesting way to go about developing embedded applications. We will be exploring it in greater detail on our future videos, stay tuned!

(Grab a copy of the code used in this video here and let us know if you end up doing something cool with it or have an idea for our next videos.)