18
Contiki A Tiny OS for the Internet of Things

Contiki Presentation

Embed Size (px)

Citation preview

ContikiA Tiny OS for the Internet of Things

Getting Started

I got 99 problems

● Resource Constraints○ Small memory (~100kb code, <20kb RAM)○ CPU (8-bit microcontroller)○ Low-power/battery life

● Large number of small parts○ Hard to physically reclaim and reprogram on update○ Network may have a variety of software versions

and hardware permutations.

But an OS ain’t one

● Dynamic loading and replacement of code● Event Driven Kernel

○ allows for low power○ preemptive multithreading implemented as external

optionally linkable library● Support for power-save modes*

* user-implemented (mileage may vary)

Let’s get down tobusiness

System Architecture

● Core [Static Binary]○ Contiki kernel○ Program loader○ Language runtime core○ Communication stack for device drivers

● Loaded Components [Dynamic]○ Services (loadable libraries)○ Application Processes

System Architecture

Processes in Contiki

● Can be either Services or Applications● Consist of:

○ Event handler function○ Optional poll handler function

● Can be replaced at runtime● All communication goes through the kernel

○ Posting Events● Can communicate directly with hardware

Services

“Dynamically linked shared library”

Kernel Architecture

● Event Driven○ Kernel will never preempt running handler○ Support for synchronous and asynchronous events○ Only one event handler may run at any given time.

● Single Shared Stack○ Prevents overallocation (fragmentation) problems

Cool stuff ^_^

Preemptive Multi-Threading

● Generic component○ interface to the event kernel

● Platform-specific component○ handles stack switching○ preemption primitives*

● Each thread has different stack○ stacks are user-managed by library service

* could allow for application-specific preemption protocols

Preemptive Multi-Threading

Over-the-air Programming

● Propagate dynamic updates through a network of devices running Contiki

● Reduce Cost:○ labor/time savings

● Network can adapt to environmental changes in-place without physical intervention

Memory Usage Profiling

p = max # processes

e = max size of event queue

s = size of thread stack

Conclusions

Pros:● Over-the-air programming● Dynamically linked services

○ no need to recompile on update

Cons:● Event-based architecture

○ can be hard to program for● Access control + security vulnerabilities

○ need to verify access to reprogramming facilities.

Thanks!

ReferencesDunkels, Adam, Bjorn Gronvall, and Thiemo Voigt. "Contiki-a lightweight and flexible operating system for tiny networked sensors." Local Computer Networks, 2004. 29th Annual IEEE International Conference on. IEEE, 2004. [LINK]