+ All Categories
Home > Documents > Celina Gibbs Software Architecture Seng 522 STARS Scoped Types and Aspects for Realtime Systems.

Celina Gibbs Software Architecture Seng 522 STARS Scoped Types and Aspects for Realtime Systems.

Date post: 21-Dec-2015
Category:
View: 229 times
Download: 1 times
Share this document with a friend
Popular Tags:
25
Celina Gibbs Software Architecture Seng 522 STARS Scoped Types and Aspects for Realtime Systems
Transcript

Celina GibbsSoftware ArchitectureSeng 522

STARSScoped Types and Aspects for

Realtime Systems

engineering infrastructure

demands

features

load

currents

multiple lanes?

raising/lowering

capabilities?

a tower?special

materials?

tides

wind

engineering infrastructure

• code under pressure

• needs to be both fast and flexible

system infrastructure

application-specific demands

platform-specific features

virtual machines

• code under pressure

• needs to be both fast and flexible

What happens to structure?

application-specific demands

platform-specific features

virtual machines

application specific demands

platform specific features

Java Virtual Machine

2

Java Virtual Machine

RTLinux

RT

responsibility to structure RT mechanism falls on the

application

Can STARS bring structure to RT mechanism to improve manageability of

RT applications?

RTSJ memory regions

scope a

scope b

scope c

parent

parent

all scoped memory areas must follow a single parent rule to avoid cyclic parent relationships

objects allocated within a scoped memory area can not be discarded until all threads in that area have terminated

an outer scope may not hold a reference to an object within a more deeply nested inner scope

RTSJ memory regions

scope a

scope b

parent

all scoped memory areas must follow a single parent rule to avoid cyclic parent relationships

objects allocated within a scoped memory area can not be discarded until all threads in that area have terminated

an outer scope may not hold a reference to an object within a more deeply nested inner scope

RT mechanisms getting in the way

RT mechanisms getting in the way

left to developer to decipher…

• AsynchronouslyInterruptedException: Generated when a thread is asynchronously interrupted.

• DuplicateFilterException: PhysicalMemoryManager can only accomodate one filter object for each type of memory. It throws this exception if an attempt is made to register more than one filter for a type of memory.

• InaccessibleAreaException: Thrown when an attempt is made to execute or allocate from an allocation context that is not accessible on the scope stack of the current thread.

• MITViolationException: Thrown by the fire() method of an instance of Async-Event when the bound instance of AsyncEventHandler with a Release-Parameter type of SporadicParameters has mitViolationExcept behavior and the minimum interarrival time gets violated.

• MemoryScopeException: Thrown by the wait-free queue implementation when an object is passed that is not compatible with both ends of the queue.

• MemoryTypeConflictException: Thrown when the PhysicalMemoryManager is given conflicting specification for memory. The conflict can be between two types in an array of memory type specifiers, or when the specified base address does not fall in the requested memory type.

• OffsetOutOfBoundsException: Generated by the physical memory classes when the given offset is out of bounds.

• SizeOutOfBoundsException: Generated by the physical memory classes when the given size is out of bounds.

• AsynchronouslyInterruptedException: Generated when a thread is asynchronously interrupted.

• DuplicateFilterException: PhysicalMemoryManager can only accomodate one filter object for each type of memory. It throws this exception if an attempt is made to register more than one filter for a type of memory.

• InaccessibleAreaException: Thrown when an attempt is made to execute or allocate from an allocation context that is not accessible on the scope stack of the current thread.

• MITViolationException: Thrown by the fire() method of an instance of Async-Event when the bound instance of AsyncEventHandler with a Release-Parameter type of SporadicParameters has mitViolationExcept behavior and the minimum interarrival time gets violated.

• MemoryScopeException: Thrown by the wait-free queue implementation when an object is passed that is not compatible with both ends of the queue.

• MemoryTypeConflictException: Thrown when the PhysicalMemoryManager is given conflicting specification for memory. The conflict can be between two types in an array of memory type specifiers, or when the specified base address does not fall in the requested memory type.

• OffsetOutOfBoundsException: Generated by the physical memory classes when the given offset is out of bounds.

• SizeOutOfBoundsException: Generated by the physical memory classes when the given size is out of bounds.

ExceptionsExceptions

• UnsupportedPhysicalMemoryException: Generated by the physical memory classes when the requested physical memory is unsupported.

• MemoryInUseException: Thrown when an attempt is made to allocate a range of physical or virtual memory that is already in use.

• ScopedCycleException: Thrown when a user tries to enter a ScopedMemory that is already accessible (ScopedMemory is present on stack) or when a user tries to create ScopedMemory cycle spanning threads (tries to make cycle in the VM ScopedMemory tree structure).

