Hello World In Real-time Periodic Service

This article demonstrates a simple "Hello World" application in RTDroid. The source code is in RTDroid source code under ./demo/HelloWorld. It consists of application source codes under src directory, manifest xml file (demo.xml), and shell scrip for compilation.

Declare Real-time Periodic Service in Manifest[edit]

RTDroid provide a real-time extension of Android manifest. The following code snippet shows an example of declaring a real-time service with periodic logic.

 <service android:name="edu.buffalo.rtdroid.demo.HelloWorldService">
 <rtdroid:priority scheduler="FIFO" priority="20" />
 <period ms="200" ns="0" />
 <startTime relative="true" ms="400" ns="0" /> </rtdroid:periodic>
 <rtdroid:scopeSizes total="500K" persistent="250K" release="250K" /> 

There are three extra elements that can be used for expressing real-time properties in RTDroid manifest.

  • <rtdroid:priority> : Specify the priority of the component.
  • <rtdroid:periodic> : Specify timing requirement of the component, e.g., the starting time of the component, and the periodicity of its periodic logic.
  • <rtdroid:scopeSize>: Specify the memory usage of the component, there are three parameters are required: total, persistent, and release.

persistent and release present a fixed amount of memory for component’s object allocation and run-time computation. Component object and its related objects with same lifetime are allocated in persistent area, the other temporary variables that required during execution are allocated in release area. Then, the 'total is the sum of persistent and release.

Implement periodic logic[edit]

To write application, developers need to extend the abstract classes, which are defined in RTDroid. In this article, we show an implementation of periodic class, which extends RTPeriodicService. Here we only write the onRelease() function, which are trigger periodically at the rate define in <rtdroid:periodic>.

 public void onRelease() { 
 System.out.println("Hello World");