1 of 58

Internet of Things

Lecture 9 - IoT Operating Systems

2 of 58

IoT Demands

  • Low Power
  • Low Cost
  • Low memory footprint

  • IPv6, 6LoWPAN Adaptation Layer
  • Routing protocol
  • Packet loss - retransmission
  • Lightweight application layer protocols (CoAP, MQTT)

2

Lecture 9 - IoT Operating Systems

3 of 58

Low-end IoT Devices

  • Resource constrained devices
  • IETF classification (RFC 7228):
    • Class 0
      • <<10 KB of RAM and <<100 KB Flash
      • sensor node from WSN

3

Lecture 9 - IoT Operating Systems

4 of 58

Low-end IoT Devices

  • IETF classification:
    • Class 1
      • ∼10 KB of RAM and ∼100 KB Flash
      • rich applications
      • advanced features
      • routing and secure protocols
    • Class 2
      • more resources

4

Lecture 9 - IoT Operating Systems

5 of 58

Low-end IoT Devices

  • Class 0
    • Not suitable to run an OS
    • Bare metal and hardware-specific software
  • Class 1 and above
    • Router, host, server
    • Networking stack, reprogrammable applications

5

Lecture 9 - IoT Operating Systems

6 of 58

Low-end IoT Devices

  • Software primitives enabling hardware independent code production

  • APIs for large-scale software development, deployment, and maintenance

  • Software primitives provided by OSes

6

Lecture 9 - IoT Operating Systems

7 of 58

IoT OS Requirements

  • Small memory footprint
    • optimized libraries, efficient data structures
    • tradeoff between: performance, a convenient API, and a small OS memory footprint

  • Support for Heterogeneous Hardware
    • 8-bit, 16-bit, 32-bit architectures
    • different amounts of RAM & ROM

7

Lecture 9 - IoT Operating Systems

8 of 58

IoT OS Requirements

  • Network Connectivity
    • various communication technologies
      • IEEE 802.15.4, Wi-Fi, BLE, NFC, etc.
    • communication between devices and
    • end-to-end communication over the Internet
    • network stacks based on IP protocols

8

Lecture 9 - IoT Operating Systems

9 of 58

IoT OS Requirements

  • Energy Efficiency
    • make use of energy saving options
    • use hardware cryptographic operations
    • provide energy saving options to upper layers
    • duty cycling, minimize number of tasks executed periodically

9

Lecture 9 - IoT Operating Systems

10 of 58

IoT OS Requirements

  • Real-time capabilities
    • precise timing and timely execution
    • in critical scenarios: medical, vehicular, etc.
    • Real-time OS (RTOS)
    • guarantee worst-case execution times and interrupt latencies
    • kernel functions operate with a deterministic run time

10

Lecture 9 - IoT Operating Systems

11 of 58

IoT OS Requirements

  • Security
    • high security and privacy standards
    • cryptographic libraries and security protocols
    • security updates

11

Lecture 9 - IoT Operating Systems

12 of 58

OS Design for IoT - Architecture

  • General Architecture and Modularity
    • Kernel type: exokernel, microkernel, monolithic, hybrid
    • Exokernel
      • few abstractions between the application and the hardware
      • avoiding resource conflicts
      • checking access levels

12

Lecture 9 - IoT Operating Systems

13 of 58

OS Design for IoT - Architecture

  • General Architecture and Modularity
    • Microkernel
      • minimalistic set of features
      • device drivers run in user space
      • flexibility and robustness
      • an error in a driver does not affect the whole system

13

Lecture 9 - IoT Operating Systems

14 of 58

OS Design for IoT - Architecture

  • General Architecture and Modularity
    • Monolithic
      • all components are developed together
      • device drivers run in kernel space
      • an error in a driver may affect the whole system
      • OS size may be too big for some IoT devices
    • Hybrid
      • compromise between microkernel and monolithic

14

Lecture 9 - IoT Operating Systems

15 of 58

OS Design for IoT - Scheduling

  • Scheduling Model
    • Scheduler impacts:
      • energy consumption
      • real-time capabilities
      • programming model
    • 2 types of schedulers
      • preemptive
      • cooperative

15

Lecture 9 - IoT Operating Systems

