Programming r t abstractions
Download
1 / 32

Programming R-T Abstractions - PowerPoint PPT Presentation


  • 216 Views
  • Uploaded on

Programming R-T Abstractions. TSW November 2009 Anders P. Ravn Aalborg University. Characteristics of a RTS. Timing Constraints Concurrent control of separate components Dependability Requirements Facilities to interact with special purpose hardware.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Programming R-T Abstractions' - chars


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Programming r t abstractions

Programming R-T Abstractions

TSW November 2009

Anders P. Ravn

Aalborg University


Characteristics of a rts
Characteristics of a RTS

  • Timing Constraints

  • Concurrent control of separate components

  • Dependability Requirements

  • Facilities to interact

    with special purpose hardware


Timing constraints
Timing Constraints

  • Notion of time

  • Specifying timing constraints:

    Temporal scopes

  • Notion of Event

  • Clocks, delays and timeouts


Rt java time types
RT Java Time Types

public abstract class HighResolutionTimeimplements

java.lang.Comparable

{

...

public booleanequals(HighResolutionTime time);

public final long getMilliseconds();

public final intgetNanoseconds();

public void set(HighResolutionTime time);

public void set(long millis);

public void set(long millis, intnanos);

}


Time

HighResolutionTime

AbsoluteTime

RelativeTime


RTSJ Absolute and Relative Time

public class AbsoluteTimeextends HighResolutionTime

{ // various constructor methods including

public AbsoluteTime(AbsoluteTime T);

public AbsoluteTime(long millis, intnanos);

...

public final AbsoluteTime add(RelativeTime time);

public final RelativeTime subtract(AbsoluteTime time);

public final AbsoluteTime subtract(RelativeTime time);

}

public class RelativeTimeextends HighResolutionTime

{ // various constructor methods including

public RelativeTime(long millis, intnanos);

public RelativeTime(RelativeTime time);

...

public final RelativeTime add(RelativeTime time);

public final RelativeTime subtract(RelativeTime time);

}


Temporal scope
Temporal scope

  • C: maximum execution time

  • D: deadline for completion of execution

  • T: minimum time between releases (period)

  • S: minimum delay before start of execution


Rtsj releaseparameters
RTSJ ReleaseParameters

ReleaseParameters

PeriodicParameters

AperiodicParameters

SporadicParameters


Rtsj releaseparameters1
RTSJ ReleaseParameters

public abstract class ReleaseParameters {

protected ReleaseParameters(

RelativeTime cost, RelativeTime deadline,

AsyncEventHandleroverrunHandler,

AsyncEventHandlermissHandler);

...

}


Rtsj periodic parameters
RTSJ Periodic Parameters

public class PeriodicParametersextends ReleaseParameters

{

public PeriodicParameters(

HighResolutionTime start,

RelativeTime period,

RelativeTime cost,

RelativeTime deadline,

AsyncEventHandleroverrunHandler,

AsyncEventHandlermissHandler);

public RelativeTimegetPeriod();

public HighResolutionTimegetStart();

}


Rtsj aperiodic and sporadicparameters
RTSJ Aperiodic- and SporadicParameters

public class AperiodicParametersextends ReleaseParameters

{

public AperiodicParameters(RelativeTime cost,

RelativeTime deadline, AsyncEventHandleroverrunHandler,

AsyncEventHandlermissHandler);

}

public class SporadicParametersextends AperiodicParameters

{

public SporadicParameters(RelativeTimeminInterarrival,

RelativeTime cost, RelativeTime deadline,

AsyncEventHandleroverrunHandler,

AsyncEventHandlermissHandler);

public RelativeTimegetMinimumInterarrival();

public void setMinimumInterarrival(RelativeTime minimum);

}


Rtsj asyncevent
RTSJ AsyncEvent

public class AsyncEvent

{

public AsyncEvent();

...

public void addHandler(AsyncEventHandler handler);

public void fire();

...

}

An asynchronous event can have a set of handlers associated with it,

and when the event occurs,

the fireCount of each handler is incremented,

and the handlers are released.


Rtsj clock
RTSJ Clock

public abstract class Clock

{

public Clock();

public static Clock getRealtimeClock();

public abstract RelativeTimegetEpochOffset();

public AbsoluteTimegetTime();

public abstract void getTime(AbsoluteTime time);

public abstract RelativeTimegetResolution();

public abstract void setResolution(RelativeTime resolution);

}


Characteristics of a rts1
Characteristics of a RTS

  • Timing Constraints

  • Concurrent control of separate components

  • Dependability Requirements

  • Facilities to interact

    with special purpose hardware


Rtsj schedulable
RTSJ Schedulable

«interface»

Schedulable

RealTimeThread

AsyncEventHandler

BoundAsyncEventHandler

NoHeapRealTimeThread


Rtsj asynceventhandler
RTSJ AsyncEventHandler

public class AsyncEventHandlerextends java.lang.Object

implements Schedulable

