contiki a lightweight and flexible operating system for tiny networked sensors presented by: jeremy...
Post on 19-Dec-2015
218 views
TRANSCRIPT
![Page 1: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/1.jpg)
ContikiContiki
A Lightweight and Flexible A Lightweight and Flexible Operating System for Tiny Operating System for Tiny
Networked SensorsNetworked Sensors
Presented by: Jeremy SchiffPresented by: Jeremy Schiff
![Page 2: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/2.jpg)
ObjectivesObjectives
LightweightLightweight
Event Driven ModelEvent Driven Model Has Multi-Threading Support as LibraryHas Multi-Threading Support as Library
Dynamic Loading and Replacement Dynamic Loading and Replacement of Individual Servicesof Individual Services
![Page 3: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/3.jpg)
Contiki MotivationsContiki Motivations
No memory protection between appsNo memory protection between apps
Kernel very minimalKernel very minimal CPU multiplexingCPU multiplexing Loading ProgramsLoading Programs
All other abstractions by librariesAll other abstractions by libraries Custom ApplicationsCustom Applications
![Page 4: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/4.jpg)
DifferentiationDifferentiation
TinyOSTinyOS Statically linked entire applicationsStatically linked entire applications
MagnetOSMagnetOS Virtual Machine – byte codeVirtual Machine – byte code
MantisMantis Pure MultiThreadPure MultiThread
ContikiContiki Dynamic Linking of binariesDynamic Linking of binaries Event/Thread HybridEvent/Thread Hybrid
![Page 5: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/5.jpg)
Why Loadable Why Loadable ApplicationsApplications
Smaller file to uploadSmaller file to upload
Less EnergyLess Energy
Less Dissemination Time Less Dissemination Time
![Page 6: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/6.jpg)
Why No Threads?Why No Threads?
Thread stacks must be allocated at creation Thread stacks must be allocated at creation timetime
Stack Memory Over-ProvisionedStack Memory Over-Provisioned No Virtual Memory SystemNo Virtual Memory System No Memory Protection Mechanisms No Memory Protection Mechanisms
Locking for state exclusionLocking for state exclusion Stack memory is inaccessible to other Stack memory is inaccessible to other
threadsthreads
![Page 7: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/7.jpg)
EventsEvents
No lockingNo locking Only one running at a timeOnly one running at a time
Only one stackOnly one stack Locking rareLocking rare
Hard to express some things as state Hard to express some things as state machinemachine
Problem: Cryptography takes 2 seconds, Problem: Cryptography takes 2 seconds, everything else blocked.everything else blocked.
Solution: Preemptive ThreadsSolution: Preemptive Threads
![Page 8: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/8.jpg)
System OverviewSystem Overview
Service – Something that implements Service – Something that implements functionality for more than one functionality for more than one applicationapplication
Apps have direct access to hardwareApps have direct access to hardware Single Address SpaceSingle Address Space Inter-process communication via event Inter-process communication via event
postingposting Always Through KernelAlways Through Kernel
![Page 9: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/9.jpg)
Core vs. Loaded ProgramCore vs. Loaded Program
Partitioned at compile Partitioned at compile timetime
CoreCore Single Binary Single Binary Ideally never modifiedIdeally never modified
ProgramProgram Easily upgradedEasily upgraded
![Page 10: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/10.jpg)
KernelKernel
Execution via: Kernel Events or Execution via: Kernel Events or Polling EventsPolling Events
No preemption of scheduled events No preemption of scheduled events Synchronous vs Asynchronous EventsSynchronous vs Asynchronous Events
Synch: Like Function CallSynch: Like Function Call Asynch: Like posting new eventAsynch: Like posting new event
Asynch reduces stack spaceAsynch reduces stack space Debugging issuesDebugging issues
![Page 11: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/11.jpg)
Two Level SchedulingTwo Level Scheduling
Events Events Can’t preempt one anotherCan’t preempt one another
Interrupts Interrupts Can preempt eventsCan preempt events Can use “underyling real-time executive” Can use “underyling real-time executive”
Provides realtime guaranteesProvides realtime guarantees Non-hardwareNon-hardware
Can’t post eventsCan’t post events Use polling flag insteadUse polling flag instead Prevent race conditionsPrevent race conditions
![Page 12: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/12.jpg)
Loading ProgramsLoading Programs
Relocation Information in BinaryRelocation Information in Binary
Check for space before loadingCheck for space before loading
Call Initialization FunctionCall Initialization Function Replace or Starts new ProgramReplace or Starts new Program
![Page 13: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/13.jpg)
Power Save ModePower Save Mode
No explicit Kernel assistanceNo explicit Kernel assistance
Access to event queue size Access to event queue size
![Page 14: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/14.jpg)
ServicesServices
ApplicationApplication
Service LayerService Layer
Service InterfaceService Interface
Service ProcessService Process
![Page 15: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/15.jpg)
ApplicationApplication
Must dynamically linkMust dynamically link
Interact via Service StubInteract via Service Stub
Compiled inCompiled in Version numberVersion number Caches Service ProcessIDCaches Service ProcessID
![Page 16: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/16.jpg)
Service LayerService Layer
Works with KernelWorks with Kernel Provides lookup for specific serviceProvides lookup for specific service Returns a Service InterfaceReturns a Service Interface
Has pointers to all functions service providesHas pointers to all functions service provides Contains a version NumberContains a version Number Interface description implemented by Service Interface description implemented by Service
ProcessProcess
Version numbers must matchVersion numbers must match Failure Support? MANTIS thinks about this better.Failure Support? MANTIS thinks about this better.
![Page 17: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/17.jpg)
Service ExampleService Example
![Page 18: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/18.jpg)
Service ReplacementService Replacement
Process ID must be preservedProcess ID must be preserved Kernel supportedKernel supported Kernel instructs service to remove itselfKernel instructs service to remove itself
Could lead to problemsCould lead to problems Kernel provides mechanism to transfer state Kernel provides mechanism to transfer state Service state also versionedService state also versioned Service state must be stored in a shared Service state must be stored in a shared
space during swap due to reallocations of old space during swap due to reallocations of old version’s spaceversion’s space Is there a better way to do this - SOS?Is there a better way to do this - SOS?
![Page 19: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/19.jpg)
LibrariesLibraries
Application optionsApplication options Static link with coreStatic link with core Static link with librariesStatic link with libraries
Single binarySingle binary Call a serviceCall a service
Memcpy() vs Atoi()Memcpy() vs Atoi() MemCpy in CoreMemCpy in Core
![Page 20: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/20.jpg)
CommunicationCommunication Architecture makes easy to replace Architecture makes easy to replace
Communication Stack Communication Stack A service like any otherA service like any other Enables multiple communication stack for Enables multiple communication stack for
comparisoncomparison
Comm Services use Service Mechanism to Comm Services use Service Mechanism to call one anothercall one another
Comm Services use Synchronous events to Comm Services use Synchronous events to communicates with applicationscommunicates with applications No copying of buffers because Synch events No copying of buffers because Synch events
can’t be preemptedcan’t be preempted
![Page 21: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/21.jpg)
Communication StackCommunication Stack
![Page 22: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/22.jpg)
Multi-ThreadingMulti-Threading
Optional Library linked inOptional Library linked in
Kernel interactionKernel interaction Platform IndependentPlatform Independent
Stack Switching / Preemption Stack Switching / Preemption primitivesprimitives Platform DependentPlatform Dependent
![Page 23: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/23.jpg)
Multi-Thread APIMulti-Thread API
![Page 24: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/24.jpg)
Over the air Over the air ProgrammingProgramming
1 node took 30 seconds1 node took 30 seconds
40 nodes took 30 minutes40 nodes took 30 minutes
1 component for 40 nodes took 2 1 component for 40 nodes took 2 minutesminutes
Used naïve protocolUsed naïve protocol
![Page 25: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/25.jpg)
Code SizeCode Size
Bigger than TinyOS, Smaller than Bigger than TinyOS, Smaller than MantisMantis
Polling Handlers and Increase Polling Handlers and Increase FlexibilityFlexibility
Less compiler optimization possibleLess compiler optimization possible
![Page 26: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/26.jpg)
Preemption DemoPreemption Demo
Start 8 second Start 8 second process at 5 process at 5 Seconds and Seconds and continually pingcontinually ping
~.1 ms latency ~.1 ms latency increaseincrease
Poll handler Poll handler caused spikescaused spikes Mainly Radio Mainly Radio
Packet driverPacket driver
![Page 27: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/27.jpg)
PortabilityPortability
Custom Code in a portCustom Code in a port Boot up codeBoot up code Device DriversDevice Drivers Architecture specific parts of program Architecture specific parts of program
loaderloader Stack switching code of the multithreading Stack switching code of the multithreading
librarylibrary
Kernel and Service layer need no Kernel and Service layer need no changeschanges
![Page 28: Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff](https://reader034.vdocuments.mx/reader034/viewer/2022051315/56649d3e5503460f94a16a66/html5/thumbnails/28.jpg)
Questions?Questions?