• UnknownHappeningException: Thrown when bindTo() is called with an illegal happening.

• UnsupportedPhysicalMemoryException: Generated by the physical memory classes when the requested physical memory is unsupported.

• MemoryInUseException: Thrown when an attempt is made to allocate a range of physical or virtual memory that is already in use.

• ScopedCycleException: Thrown when a user tries to enter a ScopedMemory that is already accessible (ScopedMemory is present on stack) or when a user tries to create ScopedMemory cycle spanning threads (tries to make cycle in the VM ScopedMemory tree structure).

• UnknownHappeningException: Thrown when bindTo() is called with an illegal happening.

RuntimeExceptions

RuntimeExceptions

• IllegalAssignmentError: Thrown on an attempt to make an illegal assignment.

• MemoryAccessError: Thrown by the JVM when a thread attempts to access memory that is not in scope.

• ResourceLimitError: Thrown if an attempt is made to exceed a system resource limit, such as the maximum number of locks.

• ThrowBoundaryError: A throwable tried to propagate into a scope where it was not accessible.

• IllegalAssignmentError: Thrown on an attempt to make an illegal assignment.

• MemoryAccessError: Thrown by the JVM when a thread attempts to access memory that is not in scope.

• ResourceLimitError: Thrown if an attempt is made to exceed a system resource limit, such as the maximum number of locks.

• ThrowBoundaryError: A throwable tried to propagate into a scope where it was not accessible.

ErrorsErrors

RTSJ memory regions

scope a

scope b

parent

all scoped memory areas must follow a single parent rule to avoid cyclic parent relationships

objects allocated within a scoped memory area can not be discarded until all threads in that area have terminated

an outer scope may not hold a reference to an object within a more deeply nested inner scope

the right abstraction can help structure the mechanism…

the right abstraction can help structure the mechanism…

heap memory

plain java run-loop

runrun

applicationinstructions

applicationinstructions

terminateterminateconditioncondition

RTSJ run-loop

runrun create new memory scope(m)

create new memory scope(m)

terminateterminate

conditioncondition

create new application thread(a)

create new application thread(a)

applicationinstructions

applicationinstructions

a.run in ma.run in m

terminateterminate

inner memory scope outer memory scope

crosscutting structure

aspect-oriented software development (AOSD)

aspect

RTSJ using AOSD…App around(Object o): call(void App.new()) && this (o) {

App d = (AppLoop)proceed(o);d.memSpace = new LTMemory( SZ,SZ );

return d;

}

App around(Object o): call(void App.new()) && this (o) {

App d = (AppLoop)proceed(o);d.memSpace = new LTMemory( SZ,SZ );

return d;

}

void around(Detector d): execution(void App.run()) && this (d) {

(d.memSpace).enter( new Runnable() {public void run() {

proceed(d);

}});

}

void around(Detector d): execution(void App.run()) && this (d) {

(d.memSpace).enter( new Runnable() {public void run() {

proceed(d);

}});

}

scoped types to clarify policy

• provides the abstraction to help structure mechanism

• clarifies policy

• possible problems:– breaks existing abstractions?– conceals too much mechanism?

scoped types and packages

scopea

scopea.scopeb

scopea.scopeb.scopec

imm

mem

cdmem

parent

parent

scoped types and gates

scope a

scope b

scope c

parent

parent

instance of agate class

instance of agate class

scoped types and gates

scope a

scope b

parent

instance of agate class

instance of agate class

applying AOSD to gates

public interface Gate { MemoryArea mem;

}

declare parents: (type1||type2||…) implements Gate

Gate around(Object o): call(void Gate+.new()) && this (o) {

Gate g = proceed(o);g.memSpace = new LTMemory( SZ,SZ );

return g;

}

Gate around(Object o): call(void Gate+.new()) && this (o) {

Gate g = proceed(o);g.memSpace = new LTMemory( SZ,SZ );

return g;

}

void around(final Gate g): execution(void Gate+.run()) && this (g) {

(g.memSpace).enter( new Runnable() {public void run() {

proceed(g);

}});

}

void around(final Gate g): execution(void Gate+.run()) && this (g) {

(g.memSpace).enter( new Runnable() {public void run() {

proceed(g);

}});

}

tool supportstatic verification

• set of rules established to coincide with RTSJ invariants

• assume that a scoped package contains at least one gate class and zero or more scoped classes

• statically verify rules• eliminates expensive, error prone dynamic

verification

