Image Processing Reference
In-Depth Information
Application
Loaded
processes
Core
Communication
service
Program loader
Basic
libraries
Kernel
FIGURE .
System architecture of Contiki.
Common systems using a multithreads require a memory stack for each thread that finally
increases the total amount of memory. In addition, the required stack memory is often very large
because it is hard to predict how much memory space is needed during lifetime. In contrast, the pro-
posed event-driven model only needs to provide one stack while passing all enqueued events. hus,
all processes use the same stack. Furthermore, there is no need for mutual exclusion and locking of
shared resources. Each event will run to completion before another event starts.
As it is illustrated in Figure ., a working Contiki system consists of the kernel, the program
loader, some basic libraries and the communication stack which is built as service on top of the
kernel. Device drivers have to be implemented as services which can be used by applications or other
services. All processes, i.e., services and applications, can communicate with each other through the
kernel via message passing with the help of events. Also direct communication with the underlying
hardware is provided by the kernel.
A process in Contiki is either an application or a service that provides functionality to other pro-
cesses. Each process contains an event handler function to be called by the system if an event occurs.
In addition, an optional polling handler function can be defined to poll events.
Contiki provides asynchronous as well as synchronous events. Synchronous events cause the target
process to be scheduled immediately. Asynchronous events on the other hand are enqueued and
dispatched to the target process after releasing the current thread. In-between the thread switch,
asynchronous events are processed.
Ifahardwareinterruptoccurs,itdoesnotcauseanyeventtobepostedtopreventraceconditions
between the kernel and all threads. Instead, a polling flag is set by the kernel. his flag can be handled
by all implemented polling handlers. Figure . illustrates the described interprocess operations,
including service infrastructure.
12.3.8.2 Libraries
Contiki's kernel provides only the most essential features. To expand the functionality of Contiki,
three kinds of methods are available. First, libraries are statically linked to the core (Figure .).
Search WWH ::




Custom Search