<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Towards the Coexistence of Divergent Applications on Smart City Sensing Infrastructure</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Rajiv Ramdhany</string-name>
          <email>r.ramdhany@lancaster.ac.uk</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Geoff Coulson</string-name>
          <email>g.coulson@lancaster.ac.uk</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>School of Computing and Communications Lancaster University</institution>
          ,
          <addr-line>Infolab21, LA1 4WA Lancaster</addr-line>
          ,
          <country country="UK">UK</country>
        </aff>
      </contrib-group>
      <fpage>26</fpage>
      <lpage>30</lpage>
      <abstract>
        <p>Based on the trends of divergent sensor node software evolution and on-node multi-application coexistence observed from a real smart city WSAN deployment, we propose requirements for optimum exploitation of the infrastructure. In particular, we advocate the need to switch between concurrency models depending on usage context.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>Long-term Wireless Sensor and Actuator Network (WSAN) deployments as in smart city
infrastructures/testbeds are becoming increasingly large-scale, multipurpose and
‘infrastructural’ in nature. Because of their multi-purpose nature and the major capital
investments involved, we envisage that the owners/ operators of future infrastructural WSAN
deployments will increasingly be driven to adopt agile, multi-stakeholder usage models.
Economically-viable exploitation models require multiplexing concurrent experiments,
applications and users on the WSANs and are characterised by 1) the need to run divergent
and ever-changing software configurations across their (heterogeneous) node base, and 2)
multi-application sensing, the sharing of sensing hardware or sensed data among multiple
coexisting applications.</p>
      <p>
        As a growing set of novel applications are requiring additional complexity and
‘intelligence’ to be pushed to the WSAN leaf nodes [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ], we argue a simplistic concurrent-usage
model based exclusively on sensor-data sharing or on coarse-grain scheduling of sensor
nodes via group reservations (and node reprogramming) [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] does not deliver the
flexibility and efficiency required for an optimum, cost-effective infrastructure exploitation.
      </p>
      <p>
        In this paper, we identify several requirements for enabling the coexistence the WSAN
applications on sensor nodes and focus on the need for OS-level concurrency. The
execution model of current WSN operating systems embodies a particular concurrency strategy
usually based on one of the following: split-phase FIFO task scheduling,
synchronous/asynchronous events, cooperative multithreading, time-sliced preemptive
multithreading or real time scheduling. The choice of a concurrency model often implies a
trade-off between the degree of concurrency, scheduling predictability and resource usage,
made necessary by the resource paucity in the host embedded devices. For example,
eventbased execution models are more energy-efficient and conservative at memory utilisation
[
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] than multithreading but result in unpredictable scheduling behavior when event
handlers are long-lived. Preemptive multithreading models, in contrast, are more deterministic
and offer better event processing capabilities in terms of meeting processing deadlines; but
they incur memory overhead and higher energy consumption [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. Due to ever changing
applications and software configurations in smart city WSANs, we argue that this trade-off
      </p>
      <p>Towards the Coexistence of Divergent Applications on Smart City Sensing Infrastructure 27
is itself dynamic and divergent. Concurrency models have associated costs/benefits and
tend to suit particular WSAN usage scenarios and node roles. Hence, not all nodes need to
commit permanently to a single concurrency model. Instead, we advocate i) concurrency
strategy selection for every IoT node based on its tasks assignment and role (e.g.
application data fusion point or packet forwarder) and, ii) switching between concurrency models
when WSAN nodes participate in different applications serially or simultaneously.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Motivation and State-of-the-Art</title>
      <p>
        We consider the usage model of a real-life smart city WSAN, in occurrence the
SmartSantanter platform, to explain our position. The SmartSantander platform [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] is a
multi-purpose city-scale experimental research facility in support of typical applications
and services for a smart city. It comprises of a large number of Internet of Things (IoT)
devices which are deployed in several urban scenarios, and federated into a single testbed
for the purpose of concurrent experimentation and service provisioning. In addition to
testbed services for experimentation, a number of smart-city services are currently
deployed, namely: city parking control &amp; management, environmental monitoring,
onvehicle mobile sensing, transport vehicle tracking, traffic congestion monitoring and
precision irrigation for urban parks. An analysis of these concurrent services/experiments
reveals that the tasks assigned to IoT nodes usually involve: 1) sensor data sampling, 2)
data collection from neighbouring nodes 3) data processing (e.g. temporal aggregation,
compression or signal processing) 4) data encryption/decryption before
processing/forwarding, or 5) routing data to sink nodes. Further, the functionality that need to
be deployed on sensor nodes is itself application-specific and diverse, for example
conditional triggers for sensor readings, routing behaviour triggered by frequency-analysis of
sensor data, sophisticated data aggregators and compression to name but a few. Also
evident is the need for cohabitation of applications on nodes (for instance, environmental
monitoring, parking control and experimentation sharing repeater nodes).
      </p>
      <p>
        Our analysis has identified the following requirements for achieving concurrent