16 of 58

OS Design for IoT - Scheduling

  • Scheduling Model
    • Multiple schedulers available
      • select at build time
    • Cooperative scheduler
      • each thread is responsible to yield control
      • another task or the kernel will not interrupt it

16

Lecture 9 - IoT Operating Systems

17 of 58

OS Design for IoT - Scheduling

  • Scheduling Model
    • Preemptive scheduler
      • can interrupt any task to allow another task to be executed
      • time slices
      • periodic timer tick
        • prevents the IoT device to enter the deepest power-save mode

17

Lecture 9 - IoT Operating Systems

18 of 58

OS Design for IoT - Memory

  • Limited amount of memory
  • Memory Allocation
    • Static allocation
      • over-provisioning
      • makes the system less flexible
      • simple system design

18

Lecture 9 - IoT Operating Systems

19 of 58

OS Design for IoT - Memory

  • Memory Allocation
    • Dynamic allocation
      • complicated design
      • malloc is time-wise nondeterministic => breaks real time guarantees
      • handle out-of-memory situations at runtime
      • memory fragmentation => run out of memory

19

Lecture 9 - IoT Operating Systems

20 of 58

OS Design for IoT - Network Stack

  • Network Buffer Management
    • chunks of memory shared between layers
    • 2 methods:
      • copy memory => consumes resources
      • pass pointers => memory allocation
        • central memory manager

20

Lecture 9 - IoT Operating Systems

21 of 58

OS Design for IoT - Programming Model

  • Programming Model
    • Event-driven systems
      • used in WSN
      • every task has to be triggered by an event
      • event loop, shared stack
      • more efficient use of memory

21

Lecture 9 - IoT Operating Systems

22 of 58

OS Design for IoT - Programming Model

  • Programming Model
    • Multithreaded systems
      • run each task in its own thread context
      • communicate using IPC
      • allow easy development of applications

22

Lecture 9 - IoT Operating Systems

23 of 58

OS Design for IoT - Drivers

  • Driver Model and Hardware Abstraction Layer
    • sensors, actuators, ADC, SPI, I2C, CAN bus, serial lines, GPIOs
    • driver interface
    • Hardware Abstraction layer
      • well-defined interface to CPU, memory, interrupt handling
      • easy porting
    • overhead

23

Lecture 9 - IoT Operating Systems

24 of 58

Most popular OSes

  • TinyOS
  • Contiki OS
  • RIOT OS
  • FreeRTOS
  • NuttX

24

Lecture 9 - IoT Operating Systems

25 of 58

TinyOS

  • From 2000
  • Developed for WSN (8-bit, 16-bit arch) - class 0 devices
  • Monolithic kernel
  • Cooperative scheduler
  • Event driven
  • Components virtually wired, as described by configurations
  • It provides algorithms, protocols, device drivers, file systems and a shell

25

Lecture 9 - IoT Operating Systems

26 of 58

TinyOS

  • Dialect of the C programming language called nesC
  • BLIP networking stack includes 6LoWPAN
  • Language primitives and programming abstractions to reduce bugs
  • Memory efficiency by reducing linked code to a minimum
  • Lack of a large developer community
  • BSD license

26

Lecture 9 - IoT Operating Systems

27 of 58

Contiki

  • Developed by Adam Dunkels in 2003
  • Supports a wide range of resource constrained devices
    • 8-bit AVR, 16- and 20-bit MSP430, 32-bit ARM Cortex M3
  • Monolithic architecture
    • core system + processes => a single image
    • all processes share the same memory space and privileges with the core system

27

Lecture 9 - IoT Operating Systems

28 of 58

Contiki

  • Cooperative scheduling
  • Memory allocation
    • static allocation
    • libraries for memory management (memb, mmem)
    • third-party modules for dynamic allocation
      • standard C malloc API

28

Lecture 9 - IoT Operating Systems

29 of 58

Contiki

  • uIP (micro IP) networking stack
    • 6LoWPAN, IPv4, IPv6, IPv6 neighbor discovery, IPv6 multicasting, RPL, TCP, UDP
    • Queuebuf allocates packet buffers from a static pool of memory
  • Protothreads - lightweight, cooperative

29