summaryclass App extends NoHeapRealtimeThread { static void main() { imm = ImmortalMemory.instance(); app = (App) imm.newInstance( App.class); app.start(); }  void run() { LTMemory mem = new LTMemory( ...); mem.enter( new Runner() ); }} class Runner implements Runnable { void run() { LTMemory cdmem = new LTMemory(...); Detector cd = new Detector( new StateTable() ); while ( true ) cdmem.enter( cd ); }} class Detector implements Runnable { StateTable state; … void run() { Frame frame = receiveFrame(); Position pos_in_table = state.get( frame.getAircraft()); if (pos_in_table == null) { mem = MemoryArea.getMemoryArea(this); Aircraft new plane = mem.newInstance( Aircraft.class); frame.getAircraft().update(new_plane); pos_in_table = mem.newInstance( Position.class); state.put( new_plane, pos_in_table); } pos_in_table.update( frame.getPosition()); }}

raw RTSJ

package imm;@scoped class Main { static void main() { new App().start(); }}

package imm.mem;@gate final class Appextends NoHeapRealtimeThread { void run() { Detector cd = new Detector(); StateTable state = new StateTable(); Aircraft key = new Aircraft(); while ( true ) cd.run( state, key); }}@scoped class StateTable ...@scoped class Aircraft ...@scoped class Position ...

package imm.mem.cdmem;@gate final class Detector { void run(StateTable state, Aircraft key){ Frame frame = receiveFrame(); TmpAircraft plane = frame.getAircraft(); plane.update( key); Position pos_in_table = state.get( key); if ( pos_in_table == null ) state.put(plane.copy(), frame.getPosition().copy()); else frame.getPosition(). update(pos_in_table); }}@scoped class TmpAircraft ...@scoped class TmpPosition ...@scoped class Frame ...

scoped types

class App extends NoHeapRealtimeThread { static void main() { app.start(); }  class Runner implements Runnable { void run() { Detector cd = new Detector( new StateTable() ); }} class Detector implements Runnable { StateTable state; … void run() { Frame frame = receiveFrame(); Position pos_in_table = state.get( frame.getAircraft()); if (pos_in_table == null) { Aircraft new plane = new Aircraft(); frame.getAircraft().update(new_plane); pos_in_table = new Position(); state.put( new_plane, pos_in_table); } pos_in_table.update( frame.getPosition()); }}

void around (Object obj): execution ( void *.run() ) && this (obj) {

if ( isGate (obj) ) new LTMemory(..).enter( new Runnable() { public void run() { proceed(); } });}void around (Object obj): execution ( void *.run() ) && this (obj) {

if ( isGate (obj) ) new LTMemory(..).enter( new Runnable() { public void run() { proceed(); } });}

aspect

summary

class App extends NoHeapRealtimeThread { static void main() { imm = ImmortalMemory.instance(); app = (App) imm.newInstance( App.class); app.start(); }  void run() { LTMemory mem = new LTMemory( ...); mem.enter( new Runner() ); }} class Runner implements Runnable { void run() { LTMemory cdmem = new LTMemory(...); Detector cd = new Detector( new StateTable() ); while ( true ) cdmem.enter( cd ); }} class Detector implements Runnable { StateTable state; … void run() { Frame frame = receiveFrame(); Position pos_in_table = state.get( frame.getAircraft()); if (pos_in_table == null) { mem = MemoryArea.getMemoryArea(this); Aircraft new plane = mem.newInstance( Aircraft.class); frame.getAircraft().update(new_plane); pos_in_table = mem.newInstance( Position.class); state.put( new_plane, pos_in_table); } pos_in_table.update( frame.getPosition()); }}

raw RTSJ

class App extends NoHeapRealtimeThread { static void main() { app.start(); }  class Runner implements Runnable { void run() { Detector cd = new Detector( new StateTable() ); }} class Detector implements Runnable { StateTable state; … void run() { Frame frame = receiveFrame(); Position pos_in_table = state.get( frame.getAircraft()); if (pos_in_table == null) { Aircraft new plane = new Aircraft(); frame.getAircraft().update(new_plane); pos_in_table = new Position(); state.put( new_plane, pos_in_table); } pos_in_table.update( frame.getPosition()); }}

void around (Object obj): execution ( void *.run() ) && this (obj) {

if ( isGate (obj) ) new LTMemory(..).enter( new Runnable() { public void run() { proceed(); } });}void around (Object obj): execution ( void *.run() ) && this (obj) {

if ( isGate (obj) ) new LTMemory(..).enter( new Runnable() { public void run() { proceed(); } });}

aspect

conclusions• require sophisticated mechanisms to

support complex structure

• AOSD provides linguistic support for software engineering principles– separation of concerns– modularity

• STARS uses AOSD to achieve– separation of real-time mechanism from application

code


Recommended