sensornode use and gauged their current level of support in the state-of-the art.
─ Dynamic local sensor-node reconfiguration - the capability to dynamically
augment/adapt sensor node software by instantiating/removing software modules using
runtime dynamic linking. Various degrees of support for in-situ software update are
offered by modular WSN OSes. Contiki [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] only supports one updatable module at any
one time loaded on top of a fixed kernel. Lorien [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] supports runtime addition, removal
and replacement of software components more naturally.
─ Support for managed sensor node software evolution. A systematic ongoing,
efficient and non-disruptive means of determining and executing software compositional
changes on WSAN nodes such that different nodes can evolve along different lines to
support the software configuration that meet the needs of different stakeholders.
OSlevel architectural reflection and a suite of lightweight protocols are used in [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] to
track/report software configurations, and perform component dissemination and
instructed configuration updates on behalf of users.
─ Application Isolation. With multiple applications sharing a node, it is necessary to
isolate access to node resources (hardware, memory and network) to avoid applications
corrupting each other by overwriting unprotected memory locations or race conditions
on sensors or network interfaces. Since hardware support for virtual memory (personal
address spaces) is inexistent on current WSAN MCUs, the common approach for
memory isolation is through the creation and policing of software protection domains
as proposed in [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] or sandboxing via on-node virtualisation as in the Maté VM [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ].
Hardware access isolation can be provided through virtualised access: SenShare [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ]
provides a compile-time Hardware Abstraction Layer (a set of interfaces used by
applications) which redirects hardware access requests to a runtime comprising of virtual
hardware controllers that serve access requests to the underlying hardware. Network
traffic isolation is achieved by maintaining per-application network overlays as in
Lorien [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] and SenShare [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ].
─ OS-level Concurrency. This involves scheduling the processor between tasks from
coexisting applications and/or experiments efficiently so that they meet their processing
deadlines. Concurrency in TinyOS [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ] is realised through events, and the split-phase
operation of tasks (deferred computation/calls) and event handlers. Tasks run to
completion and are only preemptible by events (triggered as a result of hardware
interrupts); they must therefore be kept reasonably short as not to delay other time-sensitive
tasks such as network stack packet-processors. At the other end of the design space,
concurrent tasks are implemented as threads as in Mantis OS [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ]; applications as well
as system components such as stacks may spawn threads which must be scheduled.
Context switching between threads is performed by a thread scheduler, which follows a
priority-based algorithm with round-robin semantics.
      </p>
      <p>
        Different concurrency models are adopted by existing WSN OSes but none provide
