MANTIS OS CS294- 11 SensorNet CS294- 11 SensorNet Fall 2005 Fall - - PowerPoint PPT Presentation

mantis os
SMART_READER_LITE
LIVE PREVIEW

MANTIS OS CS294- 11 SensorNet CS294- 11 SensorNet Fall 2005 Fall - - PowerPoint PPT Presentation

MANTIS OS CS294- 11 SensorNet CS294- 11 SensorNet Fall 2005 Fall 2005 Murali Rangan Murali Rangan (Liberally drawn from slides by R. Han, et al) (Liberally drawn from slides by R. Han, et al) MOS (MANTIS OS) Goals Goals General- purpose


slide-1
SLIDE 1

MANTIS OS

CS294- 11 SensorNet CS294- 11 SensorNet Fall 2005 Fall 2005 Murali Rangan Murali Rangan

(Liberally drawn from slides by R. Han, et al) (Liberally drawn from slides by R. Han, et al)

slide-2
SLIDE 2

MOS (MANTIS OS)

Goals Goals

General- purpose sw/ hw platform for General- purpose sw/ hw platform for sensornets sensornets Simplify sensornets for novices Simplify sensornets for novices Flexible for advanced research Flexible for advanced research Adapt to resource constraints Adapt to resource constraints

Why multimodal? Why multimodal?

Supports variety of apps, hw platforms, Supports variety of apps, hw platforms, deployment scenarios deployment scenarios

slide-3
SLIDE 3

Overview

Lightweight POSIX- like multithreading Lightweight POSIX- like multithreading Simple, vanilla ANSI C API Simple, vanilla ANSI C API Preemptive time- sliced scheduling Preemptive time- sliced scheduling I/ O sync via mutual exclusion I/ O sync via mutual exclusion Layered network stack, device drivers Layered network stack, device drivers Dynamic reprogramming Dynamic reprogramming Flexible power management Flexible power management

Modest learning curve Build com plex apps Cross platform portability

slide-4
SLIDE 4

Classic MT OS in 500 bytes

Hardware MANTIS System API Kernel/ Scheduler

Network Stack

MANTIS OS Device Drivers T3

Com m and Server

T4 T5 User- level threads

slide-5
SLIDE 5

Lightweight MOS kernel

Preemptive multi- threading Preemptive multi- threading

Priority/ round- robin scheduling Priority/ round- robin scheduling Fast context switching (~60microsecs) Fast context switching (~60microsecs)

144 byte footprint for scheduler 144 byte footprint for scheduler

Static thread table (default 12 threads) Static thread table (default 12 threads) 10 bytes per thread entry 10 bytes per thread entry

Dynamic thread stack allocated on heap Dynamic thread stack allocated on heap Thread context saved on thread stack Thread context saved on thread stack Counting and binary semaphores Counting and binary semaphores

slide-6
SLIDE 6

User Level network stack

Non- strict layered design Non- strict layered design

Network, transport, app layers in user level Network, transport, app layers in user level MAC protocol in “comm” layer MAC protocol in “comm” layer

Implement in one or more threads Implement in one or more threads

Performance Vs Flexibility trade off Performance Vs Flexibility trade off Easy to implement/ experiment Easy to implement/ experiment Can implement different routing protocols Can implement different routing protocols Cross- platform prototyping Cross- platform prototyping

slide-7
SLIDE 7

MOS Comm/ Device Layers

  • Com m Layer
  • Interface to com m devices
  • Manage shared pool of buffers
  • Device Layer
  • Interface to all devices
slide-8
SLIDE 8

Comm layer

Blocking com_send/ com_recv calls Blocking com_send/ com_recv calls

Interrupt- driven packet reception Interrupt- driven packet reception Fills comBuf from a pool of comBufs Fills comBuf from a pool of comBufs com_recv gets pointer to a full comBuf pkt com_recv gets pointer to a full comBuf pkt Zero- copy on both send and receive Zero- copy on both send and receive Downside- App receiving pkt must free comBuf Downside- App receiving pkt must free comBuf com_mode for power management (on/ off/ idle) com_mode for power management (on/ off/ idle) com_ioctl for comm specific functions com_ioctl for comm specific functions MAC protocol implemented in radio device driver MAC protocol implemented in radio device driver

slide-9
SLIDE 9

Device drivers

Each driver implements four functions Each driver implements four functions dev_read, dev_write, dev_mode, dev_ioctl dev_read, dev_write, dev_mode, dev_ioctl read/ write calls are blocking, synchronous read/ write calls are blocking, synchronous Each driver keeps a mutex for I/ O sync Each driver keeps a mutex for I/ O sync Single static call table of driver function pointers Single static call table of driver function pointers Devices addressed using index in this table Devices addressed using index in this table dev_register() - to initialize call table, mutex dev_register() - to initialize call table, mutex dev_mode for power management (on/ off/ idle) dev_mode for power management (on/ off/ idle) dev_ioctl for device specific calls dev_ioctl for device specific calls

