Presentation is loading. Please wait.

Presentation is loading. Please wait.

David Gay Intel Research Berkeley

Similar presentations


Presentation on theme: "David Gay Intel Research Berkeley"— Presentation transcript:

1 David Gay Intel Research Berkeley
nesC 1.2 David Gay Intel Research Berkeley nesC is a PL for a new area, n.e.s. nesC is the PL used to implement TinyOS, our OS for n.e.s., and its apps nesC and TinyOS tightly intertwined; designed together to address 1! challenges of this area I’ll start by introducing n.e.s, typical apps and the resulting challenges I will then show how nesC and TinyOS address these challenges

2 Introduction nesC 1.2 is a major revision to the nesC language Goals
“external” types (with Kevin Chang, UCLA) generic components binary components attributes Goals simplify TinyOS programming make it easier to define new abstractions and services

3 External Types: Why? Current message formats defined as C structures
machine-dependent representation different padding different endianness Until recently, not a problem: homogeneous networks, with platform-specific radios mig tool decodes structures for PCs Now: on telos, micaz, imote2 want interoperability!

4 Standard Solutions Marshalling/unmarshalling:
needs extra RAM protocol stack built by wiring components, so no obvious central place to do marshalling/unmarshalling Unix-style htons, htonl, etc calls programmer-unfriendly only addresses endiannness gcc’s “packed” attribute only addresses padding

5 External Types nesC 1.2 introduces “external types”, which have a platform-independent representation: OLD NEW struct TOSMsg { nx_struct TOSMsg { uint16_t addr; nx_uint16_t addr; uint8_t group; nx_uint8_t group; … … nx_structs have no padding nx_uint16_t, etc are big-endian on all platforms these types can be used like any C types (some minor restrictions) Very easy to convert TinyOS code to use external types

6 Generic Components Components with numeric and type arguments, that can be instantiated at compile-time Interfaces can also have type arguments Uses: utility components: filters, adapters, queues, buffers, etc wiring patterns: see OSKI generic module QueueC(typedef t, int n) { provides interface Queue<t>; } implementation { t q[n]; } configuration App { } implementation { components AppM, new QueueC(TOSMsg, 10) as MyQ; AppM.MsgQ -> MyQ; }

7 Other Changes (in brief)
Attributes (inspired by Java 1.5) programmers can add custom annotations to nesC programs external tools can extract program information uses: wiring checks, network management attributes, etc Binary components compile nesC “app” to .o file with specified entry, exit points uses: build, use, distribute components in binary form encapsulate set of components as C library

8 Status All features implemented
Alpha release at Being used for TinyOS 2.x development work Will be released with TinyOS 2.0

9 Backup

10 Generic Configurations
generic configuration SomeAssembly() { provides interface X; } implementation { components new SomeAssemblyM() as SA, new QueueC(TOSMsg, 10) as SomeQ; X = SA.X; SA.Queue -> SomeQ; } Every instantiation of SomeAssembly will create new instances of SomeAssemblyM and IntQueueC

11 Generic Interfaces Many interfaces similar, except for result, argument types Generic interfaces support this by allowing interfaces to take type parameters Two generic interfaces are connectable iff they have the same type arguments Generic components with type arguments can use generic interfaces to: Provide functionality dependent on that type Express requirements of operations on that type

12 configuration MyApp { }
implementation { components MyCode, new QueueC(int, 10) as MyQ; MyCode.Queue -> MyQ; } interface Queue<t> { command void push(t x); command t pop(); } generic module QueueC (typedef t, int n) { provides interface Queue<t> as Q; } implementation { t q[n]; int p1, p2; command void Q.push(t x) { q[p1++] = x; if (p1 == n) p1 = 0; } …

13 Another example interface Compare<t> {
command bool lessthan(t x1, t x2); } generic module Sort(typedef t) { uses interface Compare<t> as C; } implementation { void f() { t x1, x2; if (call C.lessthan(x1, x2)) …

14 Binary Components component ExternalInterface { provides interface StdControl; uses interface Timer; } entry points (of program including ExternalInterface): ExternalInterface.Timer.fired exit points: ExternalInterface.StdControl.{init, start, stop} ExternalInterface.Timer.{start, stop}

15 Attributes Information on attributes, etc output in XML
{ }; { int key; }; provides interface provides interface Information on attributes, etc output in XML Java-based parser for this XML schema Sample “wiring check” demo app


Download ppt "David Gay Intel Research Berkeley"

Similar presentations


Ads by Google