optimal scheduling/resource-consumption under the full range of operating conditions
encountered in multi-purpose WSANs. Run-to-completion event-driven systems such as TinyOS
are efficient in terms of memory usage (single stack usage) and energy consumption (more
time spent in idle mode than other schemes) [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. But they force programmers to model
their algorithms as finite state machines, split-phase operations and short tasks.
Longrunning tasks may cause other parts of the OS to perform poorly as they cannot be
preempted. At high packet arrival rates, for instance, packet processors are unable to
dequeue packets from the radio module’s buffer fast enough since their execution cannot
be prioritised over other tasks. The average execution time of task is variable and this
nondeterministic scheduling behavior is further exacerbated under high load.
Task prioritisation and time-sliced preemption are accepted notions in contemporary OSes
to achieve low execution-delay variation and fairer scheduling between application tasks
although this comes at a price. Preemptive multithreading enables independence between
tasks [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] but requires extra programmable memory for capturing and restoring execution
context when threads are switched. Each thread has its own stack which typically has to be
over-provisioned as stack-space consumption of threads is hard to predict. Moreover,
locking mechanisms are required to serialise concurrent thread access to shared resources,
introducing additional overhead. Context switching causes the processor to spend less time
in idle mode, resulting in higher battery power consumption.
      </p>
      <p>
        Cooperative threading support in WSN OS such as Tiny-Threads [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ], rely on applications
to voluntarily yield the processor, thereby providing concurrency without the costs of
preemption. However, it places the burden of managing concurrency explicitly on the
      </p>
      <p>Towards the Coexistence of Divergent Applications on Smart City Sensing Infrastructure 29
programmer and the inexact science of placing yielding points in code cause
highlyvariable inter-yield intervals. Hybrid models attempt to combine the advantages of both
events and cooperative threading. Contiki, for example, is primarily event-driven i.e.
processes are implemented as event handlers that run to completion and share a common
stack; but it additionally supports multithreading capability as an optional library that
applications can link to.
3</p>
    </sec>
    <sec id="sec-3">
      <title>Pluggable Concurrency Models for MultiApplication Sensing</title>
      <p>Due to divergent evolution of sensor node software and the multi-application
coexistence, we believe the choice of single network-wide concurrency model to be sub-optimal.
In particular, we recommend the adoption of different concurrency strategies to suit each
sensor nodes’ operating context and application requirements, and enabling switching
between them as requirements change. To this end, we propose the following set of
dynamically loadable context-dependent concurrency schemes for smart-city usage scenarios
and provide implementations in Lorien, our reflective component-based WSN OS.
- Split-Phase FIFO Task Scheduling. This concurrency scheme is suitable for usage
scenarios where single-application tasks run on nodes, are short-lived and do not require
scheduling guarantees. As tasks are executed serially on the main thread, race conditions
do not occur and programmers need not use synchronisation primitives. The MCU spends
time either executing tasks and interrupt handlers or sleep duty cycling thereby consuming
less power than if context-switching. Split-Phase FIFO Task Scheduling is preferable on
dedicated single-application leaf nodes for example, in parking sensors nodes buried in the
asphalt or nodes.
- Cooperative Fibers. When a sensor node becomes a data fusion point or is assigned
more CPU-intensive data processing tasks such as Huffman compression of data samples
or pattern matching, yield points can be introduced though cooperative fibers to allow the
CPU to switch to other tasks. A fiber waiting for the radio hardware module to become
available after a transmission can hence voluntarily yield to allow other tasks to execute.
To ensure that suspended fibers are resumed, task continuations are captured in the form
of execution context (including the stack pointer) and restored, using the setcontext
family of functions: getcontext, setcontext and swapcontext.
- Preemptive Time-Sliced Multithreading. This concurrency model is suitable where
task independence and prioritization are required for performance and responsiveness. As
an example, repeater nodes also participating in environmental monitoring scenarios must
prioritise packet forwarding over sensing tasks to avoid inducing network delays. When
sudden high activity is encountered by a node that requires timely processing of tasks
(during a flash flood or volcanic eruption), this concurrency scheme allows tasks to be
scheduled for more frequent sensor data sampling, processing and transmission. For
instance, to enable data collection when Disruption Tolerant Networking (DTN) gateway
nodes on top of buses in SmartSantander come into contact opportunistically with isolated
sensor node islands, data aggregation and transmission must be prioritized over other tasks
as to reliably send data while the bus is still in radio range. Our preemptive thread
scheduler for Lorien is priority-based and uses round robin semantics to ensure a fair
distribution of CPU time slices. Binary and counting semaphores are supported to synchronise
access to shared resources such as device drivers. When a thread blocks on a device driver,
it is moved from a ready-list to a semaphore list. It is removed when, upon receiving a
hardware interrupt, the device-driver posts a semaphore to release the thread.
Powersaving is handled by a thread called idle-task which is scheduled when no threads are
active.
4</p>
    </sec>
    <sec id="sec-4">
      <title>Work in Progress and Conclusions</title>
      <p>To date, we have provided implementations for the aforementioned concurrency
models; their relative suitability to various usage scenarios is under investigation. Further, we
are currently exploring the use of proxy interfaces to make switching between concurrency
models be non-invasive for applications. Also under investigation are the relative benefits
of mixing cooperative and preemptive multithreading in the sensor node context. In this
paper, based on the trends of divergent sensor node software evolution and on-node
multiapplication coexistence observed from a real smart city WSAN deployment we have
proposed requirements for optimum exploitation of the infrastructure. In particular, switching
between concurrency models depending on context is recommended and a number of
dynamically loadable concurrency models proposed.
5</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <given-names>R.</given-names>
            <surname>Shimizu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Tei</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Fukazawa</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Honiden</surname>
          </string-name>
          .
          <article-title>Case studies on the development of wireless sensor network applications using multiple abstraction levels</article-title>
          .
          <source>In SESENA</source>
          <year>2012</year>
          ,
          <year>June 2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>L.</given-names>
            <surname>Sanchez</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.A.</given-names>
            <surname>Galache</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Gutierrez</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.M.</given-names>
            <surname>Hernandez</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Bernat</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Gluhak</surname>
          </string-name>
          , T. Garcia.
          <article-title>SmartSantander: The meeting point between Future Internet research and experimentation and the smart cities</article-title>
          .
          <source>In Future Network &amp; Mobile Summit (FutureNetw)</source>
          ,
          <year>2011</year>
          ,
          <year>June 2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <given-names>G.</given-names>
            <surname>Coulson</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Porter</surname>
          </string-name>
          ,
          <string-name>
            <surname>I. Chatzigiannakis</surname>
          </string-name>
          , and
          <string-name>
            <given-names>T.</given-names>
            <surname>Baumgartner</surname>
          </string-name>
          .
          <article-title>Flexible experimentation in wireless sensor networks</article-title>
          .
          <source>Commun. ACM 55</source>
          ,
          <issue>1</issue>
          (
          <year>January 2012</year>
          ),
          <fpage>82</fpage>
          -
          <lpage>90</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <given-names>C.</given-names>
            <surname>Duffy</surname>
          </string-name>
          ,
          <string-name>
            <given-names>U.</given-names>
            <surname>Roedig</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Herbert</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Sreenan</surname>
          </string-name>
          .
          <article-title>An Experimental Comparison of Event Driven and Multi-Threaded Sensor Node Operating Systems</article-title>
          .
          <source>PerCom Workshops '07. March</source>
          <year>2007</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <given-names>A.</given-names>
            <surname>Dunkels</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Gronvall</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Voigt</surname>
          </string-name>
          .
          <article-title>Contiki - a lightweight and flexible operating system for tiny networked sensors</article-title>
          .
          <source>Local Computer Networks</source>
          ,
          <year>2004</year>
          . Nov.
          <year>2004</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <given-names>B.</given-names>
            <surname>Porter</surname>
          </string-name>
          ,
          <string-name>
            <given-names>U.</given-names>
            <surname>Roedig</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Coulson</surname>
          </string-name>
          .
          <article-title>Type-safe updating for modular WSN software</article-title>
          .
          <source>DCOSS</source>
          <year>2011</year>
          ,
          <year>June 2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <given-names>N.</given-names>
            <surname>Weerasinghe</surname>
          </string-name>
          ,
          <string-name>
            <surname>G. Coulson.</surname>
          </string-name>
          <article-title>Lightweight module isolation for sensor nodes</article-title>
          .
          <source>In MobiVirt 2008</source>
          . ACM, New York, NY, USA.
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <given-names>P.</given-names>
            <surname>Levis</surname>
          </string-name>
          and
          <string-name>
            <given-names>D.</given-names>
            <surname>Culler</surname>
          </string-name>
          .
          <article-title>Maté: a tiny virtual machine for sensor networks</article-title>
          .
          <source>SIGARCH Comput. Archit. News</source>
          <volume>30</volume>
          ,
          <year>October 2002</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <given-names>J.</given-names>
            <surname>Hill</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Szewczyk</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Woo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Hollar</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Culler</surname>
          </string-name>
          , and
          <string-name>
            <given-names>K.</given-names>
            <surname>Pister</surname>
          </string-name>
          .
          <article-title>System architecture directions for networked sensors</article-title>
          .
          <source>SIGPLAN Not</source>
          .
          <volume>35</volume>
          ,
          <year>2000</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <given-names>S.</given-names>
            <surname>Bhatti</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Carlson</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Dai</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Deng</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Rose</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Sheth</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Shucker</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Gruenwald</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Torgerson</surname>
          </string-name>
          , and
          <string-name>
            <given-names>R.</given-names>
            <surname>Han. MANTIS OS</surname>
          </string-name>
          <article-title>: an embedded multithreaded operating system for wireless micro sensor platforms</article-title>
          .
          <source>Mob. Netw. Appl</source>
          .
          <volume>10</volume>
          ,
          <year>August 2005</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <given-names>W. P.</given-names>
            <surname>McCartney</surname>
          </string-name>
          and
          <string-name>
            <given-names>N.</given-names>
            <surname>Sridhar</surname>
          </string-name>
          .
          <article-title>Abstractions for safe concurrent programming in networked embedded systems</article-title>
          .
          <source>In Proc. of SenSys'06</source>
          ,
          <year>2006</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12. I. Leontiadis,
          <string-name>
            <given-names>C.</given-names>
            <surname>Efstratiou</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Mascolo</surname>
          </string-name>
          , and
          <string-name>
            <surname>J. Crowcroft..</surname>
          </string-name>
          <article-title>SenShare: transforming sensor networks into multi-application sensing infrastructures</article-title>
          .
          <source>In Proc. EWSN'12.</source>
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>