slide-10
SLIDE 10

Power Management

Traditional idle/ active modes Traditional idle/ active modes

No CPU throttling, voltage variation No CPU throttling, voltage variation

Apps have varying duty cycles Apps have varying duty cycles

Let the app tell when it wants to sleep Let the app tell when it wants to sleep

mos_enable_power_mgt() mos_enable_power_mgt()

Power save mode turned off by default Power save mode turned off by default to be compatible with UNIX sleep! to be compatible with UNIX sleep!

mos_thread_sleep(PERIOD) mos_thread_sleep(PERIOD) Timer wakes processor on earliest Timer wakes processor on earliest deadline expiry deadline expiry

slide-11
SLIDE 11

Energe aware scheduler

slide-12
SLIDE 12

Code example - send_forward.c

#include < inttypes.h > #include "led.h" #include "dev.h" #include "com.h" #include "msched.h" #include "clock.h" static comBuf send_pkt; //comBuf goes in heap void send_thread(); void start(void) { mos_thread_new(send_thread, 128, PRIORITY_NORMAL); } void send_thread() { send_pkt.size=2; //2 bytes while(1) { mos_led_toggle(0); (uint16_t)send_pkt.data[0] = dev_get(DEV_MICA2_TEMP); com_send(IFACE_RADIO, &send_pkt); mos_thread_sleep(1000); } }

slide-13
SLIDE 13

Code example - receive.c

#include "led.h" #include "com.h" //give us the communication layer #include "msched.h" void receiver(); void start(void) { comBuf *recv_pkt; //give us a packet pointer com_mode(IFACE_RADIO, IF_LISTEN); while(1) { recv_pkt = com_recv(IFACE_RADIO); //blocking recv a packet com_send (IFACE_SERIAL, recv_pkt); //send packet out over serial com_free_buf(recv_pkt); //free the recv'd packet to the pool mos_led_toggle(0); } }

slide-14
SLIDE 14

Cross platform

Sensor Hardware MANTIS System API Kernel/ Scheduler

Network Stack

Device Drivers T3

Com m and Server

T4 T5

Sensor Node

X86 Hardware MANTIS System API T3 T4 T5 UNIX POSIX Shim Layer

Network Stack Com m and Server

X86 PC

“AMOS” “XMOS”

slide-15
SLIDE 15

Application Integration

Application, e.g. Application, e.g.

Visualization app Visualization app Bridging Gateway Bridging Gateway

X86 Hardware MANTIS System API T3 T4 T5 UNIX POSIX Shim Layer

Network Stack Com m and Server

X Windows GUI Socket API Database API

slide-16
SLIDE 16

Virtual XMOS Nodes

Bridging XMOS Gateway Visualiz ation Application Virtual Sensor Network Of XMOS Nodes USB/ Serial

slide-17
SLIDE 17

Dynamic Reprogramming

Reprogram entire deployed node Reprogram entire deployed node

MOS boot loader can re- flash entire OS MOS boot loader can re- flash entire OS Load stored code image from EEPROM Load stored code image from EEPROM

Source- independent reprogramming Source- independent reprogramming

Standard API to store code image to Standard API to store code image to EEPROM EEPROM Reprogramming possible over arbitrary Reprogramming possible over arbitrary connection (multi- hop), or from connection (multi- hop), or from application application Simple, flexible network management Simple, flexible network management

slide-18
SLIDE 18

Remote Shell/ Command Server

Remote “login” Remote “login” to nodes to nodes Debugging Debugging functions functions

Peek/ poke Peek/ poke Kernel status Kernel status info info

Configuration Configuration

Spawn threads Spawn threads Call functions Call functions Reprogram node Reprogram node

slide-19
SLIDE 19

Summary

Lightweight, preemptive multi- threaded, cross- Lightweight, preemptive multi- threaded, cross- platform OS platform OS

Easily integrates sensornets with other apps Easily integrates sensornets with other apps User friendly User friendly Familiar API and language Familiar API and language Powerful management tools Powerful management tools

slide-20
SLIDE 20

Discussion (1)

Classic Threads Vs Events argument Classic Threads Vs Events argument Threads Threads + Ease of application development, relatively better application debugging, good for complex computations

  • Stack management, concurrency issues, cost
  • f context switching

Events Events + Single stack – easy to manage, no concurrency issues, no context switching, good for simple computations

  • Hard to program, very hard to debug
slide-21
SLIDE 21

Discussion (2)

Context switching Context switching

How critical is this? How critical is this?

Paper says 60 microsecs, website says 200 microsecs

Complex tasks in sensornets? Complex tasks in sensornets?

How far are we? How far are we?

Paper mentions compression/ crypto algos