


Adam Dunkels on Embedded Sensor Networks 31
tl writes "netzstaub has
posted an
extensive interview with Adam
Dunkels, a computer scientist working in the field of wireless sensor networks and author of the open source lwIP and uIP embedded TCP/IP stacks,
the Contiki OS, and
the Protothreads library. The interview touches on protothreads, sensor networks, TCP/IP, Contiki, and embedded software
development. Many Slashdot readers probably remember the tiny Contiki OS from
previous
articles
where, not surprisingly, clustering
has
been
discussed.
From reading the interview, it seems Contiki clusters now have come
true."
Contiki clusters? (Score:5, Funny)
A cluster of contiki boats [thefeed.no]? Wouldn't that be called a navy?
Re:Contiki clusters? (Score:2)
this [kon-tiki.no] is a kon-tiki!
Article tesxt (Score:3, Informative)
I discovered Protothreads through a link in Chris Double's weblog on Saturday. This is a fascinating tiny library, written by Adam Dunkels, a researcher at the Swedish Insitute of Computer Science. The Protothreads library implements user-level in threads in portable ANSI C in a mere 20 lines of code, and each thread uses only 2 bytes of RAM! While having a few important limitations, this comes in handy for a lot of problems, especially when writing single-threaded network servers (using Protothreads, you don't have to use state machines to do protocol handling). While checking out Protothreads, I stumbled across the very interesting link list that Adam Dunkels compiled while writing his library. From there, I got hooked and browsed the rest of Adam's website.
He has written two incredible TCP/IP stacks aimed at embedded systems. The first one, uIP, is targeted at 8bit microcontrollers, and has a very low RAM usage (it runs with as few as 128 bytes RAM for full TCP/IP support). The development version of uIP uses Protothreads to offer a BSD-style socket interface while maintaining its low RAM usage. The second stack, lwIP, is targeted at bigger embedded systems, and offers a BSD-style API.
Adam is a computer scientist working in the field of sensor networks, which are a part of the research field of ubiquitous computing. Sensor networks consist of a myriad of little embedded systems gathering environmental data through a set of sensors. However, the real value of sensor networks stems from the communication between all these systems. As Adam put it, "the nodes are interchangeable: it is the data generated by the sensors that are the primary interest". Besides uIP, which he uses as a mean to communicate between the sensor nodes, Adam works on Contiki, an embedded operating system. Contiki allows the dynamic loading of code on sensor nodes, which proves to be very useful when deploying sensor networks.
I emailed Adam a few questions about his software, embedded programming and sensor networks. He was very kind to provide exhaustive and very interesting answers. Enjoy the interview
Protothreads
These first three questions are about Protothreads, the minimal threading library Adam has written for his embedded platforms. Protothreads are inspired by coroutines, which can be sort of implemented in C using a neat little trick.
Question: Adam, what was your motivation to write protothreads?
Answer: The driver behind the development of protothreads was many years of writing event-driven code. After a while, one sees the need to have a nicer abstraction than finite state machines. Ordinary threads have many of the good properties of such an abstraction, but they have two problems: the RAM overhead is prohibitive on systems with very small memory resources ---the typical target system for uIP---, and they require a fair amount of platform specific code. As I wanted to keep both uIP and Contiki as portable as possible, this was definitely a problem.
After thinking long and hard about this, as well as reading lot of papers on the subject of concurrency, the protothreads concept dawned on me. Very simple, yet powerful. Very little RAM overhead and possible to
implement in pure C. Perhaps the nicest thing is the extremely small size of the implementation. With all comments removed, the entire library can be reduced to 20 lines of code (that goes into a header file, no less!).
Question: What kind of software uses Protothreads currently?
Answer: Currently, the Contiki OS and the development version of the uIP TCP/IP stack are using protothreads. Among other things, they are used to implement a network API called "protosockets", which are similar to the BSD socket API but based on protothreads. This means that they can be used without underlying full multithreading, which subsequently means less RAM overhead.
Question: What kind of software do you think will use Protothreads in the future?
Answer: I
Re:Article tesxt (Score:1)
Strange enough as it is that someone would post t
Cool... (Score:4, Funny)
Damn! Isn't there anything in this world safe from TCP/IP packets? Back in the old days, people would respect them, and only allow full-featured computers & OS'es to exchange them. What's becoming of this world, I ask you?
Re:Cool... (Score:2)
It may be far off still (I've seen more appliances coming out with computers like that - a LG microwave recently), but eventually, we may have to visit some "toaster update" site every once in a while, update your AV and firewall for it...
And that's hoping it doesn't get beyond that, which wouldn't surprise me seeing the ridiculous convergence we see lately in phones and what
Slashdotted already (Score:2, Informative)
Protothreads source? (Score:2)
Does anyone know where i could check it out?
Re:Protothreads source? (Score:1, Informative)
Re:Protothreads source? (Score:3, Informative)
Re:Protothreads source? (Score:1)
Read the coroutine article (Score:4, Informative)
http://www.chiark.greenend.org.uk/~sgtatha
It is nice for a change to read about an "ugly trick" which is used to increase readability!
Re:Read the coroutine article (Score:2)
A very interesting read. The Dunkels interview is also very good, this guy seems to be doing some very interesting things.
Imagine... (Score:1, Funny)
Oh... wait...
Local weather webcam (Score:1, Insightful)
If we could have cheap weather stations and webcams staring at the sky, linked together with users multiple users per town then MythTV could not only say if today will have some rain, but could verify if I can bike to the train station without getting wet.
The sensor network of webcams could track and predict individual clouds and rainfall as a the wind pushes a raining cloud across the sensor network of multiple webcam equipped homes.
Re:Local weather webcam (Score:2)
Sensor Network Hallucinations? (Score:2)
Why not (Score:2)
Trivia! (Score:1)
We arranged what we called a "hack" (essentially a more fun LAN, long before the LAN-scene came to be) where we assembled a shitload of computers at someones house and did all kinds of goofy stuff (programming, graphics, music, pranks, etc) and had a blast for 2-3 days at a time.
This guy is probably a bona-fide genius. I remember him lugging his C64 there, and he decided to show us one