Adam Dunkels on Embedded Sensor Networks
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 have come true"
A cluster of contiki boats? Wouldn't that be called a navy?
Online Starcraft RPG? At
Dietary fiber is like asynchronous IO-- Non-blocking!
Interview with Adam Dunkels
:)
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
SysWear - Geek T-shirts (UK/Europe)
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?
Mirror to Adam Dunkel's homepage.
I'm very interested in the Protothreads library sourcecode mentioned in the article - the whole 20 lines of it! Yet, the site is slashdotted and Google doesn't seem able to find it...
Does anyone know where i could check it out?
The article give a link to an article describing a trick to implement coroutines in C, I found it quite enjoyable to read:m /corout ines.html
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!
Imagine a beowulf^H^H^H^H^H^H^Hcontiki cluster of those things!
Oh... wait...
This statement is forty-five characters long.
I would like to see a local weather collaboration system.
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.
The article and references are, of course, Slashdotted. Are sensor networks subject to hallucinations? That is, are they secure enough to prevent false input (intentional or otherwise)?
Can You Say Linux? I Knew That You Could.
That piece of software is great, it uses a lot of interesting tricks to work in such small memory footprint. Adam itself helped me to implement it on mi own pet OS Picix , for te PIC18 microcontrollers, and works very well. It almost fills a 10Base-T card, and the processor is only 8 bit and 40 mhz!
Anything with an input can be fed junk.
I actually met Adam while he was in high-school. One of my childhood friends was in the same high-school class as he was.
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 of the cool demos that he had coded. Unfortunately he couldn't find the disk containing the demo, so he sat down and started writing the demo-code in hex from what he remembered of it! After about 20 minutes of typing he had finieshed it, and showed us a working demo-effect of a cube on fire. Really cool!
This was probably back in early '96 or so.
I enjoy large posteriors and I cannot prevaricate.