Lecture 9 - IoT Operating Systems

30 of 58

Contiki

  • C programming language
  • Hardware Abstraction Layer (HAL)
    • hardware-specific functionality is put in separate components
    • common API for using that hardware

30

Lecture 9 - IoT Operating Systems

31 of 58

Contiki

  • Cooja simulator
    • network simulation
    • cycle-accurate emulation
    • debugging features:
      • setting breakpoints
      • read/write to memory addresses
      • single-stepping through instructions

31

Lecture 9 - IoT Operating Systems

32 of 58

Contiki

  • Extra features:
    • shell
    • file system
    • database management system
    • runtime dynamic linking
    • cryptography libraries
    • fine-grained power tracing tool

32

Lecture 9 - IoT Operating Systems

33 of 58

Contiki

  • Real-world deployments
  • Commercial IoT products
  • Academic research
  • Large community of developers
  • GitHub repo

33

Lecture 9 - IoT Operating Systems

34 of 58

Contiki

34

Source: Ângelo André Oliveira Ribeiro, “Deploying RIOT Operating System on a Reconfigurable Internet of Things End-device”

35 of 58

RIOT

  • From 2013
  • Microkernel architecture
    • inherited from FireKernel
  • For real-time WSNs
  • 8-bit, 16-bit, 32-bit MCUs

35

Lecture 9 - IoT Operating Systems

36 of 58

RIOT

  • Full multithreading (~Linux)
    • memory overhead
    • efficient context switch - small number of CPU cycles
    • reduced TCB
    • efficient IPCs
    • memory-passing IPC between threads
    • multi-threading may be removed if necessary

36

Lecture 9 - IoT Operating Systems

37 of 58

RIOT

  • Tickless scheduler (for energy efficiency)
    • switch to idle thread
    • deepest sleep mode
    • external or kernel-generated interrupts wake up the system
  • Preemptive scheduler based on fixed priorities
    • Maximum priority thread can be interrupted only by IRQ

37

Lecture 9 - IoT Operating Systems

38 of 58

RIOT

  • Memory allocation
    • both static & dynamic
    • kernel uses only static allocation
    • enforcing constant periods for kernel tasks
    • dynamic allocation only in userspace

38

Lecture 9 - IoT Operating Systems

39 of 58

RIOT

  • Multiple network stacks
  • GNRC network stack with IP protocols
    • 6LoWPAN, IPv6, RPL, UDP, CoAP
    • centralized network buffer structure
    • pointers passed between layers
  • Extra features: shell, crypto libraries, data structures

39

Lecture 9 - IoT Operating Systems

40 of 58

RIOT

  • Kernel written in ANSI C language, assembly
  • Apps & libraries written in C or C++
  • Real-time guarantees
    • zero latency interrupt handlers
    • minimum context switching times
  • Hardware abstraction layer

40

Lecture 9 - IoT Operating Systems

41 of 58

RIOT

  • Standard debugging tools (GDB and Valgrind)
  • Run OS as process over Linux & Mac OS
  • Cooja simulator
  • POSIX standard interfaces
  • Open source community
  • LGPL license

41

Lecture 9 - IoT Operating Systems

42 of 58

RIOT

42

Source: Ângelo André Oliveira Ribeiro, “Deploying RIOT Operating System on a Reconfigurable Internet of Things End-device”

43 of 58

FreeRTOS

  • Developed by Richard Barry in 2002
  • GPL license
  • Real-time OS
  • Preemptive microkernel
  • Support for multithreading
  • Small, simple, portable, easy to use

43

Lecture 9 - IoT Operating Systems

44 of 58

FreeRTOS

  • 4 source code files
    • it is more a threading library than a full-fledged OS
  • Thread handling, mutexes, semaphores, software timers
  • Preemptive, priority based round-robin scheduler
    • periodic timer tick interrupt
    • tickless mode

44

Lecture 9 - IoT Operating Systems

45 of 58

FreeRTOS

  • Real-time guarantees
    • only deterministic operations in critical section and interrupt
  • Message queues as IPC
    • blocking and nonblocking insert functions
    • remove functions

45

Lecture 9 - IoT Operating Systems

46 of 58

FreeRTOS

  • 5 memory allocation schemes