{

public AsyncEventHandler(

SchedulingParameters scheduling,

ReleaseParameters release,

MemoryArea area);

...

public void handleAsyncEvent();

// the program to be executed

...

}


Rtsj realtimethread
RTSJ RealTimeThread

public class RealtimeThreadextends java.lang.Thread

implements Schedulable

{

public RealtimeThread(SchedulingParameters s, ReleaseParameters r);

. . .

. . .

public static RealtimeThreadcurrentRealtimeThread();

public synchronized void schedulePeriodic();

// add the thread to the list of schedulable objects

public synchronized void deschedulePeriodic();

// remove the thread from the list of schedulable object

// when it next issues a waitForNextPeriod

public booleanwaitForNextPeriod() throws ...;

public synchronized void interrupt();

// overrides java.lang.Thread.interrupt()

public static void sleep(Clock c, HighResolutionTime time) throws ...;

}




A real time application
A Real-Time Application

  • Periodic Event Handlers

  • Aperiodic Event Handlers

    collected in a mission

  • Mission Handler

    Each handler

  • has a Memory

  • is Scheduled


Periodic handler
Periodic handler

class Periodic extends PeriodicEventHandler

{

protected Periodic(.., PeriodicParameters pp,

Scheduler scheduler,

MemoryArea memory);

public void handleEvent() {

// the logic to be executed every period

}

}


Aperiodic handler
Aperiodic handler

class Aperiodic extends AperiodicEventHandler

{

protected Aperiodic(.., AperiodicParameters ap,

Scheduler scheduler,

MemoryArea memory);

public void handleEvent() {

// the logic to be executed when an event occurs

}

}


A simple mission
A simple mission

public class Basic extends Mission

{

protected Basic(.., AperiodicParameters ap,

Scheduler scheduler,

MemoryArea memoryArea)

{

... // initialization

}

public static void main (String[] args) {

new Basic( null, null,

new CyclicScheduler(),

new LTMemory(10*1024));

}

}


The mission
…The mission

addToMission(

new Periodic( null, pp, getScheduler(),

new LTMemory(1024)));

addToMission(

new Periodic( null, pp, getScheduler(),

new LTMemory(1024)));

...

add(); // mission to its scheduler


Complex mission
Complex mission

private Mission[] mission;

private int active = 0;

static AperiodicEvent event;

public ThreeSequentialMissions(...) {

mission = new Mission[3];

// set up the three missions

mission[0] = new Mission(...);

// add handlers for mission 0

// including the mission termination

...

mission[1] = new Mission();

...

// start the first mission

mission[active].add();

event = new AperiodicEvent(this);

}


Changing mission
Changing mission

private Mission[] mission;

private int active = 0;

static AperiodicEvent event;

public ThreeSequentialMissions(...) {

...

}

public void handleEvent() {

mission[active].remove();

active = (active + 1) % mission.length;

mission[active].add();

}


Rtsj scheduler
RTSJ Scheduler

Scheduler

PriorityScheduler

Class which represents the required (by the RTSJ)

priority-based scheduler.

The default instance is the base scheduler which does

fixed priority, preemptive scheduling.


Rtsj schedulingparameters
RTSJ SchedulingParameters

public class PriorityParameters {

public PriorityParameters(int priority);

...

}

public class ImportanceParameters {

public PriorityParameters(int priority, int importance);

...

}

Importance is an additional scheduling metric that may be used by

some priority-based scheduling algorithms

during overload conditions to differentiate execution order

among threads of the same priority.


Rtsj priorityscheduler
RTSJ PriorityScheduler

public class PriorityScheduler extends Scheduler

{

public static PriorityScheduler instance();

...

protected boolean

addToFeasibility(Schedulable schedulable);

public boolean isFeasible();

public boolean SetIfFeasible(

Schedulable schedulable,

ReleaseParameters release,

MemoryParameters memory);

}


Rtsj memory management
RTSJ Memory Management

MemoryArea

«singleton»

HeapMemory

ScopedMemory

ImmortalMemory

LTMemory

VTMemory

ImmortalPhysicalMemory


Rtsj memoryarea
RTSJ MemoryArea

public abstract class MemoryArea {

protected MemoryArea(long sizeInBytes);

public void enter(java.lang.Runnable logic);

// associate this memory area to the current thread

// for the duration of the logic.run method

public static MemoryArea getMemoryArea(java.lang.Object object);

// get the memory area associated with the object

public long memoryConsumed();

// number of bytes consumed in this memory area

public long memoryRemaining();

// number of bytes remaining

. . .

public synchronized java.lang.Object newInstance(

java.lang.Class type)throws IllegalAccessException,

InstantiationException, OutOfMemoryError;

// allocate an object

public long size(); // the size of the memory area

}


Simplicity static schedules
Simplicity – Static Schedules

  • Cyclic Executive

  • Time Triggered Architecture (Kopetz)

  • Synchronous Languages (Esterel)

  • Giotto (Henzinger)


ad