From RTSC-Pedia

Jump to: navigation, search
revision tip
—— LANDSCAPE orientation
[printable version]  [offline version]offline version generated on 04-Aug-2010 21:08 UTC 

Extending xdc.runtime Timestamps

How to create customized timestamp providers

Contents

Introduction

The xdc.runtime package contains several modules that need timestamps; e.g., LoggerBuf and LoggerSys. These modules obtain timestamps from other modules that implement the xdc.runtime.ITimestampProvider interface. Two such modules are provided in the xdc.runtime package:

  1. TimestampNull - a timestamp provider that always returns a timestamp of 0, and
  2. TimestampStd - a timestamp provider that uses the ANSI C Standard Library function clock() to obtain timestamps.

In the following sections we focus on how to use and create modules that both implement the ITimestampProvider interface and fully leverage device-specific hardware.

Overview

By definition, real-time systems require some means to track and measure elapsed time. However, different systems use very different methods. Some systems leverage platform-specific timer peripherals while others use application-specific data streams that are known to produce data at a fixed rate (i.e., telephony TDM data). The choice of how to measure time is application and platform specific, so it is important that the timer services provided by xdc.runtime enable the system integrator to specify an appropriate time source.

In addition to variations in how time is measured, different applications have very different precision and range requirements. Applications that only require millisecond precision often don't require more than 32-bits of range (almost 50 days), whereas measurements used to causally relate events in a multi-core system requires near nanosecond precision (yielding less than 5 seconds of range from a 32-bit value). In fact, it is not unusual for a single application to require more than one timer with different precision and range requirements.

Architecture

The xdc.runtime.Timestamp module provides a platform-independent interface that is sufficient for simple timestamping needs. This module makes use of platform-specific implementations which can take advantage of underlying hardware support, for example. Rather than define a single "provider" interface that is sufficient for the needs of the Timestamp module, the xdc.runtime package defines two interfaces:

  • ITimestampClient - defines the platform-independent interface provided by Timestamp, and
  • ITimestampProvider - defines the interface provided by platform-specific implementations and inherits from ITimestampClient

While it may seem odd that underlying timestamp provider implementations must implement the same interface as ITimestampClient, this design enables applications to call timestamp providers directly, when necessary, to leverage platform-specific capabilities. Suppose there is device specific timestamp provider, say Timestamp64, that provides additional methods that put an underlying timer into special low-power modes. Since this Timestamp64 module must implement ITimestampClient (because ITimestampProvider inherits from ITimestampClient), developers that need to leverage the low-power functionality can mechanically replace existing calls to Timestamp methods with calls to Timestamp64 methods and be sure the application will continue to function properly. The figure below illustrates the relationship between the the various timestamp interfaces and modules provided by xdc.runtime as well as this hypothetical Timestamp64 timestamp.

Timestamp Architecture

Examples

In the table below, we provide examples that illustrate how to create and use custom ITimestampProvider modules.

Example Description Purpose
Example 1 Simple timestamp provider illustrate how to create and use a custom timestamp provider

Related Topics

Using Timestamps

[printable version]  [offline version]offline version generated on 04-Aug-2010 21:08 UTC 
Copyright © 2008 The Eclipse Foundation. All Rights Reserved
Views
Personal tools
package reference