1. allocate only

2. simple and fast allocate & free

3. malloc() and free() from C library

4. more complex allocate & free (memory coalescence)

5. even more complex - allows heap span over memory sections

46

Lecture 9 - IoT Operating Systems

47 of 58

FreeRTOS

  • Does not provide a networking stack
    • various libraries for IP networking
  • Does not define a portable driver model
    • Works with vendor BSPs
  • OS implemented in C language, C++ for apps

47

Lecture 9 - IoT Operating Systems

48 of 58

NuttX

  • Developed by Gregory Nutt in 2007
  • Apache Software Foundation
  • POSIX and ANSI compliance
  • MCUs & MPUs
    • from 8-bit to 64-bit architectures

48

Lecture 9 - IoT Operating Systems

49 of 58

NuttX

  • Built as microkernel or monolithic kernel
  • Highly modular
  • Real-time capabilities
  • Tickless scheduler

49

Lecture 9 - IoT Operating Systems

50 of 58

NuttX

  • Scheduler
    • fully preemptible
    • FIFO, RR, SPORADIC policies
    • realtime scheduling
    • tickless operation support
      • lower power consumption

50

Lecture 9 - IoT Operating Systems

51 of 58

NuttX

  • Virtual File System (VFS)
  • Loadable kernel modules
  • Symmetric Multi-Processing (SMP)
  • Pseudo-terminals (PTY)
  • I/O redirection
  • On-demand paging

51

Lecture 9 - IoT Operating Systems

52 of 58

NuttX

  • Inspiration from Linux/Unix:
    • VFS
    • MTD
    • PROCFS
    • NuttShell

52

Lecture 9 - IoT Operating Systems

53 of 58

NuttX

  • Very customizable
  • Small memory footprint
  • Network stack - IPv4, IPv6, UDP, 6LoWPAN
  • Apache License 2.0
  • Runs on many embedded devices

53

Lecture 9 - IoT Operating Systems

54 of 58

OS Comparison

54

Source: O. Hahm, E. Baccelli, H. Petersen and N. Tsiftes, "Operating Systems for Low-End Devices in the Internet of Things: A Survey," in IEEE Internet of Things Journal, vol. 3, no. 5, pp. 720-734, Oct. 2016.

Lecture 9 - IoT Operating Systems

55 of 58

OS Comparison

55

Source: O. Hahm, E. Baccelli, H. Petersen and N. Tsiftes, "Operating Systems for Low-End Devices in the Internet of Things: A Survey," in IEEE Internet of Things Journal, vol. 3, no. 5, pp. 720-734, Oct. 2016.

Lecture 9 - IoT Operating Systems

56 of 58

OS Comparison

56

Source: E. Baccelli, O. Hahm, M. Günes, M. Wählisch and T. C. Schmidt, "RIOT OS: Towards an OS for the Internet of Things," 2013 IEEE Conference on Computer Communications Workshops (INFOCOM WKSHPS), 2013, pp. 79-80.

Lecture 9 - IoT Operating Systems

57 of 58

Bibliography

  • O. Hahm, E. Baccelli, H. Petersen and N. Tsiftes, "Operating Systems for Low-End Devices in the Internet of Things: A Survey," in IEEE Internet of Things Journal, vol. 3, no. 5, pp. 720-734, Oct. 2016. (link)
  • Levis, P. et al. (2005). TinyOS: An Operating System for Sensor Networks. In: Weber, W., Rabaey, J.M., Aarts, E. (eds) Ambient Intelligence. Springer (link)
  • A. Dunkels, B. Gronvall and T. Voigt, "Contiki - a lightweight and flexible operating system for tiny networked sensors," 29th Annual IEEE International Conference on Local Computer Networks, 2004, pp. 455-462 (link)
  • E. Baccelli, O. Hahm, M. Günes, M. Wählisch and T. C. Schmidt, "RIOT OS: Towards an OS for the Internet of Things," 2013 IEEE Conference on Computer Communications Workshops (INFOCOM WOKSHOPS), 2013, pp. 79-80. (link)

57

Lecture 9 - IoT Operating Systems

58 of 58

Bibliography

58

Lecture 9 - IoT Operating Systems