Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 74

system specification aClass()!!!! behaviour specification (SimulationController: SimulationController(0.003, 50)[Monitor/Monitor] || MPSoC : Platform(10000000, 0.00002, 200000000, 0.00001, 0.01, 0.

000001, "ARM11", "TriM edia", "MIPS", "ARM11")[Monitor/SimulationController, Communication/Communicatio nResources, Computation/ComputationResources] || Application: Application(1/300, 500, false,"44444444"_, 12345678 , "S2")[Monitor/SimulationController, Computation/Tasks, Communication/Buffers]) \{Communication, Computation, Monitor}

data class BatteryStatus extends Object instance variables ObservedAveragePower: Real, PreviousUpdateTime: Real, AveragePower: LongRunTimeA verage, Power: Real, PeakPower: Real, NumberOfSamples: Integer, ObservedAverageT ime: Real instance methods accurate : Boolean return(AveragePower accurate). log : BatteryStatus |LogFile: FileOut| LogFile := new(FileOut) destination("Battery.log") open; LogFile writeString("Peak Power Consumption: " + PeakPower printString + " Watts " cr cr); if (NumberOfSamples < 20000) then LogFile writeString("Observed Average Power: " + (ObservedAveragePower / Obser vedAverageTime) printString + " Watts") else LogFile writeString("Statistics for Average Power Consumption:" cr + AveragePo wer logStatistics) fi; LogFile close; return(self). init : BatteryStatus Power := 0.0; PeakPower := 0.0; AveragePower := new(LongRunTimeAverage) withParameters(0.95, 0.95); NumberOfSamples := 0.0; ObservedAveragePower := 0.0; ObservedAverageTime := 0.0; PreviousUpdateTime := 0.0; return(self). printString : String |PrintString: String| PrintString := "Current Power Consumption: " + Power printString + " Watts" cr cr + "Peak Power Consumption: " + PeakPower printString + " Watts" cr cr; if (NumberOfSamples < 20000) then

PrintString := PrintString + "Observed Average Power: " + (ObservedAveragePowe r / ObservedAverageTime) printString + " Watts" else PrintString := PrintString + "Statistics for Average Power Consumption:" cr + AveragePower printStatistics fi; return(PrintString). startConsumption(P, CurrentTime: Real): BatteryStatus |Factor: Real| NumberOfSamples := NumberOfSamples + 1; Factor := (NumberOfSamples - 1) / NumberOfSamples; ObservedAveragePower := (Factor * ObservedAveragePower) + (Power * (CurrentTime - PreviousUpdateTime)) / NumberOfSamples; ObservedAverageTime := (Factor * ObservedAverageTime) + (CurrentTime - PreviousU pdateTime) / NumberOfSamples; PreviousUpdateTime := CurrentTime; Power := Power + P; if Power > PeakPower then PeakPower := Power fi; AveragePower rewardBM(Power, CurrentTime); return(self). stopConsumption(P, CurrentTime: Real): BatteryStatus |Factor: Real| NumberOfSamples := NumberOfSamples + 1; Factor := (NumberOfSamples - 1) / NumberOfSamples; ObservedAveragePower := (Factor * ObservedAveragePower) + (Power * (CurrentTime - PreviousUpdateTime)) / NumberOfSamples; ObservedAverageTime := (Factor * ObservedAverageTime) + (CurrentTime - PreviousU pdateTime) / NumberOfSamples; PreviousUpdateTime := CurrentTime; Power := Power - P; AveragePower rewardBM(Power, CurrentTime); return(self).

data class Exponential extends Distribution instance variables Lambda: Real instance methods sample() : Real |Sample: Real| /* Returns a Real sample value for the Exponential distribution. */ Sample := -(Random random ln) / Lambda; if Sample > 0.0 then return(Sample) else return(self sample) fi. printString() : String /*

Displays information about the Exponential distribution. */ return("Exponential(" append(Lambda printString) append(")")). withParameter(L: Real) : Exponential /* Initialises the parameter for the Exponential distribution. L is the reciprocal of the expected value and must be a Real different from 0.0. */ self initialise; if L = 0.0 then self error("Parameter for Exponential distribution must be different from 0.0") fi; Lambda := L; return(self). help() : Object /* An instance of this class represents a Exponential distribution. For more information on the use of this class, see the superclass Distribution. */ return(nil).

process class Task6(MapsToNode: Char, Name: String, PriorityAssignment: Integer) extends Task instance variables initial method call Initialise()() instance methods NotifyBuffersAboutMapping()() par In1!MappedTo(MapTo) and In2!MappedTo(MapTo) and Out!MappedTo(MapTo) and Control!MappedTo(MapTo) rap. CheckTokenAvailabilityForReads(Scenario: String)() if Scenario = "S2" then In1!InspectTokenAvailability(4096); In1?TokensAvailable fi; if Scenario = "S1" then In2!InspectTokenAvailability(4096);

In2?TokensAvailable fi. ReleaseSpaceForReads(Scenario: String)() if Scenario = "S2" then In1!ReleaseRoom fi; if Scenario = "S1" then In2!ReleaseRoom fi. PerformWrites(Scenario: String)() Out!WriteTokens. ReserveSpaceForWrites(Scenario: String)() Out!ReserveRoom(1024); Out?ReservationSuccessful.

data class LongRunSampleAverage extends PerformanceMonitor instance variables AverageSquaredSum: Real, AverageSumLengthProduct: Real, Constant: Real, Transien tMode: Boolean, AverageSum: Real, CurrentSum: Real, AverageLength: Real, Current Length: Integer, AverageSquaredLength: Real, NumberOfCycles: Integer instance methods getCurrentLength() : Integer /* Returns the length of the current batch for the Long Run Sample Average. This method is only used for other complex long run average performance metrics. */ return(CurrentLength). setBatchSize(m: Integer) : LongRunSampleAverage /* This method initialises the size of the batches for the batch-means technique. */ if m > 0 then BatchSize := m else self error("BatchSize parameter for Long Run Sample Average must be larger than 0") fi; return(self). rewardBM(Reward: Real) : LongRunSampleAverage /* Implementing the technique of batch-means, this method processes a reward for th e Long Run Sample Average. */

self rewardRC(Reward, (CurrentLength = 0) | (CurrentLength = BatchSize)); return(self). help() : Object /* An instance of this class represents a monitor for Long Run Sample Average perfo rmance metrics. For more information on the use of this class, see the superclass PerformanceMon itor. */ return(nil). withParameters(A, CL: Real) : LongRunSampleAverage /* This method initialises the accuracy A and the confidence level CL for a Long Ru n Sample Average, where A and CL must be a Real within the interval [0.0, 1.0). */ if (A <= 0.0) | (A >= 1.0) then self error("Accuracy parameter for Long Run Sample Average must be within the interval (0.0, 1.0)") fi; Accuracy := A; self withConfidenceLevel(CL); return(self). getIntervalEstimation() : ConfidenceInterval /* Returns the confidence interval for the Long Run Sample Average. This method is only used for other complex long run average performance metrics. */ return(IntervalEstimation). withConfidenceLevel(CL: Real) : LongRunSampleAverage /* Initialises the confidence level CL for a Long Run Sample Average, where CL must be a Real within the interval [0.0, 1.0). This method is only used for complex long run average performance metrics. */ if (CL < 0.0) | (CL >= 1.0) then self error("ConfidenceLevel parameter for Long Run Sample Average must be within the interval [0.0, 1.0)") fi; ConfidenceLevel := CL; IntervalEstimation := new(ConfidenceInterval) withParameters(nil, nil, Confid enceLevel); Constant := (2.0 sqrt) * (self calculateInverseErfC(1.0 - ConfidenceLevel)); TransientMode := true; NumberOfCycles := 0; CurrentLength := 0; AverageSum := 0.0; AverageLength := 0.0;

AverageSquaredSum := 0.0; AverageSquaredLength := 0.0; AverageSumLengthProduct := 0.0; self setDefaultBatchSize; return(self). rewardRC(Reward: Real, RecurrenceCondition: Boolean) : LongRunSampleAverage |Poi ntEstimation, StandardDeviation, Variance, Factor, HalfWidth: Real| /* Implementing the technique of regenerative cycles, this method processes a rewar d for the Long Run Sample Average. */ if RecurrenceCondition then /* Start new Cycle */ if TransientMode then /* Start with th e first Cycle after compeleting TransientMode */ TransientMode := false else /* Process the just completed Cycle */ NumberOfCycles := NumberOfCycles + 1; Factor := (NumberOfCycles - 1) / NumberOfCycles; AverageSum := (Factor * AverageSum) + (CurrentSum / NumberOfCycles); AverageLength := (Factor * AverageLength) + (CurrentLength / NumberOfCy cles); AverageSquaredSum := (Factor * AverageSquaredSum) + (CurrentSum sqr / N umberOfCycles); AverageSquaredLength := (Factor * AverageSquaredLength) + (CurrentLengt h sqr / NumberOfCycles); AverageSumLengthProduct := (Factor * AverageSumLengthProduct) + ((Curre ntSum * CurrentLength) / NumberOfCycles); if NumberOfCycles > 1 then /* Confidence Interval u ndefined for Variance zero, which is the case if only one Batch has been complet ed yet */ PointEstimation := AverageSum / AverageLength; Variance := ((1 / Factor) * (AverageSquaredSum - (2 * PointEstimatio n * AverageSumLengthProduct) + (PointEstimation sqr * AverageSquaredLength))); if Variance > 0 then StandardDeviation := Variance sqrt else Standar dDeviation := 0.0 fi; /* Have to take rounding errors into account */ HalfWidth := (Constant * StandardDeviation) / (AverageLength * (Numb erOfCycles asReal sqrt)); IntervalEstimation := new(ConfidenceInterval) withParameters(PointEs timation - HalfWidth, PointEstimation + HalfWidth, ConfidenceLevel) fi fi; CurrentSum := Reward; /* Current Rewar d is part of the newly started Cycle */ CurrentLength := 1 else if TransientMode not then /* Continue to complete current Cycle if not in TransientMode anymore */ CurrentSum := CurrentSum + Reward; CurrentLength := CurrentLength + 1 fi fi; return(self).

printHeading() : String /* This method displays the heading for the Long Run Sample Average. */ if Accuracy = nil then /* Only used for other complex long run average performance metrics. */ return("Statistics for Long Run Sample Average") else return("Statistics for Long Run Sample Average with Accuracy " append(Accu racy printString)) fi. calculateInverseErfC(y: Real) : Real |s, t, u, w, x, z: Real| /* This method calculates the Real result value x for the inverse of the complement error function (erfc) for the Real value y which must be within the interval (0 .0, 1.0]. */ z w u s t x := := := := := := y; 0.916461398268964 - z ln; w sqrt; (u ln + 0.488826640273108) / w; 1 / (u + 0.231729200323405); u * (1 - s * (s * 0.124610454613712 + 0.5)) ((((-0.0728846765585675 * t + 0.269999308670029) * t + 0.150689047360223) * t + 0.116065025341614) * t + 0.499999303439796) * t; := 3.97886080735226 / (x + 3.97886080735226); := t - 0.5; := (((((((((0.00112648096188977922 * u + 0.000105739299623423047) * u - 0.00351287146129100025) * u 0.000771708358954120939) * u + 0.00685649426074558612) * u + 0.00339721910367775861) * u - 0.011274916933250487) * u 0.0118598117047771104) * u + 0.0142961988697898018) * u + 0.0346494207789099922) * u + 0.00220995927012179067; := ((((((((((((s * u - 0.0743424357241784861) * u 0.105872177941595488) * u + 0.0147297938331485121) * u + 0.316847638520135944) * u + 0.713657635868730364) * u + 1.05375024970847138) * u + 1.21448730779995237) * u + 1.16374581931560831) * u + 0.956464974744799006) * u + 0.686265948274097816) * u + 0.434397492331430115) * u + 0.244044510593190935) * t z * (2.718281828459045 power(x * x - 0.120782237635245222)); := x + s * (x * s + 1);

t u s

return(x). logTo(Name: String) : LongRunSampleAverage /* This method initialises the Log File for the Long Run Sample Average. The Log Fi le will have the name "Name.log", where the extension ".log" is appended automat ically. */ LogFile := new(FileOut) destination(Name + ".log") open; LogFile writeString("Statistics for the Long Run Sample Average " append(Name printString) append(" with Accuracy ") append(Accuracy printString) cr cr);

LogFile writeString(IntervalEstimation logHeading append(" Accurate :") cr); LogFile writeString("------------------------------------------------------------------------------------------------------------------------" cr); LogFile close; return(self).

process class Task2(MapsToNode: Char, Name: String, PriorityAssignment: Integer) extends Task instance variables initial method call Initialise()() instance methods NotifyBuffersAboutMapping()() par In!MappedTo(MapTo) and Out1!MappedTo(MapTo) and Out2!MappedTo(MapTo) and Control!MappedTo(MapTo) rap. ReserveSpaceForWrites(Scenario: String)() if Scenario = "S1" then Out1!ReserveRoom(1024); Out1?ReservationSuccessful; Out2!ReserveRoom(1024); Out2?ReservationSuccessful fi; if Scenario = "S2" then Out1!ReserveRoom(2048); Out1?ReservationSuccessful fi. PerformWrites(Scenario: String)() Out1!WriteTokens; if Scenario = "S1" then Out2!WriteTokens fi. ReleaseSpaceForReads(Scenario: String)() In!ReleaseRoom. CheckTokenAvailabilityForReads(Scenario: String)() In!InspectTokenAvailability(2048); In?TokensAvailable.

cluster class Application(DesiredLatency: Real, DesiredThroughput: Real, Iterate : Boolean, Mapping: String, PriorityAssignment: Integer, ScenarioPart1: String) behaviour specification (G7: ControlBuffer("G7", 1)[Buffers/Communication, T1G7/In, G7T8/Out] || G2: Con trolBuffer("G2", 1)[Buffers/Communication, T1G2/In, G2T3/Out] || F1: DataBuffer( "F1", 0, 1)[Buffers/Communication, T1F1/In, F1T2/Out] || F2: DataBuffer("F2", 0, 1)[Buffers/Communication, T1F2/In, F2T3/Out] || Task2: Task2(Mapping get(2), " Task2", PriorityAssignment/1000000)[T2F10/Out2, Tasks/Computation, T2F7/Out1, F1 T2/In, G1T2/Control] || F3: DataBuffer("F3", 0, 1)[Buffers/Communication, T1F3/I n, F3T4/Out] || F4: DataBuffer("F4", 0, 1)[Buffers/Communication, T3F4/In, F4T5/ Out] || F5: DataBuffer("F5", 0, 1)[Buffers/Communication, T3F5/In, F11T6/Out] || Task3: Task3(Mapping get(3), "Task3", PriorityAssignment/100000)[T3F5/Out2, Ta sks/Computation, T3F4/Out1, F2T3/In, G2T3/Control] || F6: DataBuffer("F6", 0, 1) [Buffers/Communication, T4F6/In, F12T6/Out] || F7: DataBuffer("F7", 0, 1)[Buffer s/Communication, T2F7/In, F7T7/Out] || F8: DataBuffer("F8", 0, 1)[Buffers/Commun ication, T5F8/In, F8T7/Out] || G1: ControlBuffer("G1", 1)[Buffers/Communication, T1G1/In, G1T2/Out] || G3: ControlBuffer("G3", 1)[Buffers/Communication, T1G3/In , G3T4/Out] || G6: ControlBuffer("G6", 1)[Buffers/Communication, T1G6/In, G6T7/O ut] || Task5: Task5(Mapping get(5), "Task5", PriorityAssignment/1000)[Tasks/Com putation, T5F8/Out, F4T5/In, F7T5/Control] || F9: DataBuffer("F9", 0, 1)[Buffers /Communication, T6F15/In, F9T7/Out] || G4: ControlBuffer("G4", 1)[Buffers/Commun ication, T1G4/In, F7T5/Out] || Task6: Task6(Mapping get(6), "Task6", PriorityAs signment/100)[F12T6/In2, Tasks/Computation, T6F15/Out, F11T6/In1, F13T6/Control] || F10: DataBuffer("F10", 0, 1)[Buffers/Communication, T2F10/In, F10T8/Out] || F11: DataBuffer("F11", 0, 1)[Buffers/Communication, T7F11/In, F11T8/Out] || F12: DataBuffer("F12", 4, 1)[Buffers/Communication, T8F12/In, F12T1/Out] || Task1: T ask1(Iterate, Mapping get(1), "Task1", PriorityAssignment/10000000, ScenarioPar t1)[T1FG5/C_T6, T1F1/D_T2, F12T1/In, T1F2/D_T3, T1G4/C_T5, T1F3/D_T4, T1G3/C_T4, Tasks/Computation, T1G7/C_T8, T1G2/C_T3, T1G1/C_T2, T1G6/C_T7, Monitor/Monitor] || Task7: Task7(Mapping get(7), "Task7", PriorityAssignment/10)[Tasks/Computat ion, G6T7/Control, F9T7/In3, T7F11/Out, F8T7/In2, F7T7/In1] || G5: ControlBuffer ("G5", 1)[Buffers/Communication, T1FG5/In, F13T6/Out] || Task4: Task4(Mapping g et(4), "Task4", PriorityAssignment/10000)[Tasks/Computation, T4F6/Out, F3T4/In, G3T4/Control] || Task8: Task8(DesiredLatency, DesiredThroughput, Iterate, Mappin g get(8), "Task8", PriorityAssignment/1)[Tasks/Computation, G7T8/Control, Monit or/Monitor, T8F12/Out, F11T8/In2, F10T8/In1])\{T1F3, F10T8, F9T7, T5F8, T3F4, F7 T7, T1F1, T2F7, F7T5, F11T8, G3T4, F11T6, T1G1, F3T4, F4T5, T1G2, G2T3, F13T6, T 1F2, G1T2, G7T8, F8T7, T1G6, T1G4, T6F15, T2F10, T4F6, T1G7, T8F12, T1G3, F12T6, F2T3, T7F11, F1T2, T3F5, G6T7, F12T1, T1FG5}[SimulationController/Monitor]

process class PlatformMonitor() instance variables Status: PlatformStatus initial method call Initialise()() instance methods CheckAccuracyStatus()() |Name: String, MonitorID: Integer, Accurate: Boolean| SimulationController?PlatformStatus; MonitorID := 1; while MonitorID <= Status getNumberOfMonitors() do

Monitor!Status(Status getMonitor(MonitorID)); Monitor?AccuracyStatus(Accurate){Status register(MonitorID, Accurate)}; MonitorID := MonitorID + 1 od; SimulationController!PlatformAccuracyStatus(Status accurate); CheckAccuracyStatus()(). Initialise()() |Monitor: String| Status := new(PlatformStatus) init; abort while true do Monitor?InitialiseMonitor(Monitor){Status addMonitor(Monitor )} od with delay(2.0e-12); abort CheckAccuracyStatus()() with SimulationController?StopSimulation; while true do Monitor!StopSimulation od.

data class SchedulerStatus extends Object instance variables NumberOfTasks: Integer, TaskList: QueueElement, Policy: String instance methods removeTask(OldTask: ScheduledTask) : Integer |E: QueueElement| E := TaskList getPrev; while E getElement getName != OldTask getName do E := E getPrev od; E getNext setPrev(E getPrev); E getPrev setNext(E getNext); NumberOfTasks := NumberOfTasks - 1; return(NumberOfTasks). nextTaskToSchedule : ScheduledTask return(TaskList getPrev getElement). updateTask(OldTask: ScheduledTask) : SchedulerStatus |E: QueueElement| E := TaskList getPrev; while E != TaskList do if E getElement getName = OldTask getName then E setElement(OldTask) fi; E := E getPrev od; return(self). init(T: String) : SchedulerStatus Policy := T; NumberOfTasks := 0; TaskList := new(QueueElement); TaskList setNext(TaskList) setPrev(TaskList); return(self).

printString : String |PrintOut: String, E: QueueElement| PrintOut := "Operating System with Policy: " + Policy printString cr cr + "List of Waiting Tasks:" cr; PrintOut := PrintOut + "( "; E := TaskList getPrev; while E != TaskList do PrintOut := PrintOut + E getElement printString; if E getPrev != TaskList then PrintOut := PrintOut + ", " fi; E := E getPrev od; PrintOut := PrintOut + " )"; return(PrintOut). registerTask(Task, Scenario: String, Priority: Integer) : ScheduledTask |NewTask : ScheduledTask, NE, E: QueueElement, Found: Boolean| NewTask := new(ScheduledTask) init(Task, Scenario, Priority); NE := new(QueueElement) setElement(NewTask); if Policy = "FCFS" then E := TaskList else if Policy = "PB" then E := TaskList getNext; Found := false; while (E != TaskList) & (Found not) do if E getElement getPriority < Priority then E := E getNext else Found := true fi od; E := E getPrev else self error("Unkown Scheduling Policy") fi fi; NE setNext(E getNext) setPrev(E); E setNext(NE); NE getNext setPrev(NE); NumberOfTasks := NumberOfTasks + 1; return(NewTask).

data class DataBufferMonitor extends Object instance variables Name: String, Trace: Boolean, ReservedLocations: Integer, TokenSize: Integer, Va rianceOccupation: LongRunTimeVariance, PreviousTime: Real, Monitor: Boolean, Ava ilableTokens: Integer, MaximumOccupation: Integer, AverageOccupation: LongRunTim eAverage, BufferSize: Integer, TraceFile: FileOut instance methods remove(NumberOfTokens: Integer, CurrentTime: Real) : DataBufferMonitor |Occupati on: Integer|

Occupation := ReservedLocations + AvailableTokens; if Trace & (CurrentTime > PreviousTime) then TraceFile writeString("At time: " + PreviousTime printString + " Occupation: " + (Occupation * TokenSize) printString cr) fi; AvailableTokens := AvailableTokens - NumberOfTokens; Occupation := Occupation NumberOfTokens; if Monitor then AverageOccupation rewardBM(Occupation * TokenSize, CurrentTime); VarianceOccu pation rewardBM(Occupation * TokenSize, CurrentTime) fi; PreviousTime := CurrentTime; return(self). accurate : Boolean return(AverageOccupation accurate). available(NumberOfTokens: Integer) : Boolean return(AvailableTokens >= NumberOfTokens). getResults : String |Result: String| Result := "-------------------------------" cr + "Statistics for Channel: " + Na me cr cr; Result append("Observed Maximum Buffer Occupancy: " + MaximumOccupation printStr ing cr cr); Result append("Average Buffer Occupancy:" cr + AverageOccupation logStatistics c r cr); Result append("Variance in Buffer Occupancy:" cr + VarianceOccupation logStatist ics cr cr); return(Result). write(NumberOfTokens: Integer) : DataBufferMonitor ReservedLocations := ReservedLocations - NumberOfTokens; AvailableTokens := AvailableTokens + NumberOfTokens; return(self). init(N: String, BS, IT, TS: Integer, M: Boolean, T: Boolean) : DataBufferMonitor Name := N; BufferSize := BS; TokenSize := TS; AvailableTokens := 0; ReservedLoca tions := 0; PreviousTime := 0.0; Monitor := M; if Monitor then MaximumOccupation := 0; AverageOccupation := new(LongRunTimeAverage) withParameters(0.95, 0.95); VarianceOccupation := new(LongRunTimeVariance) withParameters(0.95, 0.95) fi; Trace := T; if Trace then TraceFile := new(FileOut) destination("Channel_" + Name + ".trace") open; TraceFile writeString("Traced Buffer Occupancy for Channel: " + Name cr cr) fi; self reserve(IT, 0.0); self write(IT); return(self).

room(NumberOfTokens: Integer) : Boolean if BufferSize > 0 then return((ReservedLocations + AvailableTokens + NumberOfTokens) <= BufferSize) else return(true) fi. reserve(NumberOfTokens: Integer, CurrentTime: Real) : DataBufferMonitor |Occupat ion: Integer| Occupation := ReservedLocations + AvailableTokens; if Trace & (CurrentTime > PreviousTime) then TraceFile writeString("At time: " + PreviousTime printString + " Occupation: " + (Occupation * TokenSize) printString cr) fi; ReservedLocations := ReservedLocations + NumberOfTokens; Occupation := Occupatio n + NumberOfTokens; if Monitor then if (Occupation * TokenSize) > MaximumOccupation then MaximumOccupation := Occ upation * TokenSize fi; AverageOccupation rewardBM(Occupation * TokenSize, CurrentTime); VarianceOccu pation rewardBM(Occupation * TokenSize, CurrentTime) fi; PreviousTime := CurrentTime; return(self).

data class ApplicationStatus extends Object instance variables NumberOfFirings: Integer, NumberOfDeadlineMisses: Integer, Throughput: LongRunRa teAverage, NextDeadline: Real, TimeOfLastFiring: Real, DesiredThroughput: Real instance methods fired(CurrentTime: Real) : ApplicationStatus NumberOfFirings := NumberOfFirings + 1; Throughput rewardBM(1, CurrentTime); if CurrentTime > NextDeadline then NumberOfDeadlineMisses := NumberOfDeadlineMis ses + 1 fi; NextDeadline := NextDeadline + 1.0 / DesiredThroughput; TimeOfLastFiring := CurrentTime; return(self). printString : String if NumberOfFirings > 0 then if NumberOfFirings = 1 then return("Throughput Results: " cr + Throughput logStatistics cr cr + (100 * (NumberOfDeadlineMisses / NumberOfFirings)) printString + "% Deadline Misses" c r cr + "Latency: " + TimeOfLastFiring printString) else return("Throughput Results: " cr + Throughput printString cr cr + (100 * ( NumberOfDeadlineMisses / NumberOfFirings)) printString + "% Deadline Misses") fi else return("Waiting for first frame")

fi. accurate : Boolean return(Throughput accurate). init(DL, DT: Real) : ApplicationStatus NumberOfFirings := 0; NumberOfDeadlineMisses := 0; NextDeadline := DL; DesiredThroughput := DT; TimeOfLastFiring := 0.0; Throughput := new(LongRunRateAverage) withParameters(0.95, 0.95) setBatchSize(10 00); return(self). log : ApplicationStatus |LogFile: FileOut| LogFile := new(FileOut) destination("Application.log") open; if NumberOfFirings = 0 then LogFile writeString("The output actor never fired!") else if NumberOfFirings = 1 then LogFile writeString("Throughput Results: " cr + Throughput logStatist ics cr cr + (100 * (NumberOfDeadlineMisses / NumberOfFirings)) printString + "% Deadline Misses" cr cr + "Latency: " + TimeOfLastFiring printString) else LogFile writeString("Throughput Results: " cr + Throughput logStatist ics cr cr + (100 * (NumberOfDeadlineMisses / NumberOfFirings)) printString + "% Deadline Misses") fi fi; LogFile close; return(self).

data class Queue extends Object instance variables PrimQueue: QueueElement, Size: Integer, Occupation: Integer, Unbounded: Integer, QueuingPolicy: String instance methods help() : Object /* Instances of this class represent a (un)bounded queue with FIFO or LIFO queueing policy. To initialise a queue, use the method init() which returns an unbounded queue with FIFO queueing policy by default. To change the queueing policy of a queue, use the method setPolicy("Policy")

where "Policy" is one of the following two possibilities: - "FIFO" to FIFO - "LIFO" y to LIFO To change the size of a queue, use either the method - setSize(Value) then 0 indicating the queue size - unboundedSize() where Value is an Integer larger to obtain an unbounded queue sets the queueing policy sets the queueling polic

For more information, see the individual methods */ return(nil). isNotEmpty() : Boolean /* Checks whether the Queue is not empty. */ return(Occupation != 0). remove() : Object |QE: QueueElement| /* Removes the first QueueElement from the Queue. */ if Occupation = 0 then self error("Queue is Empty.") fi; if QueuingPolicy = "FIFO" then QE := PrimQueue getPrev else if QueuingPolicy = "LIFO" then QE := PrimQueue getNext else self error("Unknown Queuing Policy") fi fi; QE getNext setPrev(QE getPrev); QE getPrev setNext(QE getNext); Occupation := Occupation - 1; return(QE getElement). put(NewElement: Object) : Object |NQE: QueueElement| /* Puts a NewElement into the Queue. */ if Occupation = Size then self error("Queue is Full.") fi; NQE := new(QueueElement) setElement(NewElement); NQE setNext(PrimQueue getNext) setPrev(PrimQueue); PrimQueue setNext(NQE); NQE getNext setPrev(NQE); Occupation := Occupation + 1;

return(self). printString(): String |QE: QueueElement, PrintOut: String| /* Displays the contents of the Queue. */ if Occupation = 0 then PrintOut := "Empty" else PrintOut := "( "; QE := PrimQueue getPrev; while (QE == PrimQueue) not do PrintOut append(QE printString); if (QE getPrev == PrimQueue) not then PrintOut append(", ") fi; QE := QE getPrev od; PrintOut append(" )"); return(PrintOut) fi. occupation() : Integer /* Returns the current occupation of the Queue */ return(Occupation). inspect() : Object |QE: QueueElement| /* Inspects the first QueueElement, without changing the Queue. */ if Occupation = 0 then self error("Queue is empty.") fi; if QueuingPolicy = "FIFO" then QE := PrimQueue getPrev else if QueuingPolicy = "LIFO" then QE := PrimQueue getNext else self error("Unknown Queuing Policy") fi fi; return(QE getElement). getSize() : Integer /* Returns the Size of the Queue. */ return(Size). setPolicy(Policy: String) : Queue /* Sets the QueuingPolicy. */ if (Policy = "FIFO") | (Policy = "LIFO") then QueuingPolicy := Policy; return(self)

else return(self error("Unknown Queuing Policy")) fi. setSize(S: Integer) : Queue /* Sets the Size of the Queue */ if S <= 0 then self error("Size of Queue must be larger then 0") fi; Size := S; return(self). getPolicy() : String /* Returns the Policy for the Queue. */ return(QueuingPolicy). isNotFull() : Boolean /* Checks whether the Queue is not full. */ return(Occupation != Size). unboundedSize() : Queue /* Sets the Size of the Queue to Unbounded */ Size := Unbounded; return(self). init() : Queue /* Sets the initial values of instance variables, this will be done automaticall y in the constructor of the primitive class Queue. */ Unbounded := -1; Occupation := 0; QueuingPolicy := "FIFO"; Size := Unbounded; PrimQueue := new(QueueElement); PrimQueue setNext(PrimQueue) setPrev(PrimQueue); return(self).

data class ProcessorStatus extends Object instance variables MemoryUsages: Dictionary, RunningTask: String, ContextSwitchingTime: Real, Frequ ency: Real, ExecutionTimes: Dictionary, PowerConsumption: Real, Running: Boolean , Utilisation: LongRunTimeAverage instance methods

accurate : Boolean return(Utilisation accurate). run(T: ScheduledTask, CurrentTime: Real) : ProcessorStatus Running := true; RunningTask := T getName; Utilisation rewardBM(1, CurrentTime); return(self). getContextSwitchingTime : Real return(ContextSwitchingTime / Frequency). getExecutionTime(Task: ScheduledTask) : Real if Task getRemainingExecutionTime = nil then return(ExecutionTimes at(Task getName) at(Task getScenario) / Frequency) else return(Task getRemainingExecutionTime) fi. log(Name, MemoryResults: String) : ProcessorStatus |LogFile: FileOut| LogFile := new(FileOut) destination("Processor" + Name + ".log") open; LogFile writeString("Processor Utilisation Results:" cr cr + "Average Utilisatio n:" cr + Utilisation logStatistics cr cr + "Data Memory Results: " cr cr + Memor yResults); LogFile close; return(self). init(Type: String) : ProcessorStatus |File: FileIn, i: Integer, Task: String| if (Type != "MIPS") & (Type != "ARM11") & (Type != "TriMedia") then self error(" Unknown Processor Type") fi; File := new(FileIn) source(Type + ".txt") open; File readString; Frequency := File readNumber; File readString; File readString; ContextSwitchingTime := File readNumber; File readString; File readString; PowerConsumption := File readNumber; File readString; File readString; File readString; File readString; File readString; File readString; File readString; File readString; File readStr ing; ExecutionTimes := new(Dictionary) init; MemoryUsages := new(Dictionary) init; i := 1; while i <= 8 do Task := File readString; ExecutionTimes atPut(Task, new(Dictionary) init); MemoryUsages atPut(Task, new(Dictionary) init); ExecutionTimes at(Task) atPut("S1", File readNumber); ExecutionTimes at(Task) atPut("S2", File readNumber); MemoryUsages at(Task) atPut("S1", File readNumber); MemoryUsages at(Task) atPut("S2", File readNumber); i := i + 1 od; File close; Running := false; Utilisation := new(LongRunTimeAverage) withParameters(0.95, 0.95);

return(self). getPowerConsumption : Real return(PowerConsumption). getMemoryUsage(Task: ScheduledTask) : Real return(MemoryUsages at(Task getName) at(Task getScenario)). printString : String if Running then return("Processor is Executing Task " + RunningTask printString cr cr + "Aver age Utilisation:" cr + Utilisation printStatistics) else return("Processor is Idle" cr cr + "Average Utilisation:" cr + Utilisation pr intStatistics) fi. idle(CurrentTime: Real) : ProcessorStatus Running := false; RunningTask := nil; Utilisation rewardBM(0, CurrentTime); return(self). update(Task: ScheduledTask, RunTime: Real) : ProcessorStatus if Task getRemainingExecutionTime = nil then Task setRemainingExecutionTime((ExecutionTimes at(Task getName) at(Task getSc enario) / Frequency) - RunTime) else Task setRemainingExecutionTime(Task getRemainingExecutionTime - RunTime) fi; return(self). notPreviouslyPreempted(Task: ScheduledTask) : Boolean if Task getRemainingExecutionTime != nil then return(false) else return(true) fi.

data class LongRunRateAverage extends PerformanceMonitor instance variables AverageReward: LongRunSampleAverage, AverageTime: LongRunSampleAverage, LastTime : Real instance methods getCurrentLength() : Integer return(AverageReward getCurrentLength). setBatchSize(m: Integer) : LongRunRateAverage

if m > 0 then BatchSize := m; AverageReward setBatchSize(BatchSize); AverageTime setBatchSize(BatchSize) else self error("BatchSize parameter for Long Run Rate Average must be larger t han 0") fi; return(self). rewardBM(Reward, CurrentTime: Real) : LongRunRateAverage self rewardRC(Reward, CurrentTime, (AverageReward getCurrentLength = 0) | (Av erageReward getCurrentLength = BatchSize)); return(self). help() : Object /* An instance of this class represents a monitor for Long Run Rate Average perform ance metrics. For more information on the use of this class, see the superclass PerformanceMon itor. */ return(nil). withParameters(A, CL: Real) : LongRunRateAverage if (A <= 0.0) | (A >= 1.0) then self error("Accuracy parameter for Long Run Rate Average must be within th e interval (0.0, 1.0)") fi; Accuracy := A; self withConfidenceLevel(CL); return(self). getIntervalEstimation() : ConfidenceInterval return(IntervalEstimation). withConfidenceLevel(CL: Real) : LongRunRateAverage if (CL < 0.0) | (CL >= 1.0) then self error("ConfidenceLevel parameter for Long Run Rate Average must be wi thin the interval [0.0, 1.0)") fi; ConfidenceLevel := CL; AverageReward := new(LongRunSampleAverage) withConfidenceLevel((ConfidenceLev el + 1) / 2); AverageTime := new(LongRunSampleAverage) withConfidenceLevel((ConfidenceLevel + 1) / 2); IntervalEstimation := (AverageReward getIntervalEstimation) / (AverageTime ge tIntervalEstimation); self setDefaultBatchSize(); return(self). rewardRC(Reward, CurrentTime: Real, RecurrenceCondition: Boolean) : LongRunRateA verage

if LastTime != nil then AverageReward rewardRC(Reward, RecurrenceCondition); AverageTime rewardRC(CurrentTime - LastTime, RecurrenceCondition) fi; LastTime := CurrentTime; if RecurrenceCondition then IntervalEstimation := (AverageReward getIntervalEstimation) / (AverageTime getIntervalEstimation) fi; return(self). printHeading() : String /* This method displays the heading for the Long Run Rate Average. */ if Accuracy = nil then /* Only used for other complex long run average performance metrics. */ return("Statistics for Long Run Rate Average") else return("Statistics for Long Run Rate Average with Accuracy " append(Accura cy printString)) fi. logTo(Name: String) : LongRunTimeAverage /* This method initialises the Log File for the Long Run Rate Average. The Log File will have the name "Name.log", where the extension ".log" is appended automatic ally. */ LogFile := new(FileOut) destination(Name + ".log") open; LogFile writeString("Statistics for the Long Run Rate Average " append(Name p rintString) append(" with Accuracy ") append(Accuracy printString) cr cr); LogFile writeString(IntervalEstimation logHeading append(" Accurate :") cr); LogFile writeString("------------------------------------------------------------------------------------------------------------------------" cr); LogFile close; return(self).

process class Task3(MapsToNode: Char, Name: String, PriorityAssignment: Integer) extends Task instance variables initial method call Initialise()() instance methods NotifyBuffersAboutMapping()() par In!MappedTo(MapTo) and Out1!MappedTo(MapTo)

and Out2!MappedTo(MapTo) and Control!MappedTo(MapTo) rap. CheckTokenAvailabilityForReads(Scenario: String)() In!InspectTokenAvailability(1024); In?TokensAvailable. ReleaseSpaceForReads(Scenario: String)() In!ReleaseRoom. PerformWrites(Scenario: String)() Out1!WriteTokens; if Scenario = "S2" then Out2!WriteTokens fi. ReserveSpaceForWrites(Scenario: String)() Out1!ReserveRoom(4096); Out1?ReservationSuccessful; if Scenario = "S2" then Out2!ReserveRoom(4096); Out2?ReservationSuccessful fi.

data class CommunicationStatus extends Object instance variables AverageNumberOfConcurrentConnections: LongRunTimeAverage, NumberOfConcurrentConn ections: Integer, AchievedMaximumNumberOfConcurrentConnections: Integer, ActiveC onnections: Set instance methods accurate : Boolean return(AverageNumberOfConcurrentConnections accurate). inactive(Connection: String) : Boolean return(ActiveConnections includes(Connection) not). deactivate(Connection: String, CurrentTime: Real) : CommunicationStatus ActiveConnections remove(Connection); NumberOfConcurrentConnections := NumberOfConcurrentConnections - 1; AverageNumberOfConcurrentConnections rewardBM(NumberOfConcurrentConnections, Cur rentTime); return(self). activate(Connection: String, CurrentTime: Real) : CommunicationStatus

ActiveConnections add(Connection); NumberOfConcurrentConnections := NumberOfConcurrentConnections + 1; if NumberOfConcurrentConnections > AchievedMaximumNumberOfConcurrentConnections then AchievedMaximumNumberOfConcurrentConnections := NumberOfConcurrentConnectio ns fi; AverageNumberOfConcurrentConnections rewardBM(NumberOfConcurrentConnections, Cur rentTime); return(Connection). log(Name, MemoryResults: String) : CommunicationStatus |LogFile: FileOut| LogFile := new(FileOut) destination("Communication" + Name + ".log") open; LogFile writeString("Interconnect Utilisation Results:" cr cr + "Achieved Maximu m Number of Concurrent Connections: " + AchievedMaximumNumberOfConcurrentConnect ions printString cr cr + "Statistics for Average Number of Concurrent Connection s:" cr + AverageNumberOfConcurrentConnections logStatistics cr cr + "Buffer Memo ry Results: " cr cr + MemoryResults); LogFile close; return(self). init : CommunicationStatus ActiveConnections := new(Set) init; NumberOfConcurrentConnections := 0; AchievedMaximumNumberOfConcurrentConnections := 0; AverageNumberOfConcurrentConnections := new(LongRunTimeAverage) withParameters(0 .95, 0.95); return(self). printString : String return("Number of Concurrent Connections: " + NumberOfConcurrentConnections prin tString cr cr + "Active Connections:" cr + ActiveConnections printString cr cr + "Achieved Maximum Number of Concurrent Connections: " + AchievedMaximumNumberOf ConcurrentConnections printString cr cr + "Statistics for Average Number of Conc urrent Connections:" cr + AverageNumberOfConcurrentConnections printStatistics).

process class Task7(MapsToNode: Char, Name: String, PriorityAssignment: Integer) extends Task instance variables initial method call Initialise()() instance methods NotifyBuffersAboutMapping()() par In1!MappedTo(MapTo) and In2!MappedTo(MapTo) and In3!MappedTo(MapTo) and Out!MappedTo(MapTo)

and Control!MappedTo(MapTo) rap. CheckTokenAvailabilityForReads(Scenario: String)() if Scenario = "S1" then In1!InspectTokenAvailability(1024); In1?TokensAvailable else In1!InspectTokenAvailability(2048); In1?TokensAvailable fi; In2!InspectTokenAvailability(4096); In2?TokensAvailable; In3!InspectTokenAvailability(1024); In3?TokensAvailable. ReleaseSpaceForReads(Scenario: String)() In1!ReleaseRoom; In2!ReleaseRoom; In3!ReleaseRoom. PerformWrites(Scenario: String)() Out!WriteTokens. ReserveSpaceForWrites(Scenario: String)() Out!ReserveRoom(2048); Out?ReservationSuccessful.

data class Uniform extends Distribution instance variables LowerBound: Real, IntervalLength: Real instance methods sample() : Real /* Returns a Real sample value for the Uniform distribution. */ return(LowerBound + (Random random * IntervalLength)). printString() : String /* Displays information about the Uniform distribution. */ return("Uniform(" append(LowerBound printString) append(", ") append((LowerBo und + IntervalLength) printString) append(")")). withParameters(LB, UB: Real) : Uniform /* Initialises the parameters of the Uniform distribution. LB and UB represent resp

ectively the lower and upper bounds of the interval (LB,UB) in which the sample values are and must be Reals. Notice that LB must be smaller then UB. */ self initialise; if LB >= UB then self error("Lower bound parameter of Uniform distribution must be smaller then upper bound parameter") fi; LowerBound := LB; IntervalLength := UB - LB; return(self). help() : Object /* An instance of this class represents a Uniform distribution. For more information on the use of this class, see the superclass Distribution. */ return(nil).

data class MemoryStatus extends Object instance variables Occupation: Integer, MaximumOccupation: Integer, AverageOccupation: LongRunTimeA verage instance methods accurate : Boolean return(AverageOccupation accurate). free(NumberOfBytes: Integer, CurrentTime: Real) : MemoryStatus Occupation := Occupation - NumberOfBytes; AverageOccupation rewardBM(Occupation, CurrentTime); return(self). init : MemoryStatus Occupation := 0; MaximumOccupation := 0; AverageOccupation := new(LongRunTimeAverage) withParameters(0.95, 0.95); return(self). printString: String return("Occupation: " + Occupation printString cr cr + "Maximum Occupation: " + MaximumOccupation printString cr cr + "Statistics for Average Occupation:" cr + AverageOccupation printStatistics). logString: String return("Maximum Occupation: " + MaximumOccupation printString cr cr + "Statistic s for Average Occupation:" cr + AverageOccupation logStatistics).

allocate(NumberOfBytes: Integer, CurrentTime: Real) : MemoryStatus Occupation := Occupation + NumberOfBytes; if Occupation > MaximumOccupation then MaximumOccupation := Occupation fi; AverageOccupation rewardBM(Occupation, CurrentTime); return(self).

data class LongRunTimeVariance extends PerformanceMonitor instance variables AverageSquaredReward: LongRunTimeAverage, AverageReward: LongRunTimeAverage instance methods setBatchSize(m: Integer) : LongRunTimeVariance /* This method initialises the size of the batches for the batch-means technique. */ if m > 0 then BatchSize := m; AverageReward setBatchSize(BatchSize); AverageSquaredReward setBatchSize(BatchSize) else self error("BatchSize parameter for Long Run Time Variance must be larger than 0") fi; return(self). rewardBM(Reward, CurrentTime: Real) : LongRunTimeVariance /* Implementing the technique of batch-means, this method processes a reward for th e Long Run Time Variance. */ self rewardRC(Reward, CurrentTime, (AverageReward getCurrentLength = 0) | (Av erageReward getCurrentLength = BatchSize)); return(self). help() : Object /* An instance of this class represents a monitor for Long Run Time Variance perfor mance metrics. For more information on the use of this class, see the superclass PerformanceMon itor. */ return(nil). withParameters(A, CL: Real) : LongRunTimeVariance /* This method initialises the accuracy A and confidence level CL for a Long Run Sa mple Variance, where A and CL must be a Real within the interval [0.0, 1.0). */

if (A <= 0.0) | (A >= 1.0) then self error("Accuracy parameter for Long Run Sample Variance must within th e interval (0.0, 1.0)") fi; Accuracy := A; if (CL < 0.0) | (CL >= 1.0) then self error("ConfidenceLevel parameter for Long Run Sample Variance must be within the interval [0.0, 1.0)") fi; ConfidenceLevel := CL; AverageReward := new(LongRunTimeAverage) withConfidenceLevel((ConfidenceLevel + 1) / 2); AverageSquaredReward := new(LongRunTimeAverage) withConfidenceLevel((Confiden ceLevel + 1) / 2); IntervalEstimation := (AverageSquaredReward getIntervalEstimation) - ((Averag eReward getIntervalEstimation) sqr); self setDefaultBatchSize(); return(self). rewardRC(Reward, CurrentTime: Real, RecurrenceCondition: Boolean) : LongRunTimeV ariance /* Implementing the technique of regenerative cycles, this method processes a rewar d for the Long Run Time Variance. */ AverageReward rewardRC(Reward, CurrentTime, RecurrenceCondition); AverageSquaredReward rewardRC(Reward * Reward, CurrentTime, RecurrenceConditi on); if RecurrenceCondition then IntervalEstimation := (AverageSquaredReward getIntervalEstimation) - ((Ave rageReward getIntervalEstimation) sqr) fi; return(self). printHeading() : String /* This method displays the heading for the Long Run Time Variance. */ return("Statistics for Long Run Time Variance with Accuracy " append(Accuracy printString)). logTo(Name: String) : LongRunTimeVariance /* This method initialises the Log File for the Long Run Time Variance. The Log Fil e will have the name "Name.log", where the extension ".log" is appended automati cally. */ LogFile := new(FileOut) destination(Name + ".log") open; LogFile writeString("Statistics for the Long Run Time Variance " append(Name printString) append(" with Accuracy ") append(Accuracy printString) cr cr); LogFile writeString(IntervalEstimation logHeading append(" Accurate :") cr);

LogFile writeString("------------------------------------------------------------------------------------------------------------------------" cr); LogFile close; return(self).

data class Bernoulli extends Distribution instance variables SuccessProbability: Real instance methods yieldsSuccess() : Boolean /* Returns a Boolean sample value for the Bernoulli distribution. */ return(Random random < SuccessProbability). withParameter(SP: Real) : Bernoulli /* Initialises the parameter for the Bernoulli distribution. SP is the success prob ability and must be a Real within the interval [0.0, 1.0]. */ self initialise; if (SP < 0.0) | (SP > 1.0) then self error("Parameter for Bernoulli distribution must be within the interv al [0, 1]") fi; SuccessProbability := SP; return(self). printString() : String /* Displays information about the Bernoulli distribution. */ return("Bernoulli(" append(SuccessProbability printString) append(")")). sample() : Boolean /* Returns a Boolean sample value for the Bernoulli distribution. */ return(Random random < SuccessProbability). help() : Object /* An instance of this class represents a Bernoulli distribution. For more information on the use of this class, see the superclass Distribution. */ return(nil).

data class MarkovChain extends Object instance variables Transitions: Array, CurrentState: String, NumberOfStates: Integer, StateSpace: A rray, Random: Uniform instance methods init : MarkovChain NumberOfStates := 0; StateSpace := new(Array); Transitions := new(Array); Random := new(Uniform) withParameters(0, 1); return(self). setInitialState(State: String) : MarkovChain CurrentState := State; return(self). hasState(State: String) : Boolean | result: Boolean, i: Integer | i:=1; result := false; while i<=NumberOfStates do if StateSpace get(i) = State then result := true fi; i := i +1 od; return result. addState(State: String) : MarkovChain NumberOfStates := NumberOfStates + 1; StateSpace size(NumberOfStates); StateSpace put(NumberOfStates, State); Transitions size(NumberOfStates); Transitions put(NumberOfStates, new(Array)); return(self). getNextScenario : String |NextState, Scenario: String, i, StateNumber: Integer, T: Array, Sample: Real| i := 1; while i <= StateSpace getSize do if StateSpace get(i) = CurrentState then StateNumber := i fi; i := i + 1 od; T := Transitions get(StateNumber); Sample := Random sample; i := 1; while i <= T getSize do if ((Sample > T get(i) get(2)) & (Sample <= T get(i) get(3))) then NextState := T get(i) get(1) fi; i := i + 1 od; CurrentState := NextState; return(NextState). addTransition(State: String, NextState: String, LowerBound: Real, UpperBound: Re al) : MarkovChain |i, StateNumber: Integer, T, A: Array|

i := 1; while i <= StateSpace getSize do if StateSpace get(i) = State then StateNumber := i fi; i := i + 1 od; T := Transitions get(StateNumber); A := new(Array) size(3); A put(1, NextState) put(2, LowerBound) put(3, UpperBoun d); T size(T getSize + 1); T put(T getSize, A); return(self).

process class Task(MapsToNode: Char, Name: String, PriorityAssignment: Integer) instance variables Priority: Integer, MapTo: String initial method call Initialise()() instance methods Execute(Scenario: String)() |N: String| Computation!Execute(Name, Scenario, Priority, MapTo); Computation?ExecutionCompleted(N | N = Name). NotifyBuffersAboutMapping()() skip. ReserveSpaceForWrites(Scenario: String)() skip. PerformWrites(Scenario: String)() skip. Fire()() |Scenario: String| Control!InspectTokenAvailability; Control?TokenAvailable(Scenario); CheckTokenAvailabilityForReads(Scenario)(); ReserveSpaceForWrites(Scenario)(); Execute(Scenario)(); ReleaseSpaceForReads(Scenario)(); PerformWrites(Scenario)(); Control!ReleaseRoom; Fire()(). NotifyPlatformAboutMapping()() Computation!Use(MapTo). Initialise()() |temp: String| temp := "Node"; temp := temp + "#";

temp put(5,MapsToNode); MapTo := temp; Priority := PriorityAssignment modulo(10); NotifyBuffersAboutMapping()(); NotifyPlatformAboutMapping()(); Fire()(). ReleaseSpaceForReads(Scenario: String)() skip. CheckTokenAvailabilityForReads(Scenario: String)() skip.

data class Normal extends Distribution instance variables StandardDeviation: Real, Mean: Real instance methods sample() : Real |S, U, X, Y: Real| /* Returns a Real sample value for the Normal distribution. The implementation concerns the Polar method which is based on Box-Muller method . */ S := 1.0; while S >= 1.0 do X := 2.0 * Random random - 1.0; Y := 2.0 * Random random - 1.0; S := (X * X) + (Y * Y) od; U := (-2.0 * (S ln) / S) sqrt; return(Mean + (X * U * StandardDeviation)). printString() : String /* Displays information about the Normal distribution. */ return("Normal(" append(Mean printString) append(", ") append((StandardDeviat ion * StandardDeviation) printString) append(")")). withParameters(M, V: Real) : Normal /* Initialises the parameters of the Normal distribution. M and V represent respect ively the mean and variance and must be Reals. */ self initialise; Mean := M; StandardDeviation := V sqrt;

return(self). help() : Object /* An instance of this class represents a Normal distribution. For more information on the use of this class, see the superclass Distribution. */ return(nil).

cluster class NetworkOnChip(BandwidthPerConnection: Real, ConnectionSetUpLatency : Real, NetworkName: String, PowerPerActiveConnection: Real, PowerPerStoredByte: Real) behaviour specification (BufferMemory: StorageUnit(PowerPerStoredByte)[Monitor/Monitor, Power/Power, Buf fers/Access] || RouterNetwork: CommunicationUnit(BandwidthPerConnection, Connect ionSetUpLatency, NetworkName, PowerPerActiveConnection)[Communications/Communica tions, Buffers/Memory, Power/Power, Monitor/Monitor])\{Buffers}

data class ControlBufferMonitor extends Object instance variables Name: String, Trace: Boolean, ReservedLocations: Integer, VarianceOccupation: Lo ngRunTimeVariance, TokenSize: Integer, PreviousTime: Real, Monitor: Boolean, Ava ilableTokens: Integer, MaximumOccupation: Integer, AverageOccupation: LongRunTim eAverage, Buffer: Queue, BufferSize: Integer, TraceFile: FileOut instance methods remove(CurrentTime: Real) : Integer |Occupation: Integer| Occupation := ReservedLocations + AvailableTokens; if Trace & (CurrentTime > PreviousTime) then TraceFile writeString("At time: " + PreviousTime printString + " Occupation: " + (Occupation * TokenSize) printString cr) fi; AvailableTokens := AvailableTokens - 1; Occupation := Occupation - 1; if Monitor then AverageOccupation rewardBM(Occupation * TokenSize, CurrentTime); VarianceOccu pation rewardBM(Occupation * TokenSize, CurrentTime) fi; PreviousTime := CurrentTime; return(Buffer remove). accurate : Boolean return(AverageOccupation accurate). available : Boolean return(AvailableTokens >= 1). getResults : String |Result: String|

Result := "-------------------------------" cr + "Statistics for Channel: " + Na me cr cr; Result append("Observed Maximum Buffer Occupancy: " + MaximumOccupation printStr ing cr cr); Result append("Average Buffer Occupancy:" cr + AverageOccupation logStatistics c r cr); Result append("Variance in Buffer Occupancy:" cr + VarianceOccupation logStatist ics cr cr); return(Result). write(NumberOfTokens: Integer, Scenario: Integer) : ControlBufferMonitor |Counte r: Integer| ReservedLocations := ReservedLocations - NumberOfTokens; AvailableTokens := AvailableTokens + NumberOfTokens; Counter := NumberOfTokens; while (Counter > 0) do Buffer put(Scenario); Counter := Counter - 1 od; return(self). init(N: String, BS: Integer, NIT, CIT: Queue, TS: Integer, M: Boolean, T: Boolea n) : ControlBufferMonitor Name := N; BufferSize := BS; TokenSize := TS; AvailableTokens := 0; ReservedLocations := 0; PreviousTime := 0.0; Monitor := M; if Monitor then MaximumOccupation := 0; AverageOccupation := new(LongRunTimeAverage) withParameters(0.95, 0.95); VarianceOccupation := new(LongRunTimeVariance) withParameters(0.95, 0.95) fi; Trace := T; if Trace then TraceFile := new(FileOut) destination("Channel_" + Name + ".trace") open; TraceFile writeString("Traced Buffer Occupancy for Channel: " + Name cr cr) fi; Buffer := new(Queue) init; while NIT isNotEmpty do self reserve(NIT inspect, 0); self write(NIT inspect, CIT inspect); NIT remove; CIT remove od; return(self). room(NumberOfTokens: Integer) : Boolean if BufferSize > 0 then return((ReservedLocations + AvailableTokens + NumberOfTokens) <= BufferSize) else return(true) fi. inspect() : Integer return(Buffer inspect). reserve(NumberOfTokens: Integer, CurrentTime: Real) : ControlBufferMonitor |Occu pation: Integer|

Occupation := ReservedLocations + AvailableTokens; if Trace & (CurrentTime > PreviousTime) then TraceFile writeString("At time: " + PreviousTime printString + " Occupation: " + (Occupation * TokenSize) printString cr) fi; ReservedLocations := ReservedLocations + NumberOfTokens; Occupation := Occupatio n + NumberOfTokens; if Monitor then if (Occupation * TokenSize) > MaximumOccupation then MaximumOccupation := Occ upation * TokenSize fi; AverageOccupation rewardBM(Occupation * TokenSize, CurrentTime); VarianceOccu pation rewardBM(Occupation * TokenSize, CurrentTime) fi; PreviousTime := CurrentTime; return(self).

data class PerformanceMonitor extends Object instance variables BatchSize: Integer, ConfidenceLevel: Real, Accuracy: Real, IntervalEstimation: C onfidenceInterval, LogFile: FileOut instance methods printStatistics() : String /* This method displays the statistics for about the long-run average performance m etric. */ if Accuracy = nil then return(IntervalEstimation printString) else return(IntervalEstimation printHeading tab + "Accurate:" cr + IntervalEsti mation printStatistics tab + IntervalEstimation accurate(Accuracy) printString) fi. accurate() : Boolean /* This method checks the accuracy of the long-run average performance metric */ return(IntervalEstimation accurate(Accuracy)). help() : Object /* This class is an abstract superclass of the subclasses LongRunSampleAverage, Lon gRunTimeAverage, LongRunSampleVariance and LongRunTimeVariance. To obtain a specific long run average performance metric monitor, use the method *** MANDATORY *** ofType("PerformanceMonitorType") where "PerformanceMonitorType" is one of the following: - "LongRunSampleAverage" mance metric monitor - "LongRunTimeAverage" returns a Long Run Sample Average perfor returns a Long Run Time Average performa

nce metric monitor - "LongRunSampleVariance" rmance metric monitor - "LongRunTimeVariance" ric monitor

returns a Long Run Sample Variance perfo returns a Long Run Time Variance performance met

To initialise the Accuracy (1 minus the Relative Error) and ConfidenceLevel for a Long Run Average Performance Metric, use the method *** MANDATORY ** * withParameters(Accuracy, ConfidenceLevel) where Accuracy must be a Real within the interval (0.0, 1.0) and where Confidenc eLevel must be a Real within the interval [0.0, 1.0) To process a reward for a long run average performance metric, use the only one of the methods rewardRC(Reward, RecurrenceCondition) for performance metric types Long Run Sample Average and Long Run Sample Varianc e estimated with the technique of regenerative cycles rewardRC(Reward, currentTime, RecurrenceCondition) for performance metric types Long Run Time Average and Long Run Time Variance es timated with the technique of regenerative cycles rewardBM(Reward) for performance metric types Long Run Sample Average and Long Run Sample Varianc e estimated with the batch-means technique rewardBM(Reward, currentTime) for performance metric types Long Run Time Average and Long Run Time Variance es timated with the batch-means technique where Reward must be a Real and RecurrenceCondition must be a Boolean. The default Batch Size for the batch means technique is 10000. To use a differen t Batch Size, use method setBatchSize(BatchSize) To check whether the obtained accuracy is not larger than the desired accuracy a s specified by the variable "Accuracy" when initialising the long run average pe rformance metric with the "withParameters" method, use method accurate() To initialise the logging capabilities of a long run average performance metric monitor, use the method logTo("Name") where "Name" is a name for the long-run average performance metric. The Log File will have the name "Name.log", where the extension ".log" is append ed automatically. To append a line with the current statistics of a long run average performance m etric, use the method log() */ return(nil). logStatistics() : String /* This method returns the statistics for about the long-run average performance me tric for logging purposes */ return(IntervalEstimation logHeading tab + "Accurate:" cr + IntervalEstimation l

ogStatistics tab + IntervalEstimation accurate(Accuracy) printString). log() : PerformanceMonitor /* This method logs one line in the log file with the current statistics for the lo ng-run average performance metric. */ if LogFile = nil then self error("Can not log statistics: Log File not initialised.") else LogFile append; LogFile writeString(IntervalEstimation logStatistics tab + self accurate p rintString cr); LogFile close fi; return(self). printString() : String /* This method displays information about the long-run average performance metric. */ return(self printHeading cr + self printStatistics). ofType(Type: String) : PerformanceMonitor /* This method returns an object representing a monitor for long-run average perfor mance metrics of one of the following types: - "LongRunSampleAverage" returns a monitor for Long Run Sample Average pe rformance metrics, use "LongRunSampleAverage" for the parameter Type - "LongRunTimeAverage" returns a monitor for Long Run Time Average perf ormance metrics, use "LongRunTimeAverage" for the parameter Type - "LongRunSampleVariance" returns a monitor for Long Run Sample Variance p erformance metrics, use "LongRunSampleVariance" for the parameter Type - "LongRunTimeVariance" returns a monitor for Long Run Time Variance performance metrics, use "LongRunTimeVariance" for the parameter Type - "LongRunRateAverage" returns a monitor for Long Run Rate Average perf ormance metrics, use "LongRunRateAverage" for the parameter Type */ if Type = "LongRunSampleAverage" then return(new(LongRunSampleAverage)) else if Type = "LongRunTimeAverage" then return(new(LongRunTimeAverage)) else if Type = "LongRunSampleVariance" then return(new(LongRunSampleVariance)) else if Type = "LongRunTimeVariance" then return(new(LongRunTimeVariance)) else if Type = "LongRunRateAverage" then return(new(LongRunRateAverage)) else self error("Unknown Performance Monitor Type") fi

fi fi fi fi. setDefaultBatchSize() : PerformanceMonitor /* This method sets the batch size to a default value of 10000 reward values */ BatchSize := 10000; return(self).

process class ProcessingUnit(NodeName: String, Type: String, VoltageScaleFactor: Real) instance variables Status: ProcessorStatus initial method call Initialise()() instance methods Initialise()() |InUse: Boolean, Results: String| OS?Use(InUse); if InUse then Memory!Use(InUse); Monitor!InitialiseMonitor("Processor" + NodeName); Status := new(ProcessorStatus) init(Type); if (VoltageScaleFactor != 1/4) & (VoltageScaleFactor != 1/2) & (VoltageScaleF actor != 1/3) & (VoltageScaleFactor != 2/3) & (VoltageScaleFactor != 3/4) & (Vol tageScaleFactor != 1/1) then Status error("Invalid voltage scale factor") fi; abort par ExecuteTask()() and CheckAccuracyStatus()() rap with Monitor?StopSimulation; Memory?SimulationResults(Results){Status log(NodeN ame, Results)} fi. ExecuteTask()() |Task: ScheduledTask, StartTime: Real, Preempt: Boolean| OS?Execute(Task){Status run(Task, currentTime)}; Power!StartConsumption(Status getPowerConsumption * (VoltageScaleFactor sqr)); delay(Status getContextSwitchingTime / VoltageScaleFactor); if Status notPreviouslyPreempted(Task) then Memory!Allocate(Status getMemoryUsag e(Task)) fi; StartTime := currentTime; Preempt := false; abort delay(Status getExecutionTime(Task) / VoltageScaleFactor)

with OS?Preempt{Preempt := true; Status update(Task, (currentTime - StartTime) * VoltageScaleFactor)}; OS!Stopped(Task){Status idle(currentTime)}; Power!StopConsumption(Status getPowerConsumption * (VoltageScaleFactor sqr)); if Preempt not then Memory!Free(Status getMemoryUsage(Task)) fi; ExecuteTask()(). CheckAccuracyStatus()() |ID: String, Accurate: Boolean| Monitor?Status(ID | ID = ("Processor" + NodeName)); Memory!Status; Memory?AccuracyStatus(Accurate); Monitor!AccuracyStatus(Accurate & Status accurate); CheckAccuracyStatus()().

data class ScheduledTask extends Object instance variables Scenario: String, RemainingExecutionTime: Real, Priority: Integer, Name: String instance methods getPriority : Integer return(Priority). setRemainingExecutionTime(T: Real) : ScheduledTask RemainingExecutionTime := T; return(self). getScenario : String return(Scenario). getName : String return(Name). init(N, S, P: String) : ScheduledTask Name := N; Scenario := S; Priority := P; return(self). printString : String return("Task " + Name printString + " in Scenario " + Scenario printString + " w ith Priority " + Priority printString). getRemainingExecutionTime : Real return(RemainingExecutionTime).

process class CommunicationUnit(BandwidthPerConnection: Real, ConnectionSetUpLat ency: Real, NodeName: String, PowerPerActiveConnection: Real) instance variables Status: CommunicationStatus initial method call Initialise()() instance methods CheckAccuracyStatus()() |ID: String, Accurate: Boolean| Monitor?Status(ID | ID = ("Communication" + NodeName)); Memory!Status; Memory?AccuracyStatus(Accurate); Monitor!AccuracyStatus(Accurate & Status accurate); CheckAccuracyStatus()(). Transfer()() |Channel, Connection, MapTo: String, NumberOfTokens, TokenSize, Tra nsferID: Integer| Communications?ReserveRoom(Channel, MapTo, NumberOfTokens, TokenSize | (Status i nactive(Channel)) & (MapTo = NodeName)){Status activate(Channel, currentTime)}; par Memory!Allocate(NumberOfTokens * TokenSize); Communications!TransferInitiated(Channel); delay(ConnectionSetUpLatency); Communications?Transfer(Connection, MapTo, TransferID | (Connection = Channel ) & (MapTo = NodeName)); Power!StartConsumption(PowerPerActiveConnection); delay(NumberOfTokens * TokenSize / BandwidthPerConnection); Communications!TransferCompleted(Channel, TransferID){Status deactivate(Chann el, currentTime)}; Power!StopConsumption(PowerPerActiveConnection) and Transfer()() rap. ReleaseBufferSpace()() |MapTo: String, NumberOfTokens, TokenSize: Integer| Communications?ReleaseRoom(MapTo, NumberOfTokens, TokenSize | MapTo = NodeName); Memory!Free(NumberOfTokens * TokenSize); ReleaseBufferSpace()(). Initialise()() |MapTo, Results: String, InUse: Boolean, NumberOfTokens, TokenSiz e: Integer| InUse := false; abort while true do Communications?Use(MapTo | MapTo = NodeName){InUse := true} od with delay(1.0e-12); if InUse then Memory!Use(InUse); Monitor!InitialiseMonitor("Communication" + NodeName); Status := new(CommunicationStatus) init; abort while true do Communications?InitialiseTokens(MapTo, NumberOfTokens, TokenSize | MapT o = NodeName); Memory!Allocate(NumberOfTokens * TokenSize) od with delay(1.0e-12);

abort par Transfer()() and ReleaseBufferSpace()() and CheckAccuracyStatus()() rap with Monitor?StopSimulation; Memory?SimulationResults(Results){Status log(NodeN ame, Results)} fi.

process class Task1(Iterate: Boolean, MapsToNode: Char, Name: String, PriorityAs signment: Integer, ScenarioPart1: String) instance variables Priority: Integer, MapTo: String, MarkovChain: MarkovChain initial method call Initialise()() instance methods Execute(Scenario: String)() |N: String| Computation!Execute(Name, Scenario, Priority, MapTo); Computation?ExecutionCompleted(N | N = Name). NotifyBuffersAboutMapping()() par In! MappedTo(MapTo) and D_T2!MappedTo(MapTo) and D_T3!MappedTo(MapTo) and D_T4!MappedTo(MapTo) and C_T2!MappedTo(MapTo) and C_T3!MappedTo(MapTo) and C_T4!MappedTo(MapTo) and C_T5!MappedTo(MapTo) and C_T6!MappedTo(MapTo) and C_T7!MappedTo(MapTo) and C_T8!MappedTo(MapTo) rap. ReserveSpaceForWrites(Scenario: String)() D_T2!ReserveRoom(2048); D_T2?ReservationSuccessful;

D_T3!ReserveRoom(1024); D_T3?ReservationSuccessful; if Scenario = "S1" then D_T4!ReserveRoom(2048); D_T4?ReservationSuccessful fi; C_T2!ReserveRoom(1); C_T2?ReservationSuccessful; C_T3!ReserveRoom(1); C_T3?ReservationSuccessful; C_T4!ReserveRoom(1); C_T4?ReservationSuccessful; C_T5!ReserveRoom(1); C_T5?ReservationSuccessful; C_T6!ReserveRoom(1); C_T6?ReservationSuccessful; C_T7!ReserveRoom(1); C_T7?ReservationSuccessful; C_T8!ReserveRoom(1); C_T8?ReservationSuccessful. PerformWrites(Scenario: String)() D_T2!WriteTokens; D_T3!WriteTokens; if Scenario = "S1" then D_T4!WriteTokens fi; C_T2!WriteTokens(Scenario); C_T3!WriteTokens(Scenario); C_T4!WriteTokens(Scenario); C_T5!WriteTokens(Scenario); C_T6!WriteTokens(Scenario); C_T7!WriteTokens(Scenario); C_T8!WriteTokens(Scenario). Fire()() |Scenario: String| if Iterate then Scenario := MarkovChain getNextScenario else Scenario := Scenari oPart1 fi; if MarkovChain hasState(Scenario) not then Scenario := new(Object) error("Uknown scenario: " + Scenario + " in Task1 method Fire()().") fi; CheckTokenAvailabilityForReads(Scenario)(); ReserveSpaceForWrites(Scenario)(); Execute(Scenario)(); ReleaseSpaceForReads(Scenario)(); PerformWrites(Scenario)(); if Iterate then Fire()() fi. NotifyPlatformAboutMapping()() Computation!Use(MapTo). Initialise()() |temp: String| temp := "Node"; temp := temp + "#"; temp put(5,MapsToNode);

MapTo := temp; Priority := PriorityAssignment modulo(10); NotifyBuffersAboutMapping()(); NotifyPlatformAboutMapping()(); {MarkovChain := new(MarkovChain) init; MarkovChain addState("S1"); MarkovChain addTransition("S1", "S1", MarkovChain addTransition("S1", "S2", MarkovChain addState("S2"); MarkovChain addTransition("S2", "S2", MarkovChain addTransition("S2", "S1", MarkovChain setInitialState("S1")};

0, 1/2); 1/2, 1); 0, 2/3); 2/3, 1);

abort Fire()() with Monitor?StopSimulation. ReleaseSpaceForReads(Scenario: String)() In!ReleaseRoom. CheckTokenAvailabilityForReads(Scenario: String)() In!InspectTokenAvailability(1); In?TokensAvailable.

data class DiscreteUniform extends Distribution instance variables IntervalLength: Integer, LowerBound: Integer instance methods sample() : Integer /* Returns an Integer sample value for the Discrete Uniform distribution. */ return(LowerBound + (Random random * IntervalLength) floor). printString() : String /* Displays information about the Discrete Uniform distribution. */ return("DiscreteUniform(" append(LowerBound printString) append(", ") append( (LowerBound + IntervalLength - 1) printString) append(")")). withParameters(LB, UB: Integer) : DiscreteUniform /* Initialises the parameters of this Discrete Uniform distribution. LB and UB repr esent respectively the lower and upper bounds of the discrete interval [LB,UB] i n which the sample values are and must be Integers. Notice that LB must be smaller then or equal to UB. */ self initialise;

if LB > UB then self error("Lower bound parameter of Discrete Uniform distribution must be smaller then or equal to upper bound parameter") fi; LowerBound := LB; IntervalLength := UB - LB + 1; return(self). help() : Object /* An instance of this class represents a Discrete Uniform distribution. For more information on the use of this class, see the superclass Distribution. */ return(nil).

data class QueueElement extends Object instance variables Next: QueueElement, Prev: QueueElement, Element: Object instance methods getNext: QueueElement return(Next). help() : Object /* This class is used by class Queue */ return(nil). getPrev: QueueElement return(Prev). setNext(QE: QueueElement): QueueElement Next := QE; return(self). getElement: Object return(Element). printString() : String return(Element printString). setPrev(QE: QueueElement): QueueElement Prev := QE; return(self).

setElement(element: Object): QueueElement Element := element; return(self).

data class ConfidenceInterval extends Object instance variables ConfidenceLevel: Real, LowerBound: Real, UpperBound: Real instance methods logHeading() : String /* This method returns the statistics heading for logging purposes. */ return("Point Estimation:" tab + "Confidence Interval:" tab tab + "Confidence Level:" tab + "Relative Error:"). sqr() : ConfidenceInterval |Lower, Upper: Real| /* This method implements the square operation on confidence intervals. */ if self extendedLowerGreaterEqualZero then Lower := self extendedTimes(LowerBound, LowerBound); Upper := self extendedTimes(UpperBound, UpperBound) else if self extendedUpperLessZero then Lower := self extendedTimes(UpperBound, UpperBound); Upper := self extendedTimes(LowerBound, LowerBound) else Lower := 0.0; Upper := self extendedMax(self extendedTimes(LowerBound, LowerBound), s elf extendedTimes(UpperBound, UpperBound)) fi fi; return(new(ConfidenceInterval) withParameters(Lower, Upper, ConfidenceLevel)) . extendedMin(x, y: Real) : Real /* This method returns the minimum of x and y using the extended rules of arithmeti c for the extended Real numbers. */ if (x = nil) | (y = nil) then return(nil) else if x < y then return(x) else return(y) fi fi.

negate() : ConfidenceInterval |Lower,Upper: Real| /* This method implements the negation operation on confidence intervals. */ Lower := self extendedNegate(UpperBound); Upper := self extendedNegate(LowerBound); return(new(ConfidenceInterval) withParameters(Lower, Upper, ConfidenceLevel)) . extendedLowerLessZero() : Boolean /* This method checks whether LowerBound is less then 0.0 using the extended rules of arithmetic for the extended Real numbers. */ if LowerBound = nil then return(true) else return(LowerBound < 0.0) fi. accurate(Accuracy: Real) : Boolean |RelativeError: Real| /* This method returns whether the point estimate is sufficiently accurate with res pect to Accuracy. */ RelativeError := self getRelativeError; if RelativeError = nil then return(false) else return(RelativeError <= 1 - Accuracy) fi. *(CI: ConfidenceInterval) : ConfidenceInterval |Lower, Upper, Level: Real| /* This method implements the multiplication operation on confidence intervals. */ if self extendedLowerGreaterEqualZero then if CI extendedLowerGreaterEqualZero then Lower := self extendedTimes(LowerBound, CI Upper := self extendedTimes(UpperBound, CI else if CI extendedUpperLessZero then Lower := self extendedTimes(UpperBound, Upper := self extendedTimes(LowerBound, else Lower := self extendedTimes(UpperBound, Upper := self extendedTimes(UpperBound, fi fi else if self extendedUpperLessZero then if CI extendedLowerGreaterEqualZero then Lower := self extendedTimes(LowerBound, Upper := self extendedTimes(UpperBound,

getLowerBound); getUpperBound) CI getLowerBound); CI getUpperBound) CI getLowerBound); CI getUpperBound)

CI getUpperBound); CI getLowerBound)

else if CI extendedUpperLessZero then Lower := self extendedTimes(UpperBound, CI getUpperBound); Upper := self extendedTimes(LowerBound, CI getLowerBound) else Lower := self extendedTimes(LowerBound, CI getUpperBound); Upper := self extendedTimes(LowerBound, CI getLowerBound) fi fi else if CI extendedLowerGreaterEqualZero then Lower := self extendedTimes(LowerBound, CI getUpperBound); Upper := self extendedTimes(UpperBound, CI getUpperBound) else if CI extendedUpperLessZero then Lower := self extendedTimes(UpperBound, CI getLowerBound); Upper := self extendedTimes(LowerBound, CI getLowerBound) else Lower := self extendedMin(self extendedTimes(LowerBound, CI getUp perBound), self extendedTimes(UpperBound, CI getLowerBound)); Upper := self extendedMax(self extendedTimes(LowerBound, CI getLo werBound), self extendedTimes(UpperBound, CI getUpperBound)) fi fi fi fi; Level := ConfidenceLevel + CI getConfidenceLevel - 1; return(new(ConfidenceInterval) withParameters(Lower, Upper, Level)). printHeading() : String /* This method returns the statistics heading. */ return("Point Estimation:" tab + "Confidence Interval:" tab tab tab tab tab t ab + "Confidence Level:" tab + "Relative Error:" tab). /(CI: ConfidenceInterval) : ConfidenceInterval /* This method implements the division operation on confidence intervals. */ return(self * CI reciprocal). withParameters(Lower, Upper, Level: Real) : ConfidenceInterval /* This method initialises a confidence interval with lower bound Lower, upper boun d Upper and confidence level Level. */ LowerBound := Lower; UpperBound := Upper; ConfidenceLevel := Level; return(self). +(CI: ConfidenceInterval) : ConfidenceInterval |Lower, Upper, Level: Real| /* This method implements the addition operation on confidence intervals.

*/ Lower := self extendedPlus(LowerBound, CI getLowerBound); Upper := self extendedPlus(UpperBound, CI getUpperBound); Level := ConfidenceLevel + CI getConfidenceLevel - 1; return(new(ConfidenceInterval) withParameters(Lower, Upper, Level)). getUpperBound() : Real /* This method returns the Upper Bound. */ return(UpperBound). getRelativeError() : Real |Lower, Upper: Real| /* This method returns the relative error using the extended rules of arithmetic fo r the extended Real numbers. */ if (LowerBound = nil) | (UpperBound = nil) then return(nil) else if LowerBound > 0.0 then return((UpperBound - LowerBound) / (2 * LowerBound)) else if UpperBound < 0.0 then return((LowerBound - UpperBound) / (2 * UpperBound)) else return(nil) fi fi fi. logStatistics() : String |RelativeError: Real, LogOut: String| /* This method returns the statistics for logging purposes. */ if (LowerBound = nil) | (UpperBound = nil) then LogOut := "Not Specified" tab + "[" else LogOut := (0.5 * (LowerBound + UpperBound)) printString tab tab + "[" fi; if LowerBound = nil then LogOut append("-inf, ") else LogOut append(LowerBound printString + ", ") fi; if UpperBound = nil then LogOut append("inf]" tab) else LogOut append(UpperBound printString + "]" tab) fi; if (LowerBound = nil) & (UpperBound = nil) then LogOut tab tab tab fi; LogOut append(ConfidenceLevel printString tab tab tab);

RelativeError := self getRelativeError; if RelativeError == nil then LogOut append("inf" tab tab) else LogOut append(RelativeError printString) fi; return(LogOut). reciprocal() : ConfidenceInterval |Lower, Upper: Real| /* This method implements the reciprocal operation on confidence intervals. */ if (self Lower Upper else Lower Upper fi; . getLowerBound() : Real /* This method returns the Lower Bound. */ return(LowerBound). -(CI : ConfidenceInterval) : ConfidenceInterval /* This method implements the substraction operation on confidence intervals. */ return(self + CI negate). extendedPlus(x, y: Real) : Real /* This method returns the result of x + y using the extended rules of arithmetic f or the extended Real numbers. */ if (x = nil) | (y = nil) then return(nil) else return(x + y) fi. extendedUpperGreaterZero() : Boolean /* This method checks whether UpperBound is greater then 0.0 using the extended rul es of arithmetic for the extended Real numbers. */ if UpperBound = nil then return(true) else extendedLowerLessZero) & (self extendedUpperGreaterZero) then := nil; := nil := self extendedReciprocal(UpperBound); := self extendedReciprocal(LowerBound)

return(new(ConfidenceInterval) withParameters(Lower, Upper, ConfidenceLevel))

return(UpperBound > 0.0) fi. extendedMax(x, y: Real) : Real /* This method returns the maximum of x and y using the extended rules of arithmeti c for the extended Real numbers. */ if (x = nil) | (y = nil) then return(nil) else if x > y then return(x) else return(y) fi fi. extendedTimes(x, y: Real) : Real /* This method returns the result of x * y using the extended rules of arithmetic f or the extended Real numbers. */ if (x = nil) | (y = nil) then return(nil) else return(x * y) fi. extendedLowerGreaterEqualZero() : Boolean /* This method checks whether LowerBound is greater or equal to 0.0 using the exten ded rules of arithmetic for the extended Real numbers. */ if LowerBound = nil then return(false) else return(LowerBound >= 0.0) fi. help() : Object /* This class implements an algebra of Confidence Intervals based on the extended r eal numbers and is used by the PerformanceMonitor classes. Each interval is characterized by a LowerBound and an UpperBound. If the LowerBo und is nil, it is assumed to be negatively infinite. If the UpperBound is nil, i t is assumed to be infinite. The ConfidenceLevel denotes the level of confidence of the interval. The following operators + negate sqr * reciprocal / are defined on confidence intervals: Addition Negation Substraction Raising to the square Multiplication Reciprocal Devision

*/ return(nil). printString() : String /* This method enables to display the statistics */ return(self printHeading cr append(self printStatistics)). extendedUpperLessZero() : Boolean /* This method checks whether UpperBound is less then 0.0 using the extended rules of arithmetic for the extended Real numbers. */ if UpperBound = nil then return(false) else return(UpperBound < 0.0) fi. extendedNegate(x: Real) : Real /* This method returns the result of -x using the extended rules of arithmetic for the extended Real numbers. */ if x = nil then return(nil) else return(-x) fi. getConfidenceLevel() : Real /* This method returns the Confidence Level. */ return(ConfidenceLevel). printStatistics() : String |RelativeError: Real, PrintOut: String| /* This method returns the statistics. */ if (LowerBound = nil) | (UpperBound = nil) then PrintOut := "Not Specified" tab tab + "[" else PrintOut := (0.5 * (LowerBound + UpperBound)) printString tab + "[" fi; if LowerBound = nil then PrintOut append("-inf, ") else PrintOut append(LowerBound printString + ", ") fi; if UpperBound = nil then PrintOut append("inf]" tab) else

PrintOut append(UpperBound printString + "]" tab) fi; if (LowerBound = nil) & (UpperBound = nil) then PrintOut := PrintOut tab tab tab tab tab tab tab tab fi; PrintOut append(ConfidenceLevel printString tab tab tab tab tab); RelativeError := self getRelativeError; if RelativeError = nil then PrintOut append("inf" tab tab tab tab) else PrintOut append(RelativeError printString) fi; return(PrintOut). extendedReciprocal(x: Real) : Real /* This method returns the result of 1/x using the extended rules of arithmetic for the extended Real numbers. */ if x = nil then return(0.0) else if x = 0.0 then return(nil) else return(1 / x) fi fi.

process class Task8(DesiredLatency: Real, DesiredThroughput: Real, Iterate: Bool ean, MapsToNode: Char, Name: String, PriorityAssignment: Integer) extends Task instance variables Status: ApplicationStatus initial method call Initialise()() instance methods NotifyBuffersAboutMapping()() par In1!MappedTo(MapTo) and In2!MappedTo(MapTo) and Out!MappedTo(MapTo) and Control!MappedTo(MapTo) rap. ReserveSpaceForWrites(Scenario: String)() Out!ReserveRoom(1); Out?ReservationSuccessful.

Fire()() |Scenario: String| Control!InspectTokenAvailability; Control?TokenAvailable(Scenario); CheckTokenAvailabilityForReads(Scenario)(); ReserveSpaceForWrites(Scenario)(); Execute(Scenario)(); ReleaseSpaceForReads(Scenario)(); PerformWrites(Scenario)(); Control!ReleaseRoom; Status fired(currentTime); Fire()(). PerformWrites(Scenario: String)() Out!WriteTokens. Initialise()() |temp: String| temp := "Node"; temp := temp + "#"; temp put(5,MapsToNode); MapTo := temp; Priority := PriorityAssignment modulo(10); NotifyBuffersAboutMapping()(); NotifyPlatformAboutMapping()(); Status := new(ApplicationStatus) init(DesiredLatency, DesiredThroughput); Monitor!Iterate(Iterate); abort par Fire()() and CheckAccuracyStatus()() rap with Monitor?StopSimulation{Status log}. ReleaseSpaceForReads(Scenario: String)() if Scenario = "S1" then In1!ReleaseRoom fi; In2!ReleaseRoom. CheckAccuracyStatus()() Monitor?ApplicationStatus; Monitor!ApplicationAccuracyStatus(Status accurate); CheckAccuracyStatus()(). CheckTokenAvailabilityForReads(Scenario: String)() if Scenario = "S1" then In1!InspectTokenAvailability(1024); In1?TokensAvailable fi;

In2!InspectTokenAvailability(2048); In2?TokensAvailable.

process class Task5(MapsToNode: Char, Name: String, PriorityAssignment: Integer) extends Task instance variables initial method call Initialise()() instance methods NotifyBuffersAboutMapping()() par In!MappedTo(MapTo) and Out!MappedTo(MapTo) and Control!MappedTo(MapTo) rap. CheckTokenAvailabilityForReads(Scenario: String)() In!InspectTokenAvailability(4096); In?TokensAvailable. ReleaseSpaceForReads(Scenario: String)() In!ReleaseRoom. PerformWrites(Scenario: String)() Out!WriteTokens. ReserveSpaceForWrites(Scenario: String)() Out!ReserveRoom(4096); Out?ReservationSuccessful.

process class DataBuffer(Name: String, NumberOfInitialTokens: Integer, TokenSize : Integer) instance variables MapTo: String, TransferID: Integer, Status: DataBufferMonitor initial method call Initialise()() instance methods NotifyPlatformAboutMapping()() Communication!Use(MapTo). HandleOutput()() |NumberOfTokens: Integer|

Out?InspectTokenAvailability(NumberOfTokens | Status available(NumberOfTokens)); Out!TokensAvailable; Out?ReleaseRoom; Communication!ReleaseRoom(MapTo, NumberOfTokens, TokenSize){Status remove(Number OfTokens, currentTime)}; HandleOutput()(). DetermineMapping()() |InputTask, OutputTask: String| In?MappedTo(InputTask); Out?MappedTo(OutputTask); if InputTask = OutputTask then MapTo := InputTask else MapTo := "NoC" fi. HandleInput()() |NumberOfTokens, ID: Integer, Scenario, Connection: String| In?ReserveRoom(NumberOfTokens | Status room(NumberOfTokens)); Communication!ReserveRoom(Name, MapTo, NumberOfTokens, TokenSize); Communication?TransferInitiated(Connection | Connection = Name){Status reserve(N umberOfTokens, currentTime)}; In!ReservationSuccessful; In?WriteTokens{TransferID := TransferID + 1}; par Communication!Transfer(Name, MapTo, TransferID); Communication?TransferCompleted(Connection, ID | (Connection = Name) & (ID = TransferID)){Status write(NumberOfTokens)} and HandleInput()() rap. Initialise()() TransferID := 0; Status := new(DataBufferMonitor) init(Name, -1, NumberOfInitialTokens, TokenSize , false, false); DetermineMapping()(); NotifyPlatformAboutMapping()(); if NumberOfInitialTokens > 0 then Communication!InitialiseTokens(MapTo, NumberOf InitialTokens, TokenSize) fi; par HandleInput()() and HandleOutput()() rap.

cluster class ProcessorNode(CommunicationBandwidth: Real, ConnectionSetUpLatency : Real, NodeName: String, OSPolicy: String, PowerPerActiveConnection: Real, Powe rPerStoredByte: Real, ProcessorType: String, VoltageScaleFactor: Real) behaviour specification (OperatingSystem: OperatingSystem(NodeName, OSPolicy)[ScheduledTask/Processor, C omputations/Task] || InterConnect: CommunicationUnit(CommunicationBandwidth, Con nectionSetUpLatency, NodeName, PowerPerActiveConnection)[Communications/Communic ations, BufferMemory/Memory, Power/Power, Monitor/Monitor] || BufferMemory: Stor

ageUnit(PowerPerStoredByte)[Monitor/Monitor, Power/Power, BufferMemory/Access] | | Processor: ProcessingUnit(NodeName, ProcessorType, VoltageScaleFactor)[DataMem ory/Memory, ScheduledTask/OS, Power/Power, Monitor/Monitor] || DataMemory: Stora geUnit(PowerPerStoredByte)[Monitor/Monitor, Power/Power, DataMemory/Access])\{Sc heduledTask, BufferMemory, DataMemory}

data class Set extends Object instance variables Elements: Dictionary instance methods add(e: Object) : Set Elements atPut(e, nil); return(self). printString() : String |i: Integer, k: Array, s: String| k := Elements keys; i := 1; s := "{"; while i <= k getSize do s := s + k get(i) printString; if i < k getSize then s := s + ", " fi; i := i + 1 od; s := s + "}"; return(s). init(): Set Elements := new(Dictionary) init(); return(self). remove(e: Object) : Set if Elements includesKey(e) then Elements removeKey(e); return(self) else self error("Element " + e printString + " not in Set") fi. includes(e: Object) : Boolean return(Elements includesKey(e)).

process class StorageUnit(PowerPerByte: Real) instance variables Status: MemoryStatus initial method call Initialise()()

instance methods Initialise()() |InUse: Boolean| Access?Use(InUse); if InUse then Status := new(MemoryStatus) init; abort par HandleAccesses()() and CheckAccuracyStatus()() rap with Monitor?StopSimulation; Access!SimulationResults(Status logString) fi. HandleAccesses()() |NumberOfBytes: Integer| sel Access?Allocate(NumberOfBytes){Status allocate(NumberOfBytes, currentTime)}; Power!StartConsumption(PowerPerByte * NumberOfBytes) or Access?Free(NumberOfBytes){Status free(NumberOfBytes, currentTime)}; Power!StopConsumption(PowerPerByte * NumberOfBytes) les; HandleAccesses()(). CheckAccuracyStatus()() Access?Status; Access!AccuracyStatus(Status accurate); CheckAccuracyStatus()().

data class LongRunTimeAverage extends PerformanceMonitor instance variables PreviousReward: Real, LastTime: Real, AverageRewardTimeProduct: LongRunSampleAve rage, AverageTime: LongRunSampleAverage instance methods getCurrentLength() : Integer /* Returns the length of the current cycle for the Long Run Time Average. This methid is only used for other complex long-run average performance metrics. */ return(AverageRewardTimeProduct getCurrentLength). setBatchSize(m: Integer) : LongRunTimeAverage /* This method initialises the size of the batches for the batch-means technique. */ if m > 0 then BatchSize := m; AverageRewardTimeProduct setBatchSize(BatchSize); AverageTime setBatchSize(BatchSize)

else self error("BatchSize parameter for Long Run Time Average must be larger t han 0") fi; return(self). rewardBM(Reward, CurrentTime: Real) : LongRunTimeAverage /* Implementing the technique of batch-means, this method processes a reward for th e Long Run Time Average. */ self rewardRC(Reward, CurrentTime, (AverageRewardTimeProduct getCurrentLength = 0) | (AverageRewardTimeProduct getCurrentLength = BatchSize)); return(self). help() : Object /* An instance of this class represents a monitor for Long Run Time Average perform ance metrics. For more information on the use of this class, see the superclass PerformanceMon itor. */ return(nil). withParameters(A, CL: Real) : LongRunTimeAverage /* This method initialises the accuracy A and confidence level CL for a Long Run Ti me Average, where A and CL must be a Real within the interval [0.0, 1.0). */ if (A <= 0.0) | (A >= 1.0) then self error("Accuracy parameter for Long Run Time Average must be within th e interval (0.0, 1.0)") fi; Accuracy := A; self withConfidenceLevel(CL); return(self). getIntervalEstimation() : ConfidenceInterval /* Returns the confidence interval for the Long Run Time Average. This methid is only used for other complex long run average performance metrics. */ return(IntervalEstimation). withConfidenceLevel(CL: Real) : LongRunTimeAverage /* Initialises the confidence level CL for a Long Run Time Average, where CL must b e a Real within the interval [0.0, 1.0). */ if (CL < 0.0) | (CL >= 1.0) then self error("ConfidenceLevel parameter for Long Run Time Average must be wi

thin the interval [0.0, 1.0)") fi; ConfidenceLevel := CL; AverageRewardTimeProduct := new(LongRunSampleAverage) withConfidenceLevel((Co nfidenceLevel + 1) / 2); AverageTime := new(LongRunSampleAverage) withConfidenceLevel((ConfidenceLevel + 1) / 2); IntervalEstimation := (AverageRewardTimeProduct getIntervalEstimation) / (Ave rageTime getIntervalEstimation); self setDefaultBatchSize(); return(self). rewardRC(Reward, CurrentTime: Real, RecurrenceCondition: Boolean) : LongRunTimeA verage /* Implementing the technique of regenerative cycles, this method processes a rewar d for the Long Run Time Average. */ if LastTime != nil then AverageRewardTimeProduct rewardRC(PreviousReward * (CurrentTime - LastTime ), RecurrenceCondition); AverageTime rewardRC(CurrentTime - LastTime, RecurrenceCondition) fi; PreviousReward := Reward; LastTime := CurrentTime; if RecurrenceCondition then IntervalEstimation := (AverageRewardTimeProduct getIntervalEstimation) / ( AverageTime getIntervalEstimation) fi; return(self). printHeading() : String /* This method displays the heading for the Long Run Time Average. */ if Accuracy = nil then /* Only used for other complex long run average performance metrics. */ return("Statistics for Long Run Time Average") else return("Statistics for Long Run Time Average with Accuracy " append(Accura cy printString)) fi. logTo(Name: String) : LongRunTimeAverage /* This method initialises the Log File for the Long Run Time Average. The Log File will have the name "Name.log", where the extension ".log" is appended automatic ally. */ LogFile := new(FileOut) destination(Name + ".log") open; LogFile writeString("Statistics for the Long Run Time Average " append(Name p rintString) append(" with Accuracy ") append(Accuracy printString) cr cr);

LogFile writeString(IntervalEstimation logHeading append(" Accurate :") cr); LogFile writeString("------------------------------------------------------------------------------------------------------------------------" cr); LogFile close; return(self).

process class OperatingSystem(NodeName: String, Policy: String) instance variables Status: SchedulerStatus initial method call Initialise()() instance methods Initialise()() |MapTo: String, InUse: Boolean| InUse := false; abort while true do Task?Use(MapTo | MapTo = NodeName){InUse := true} od with de lay(1.0e-12); Processor!Use(InUse); if InUse then Status := new(SchedulerStatus) init(Policy); Schedule()() fi. Schedule()() |Task, Scenario, MapToNode: String, Priority, NumberOfWaitingTasks: Integer, NewTask, OldTask: ScheduledTask| sel Task?Execute(Task, Scenario, Priority, MapToNode | MapToNode = NodeName){NewT ask := Status registerTask(Task, Scenario, Priority)}; if Status nextTaskToSchedule == NewTask then sel Processor!Execute(NewTask) /* No other Task is being executed */ or Processor!Preempt; /* Preempt running Task */ Processor?Stopped(OldTask){Status updateTask(OldTask)}; Processor!Execute(NewTask) les fi or Processor?Stopped(OldTask){NumberOfWaitingTasks := Status removeTask(OldTask) }; Task!ExecutionCompleted(OldTask getName); if NumberOfWaitingTasks > 0 then /* Run the next available Task */ Processor!Execute(Status nextTaskToSchedule) fi les; Schedule()().

data class Dictionary extends Object instance variables Occupation: Integer, MaxSize: Integer, KeyList: Array, ValueList: Array instance methods includesKey(Key: Object) : Boolean /* Returns true if Key is a key in the dictionary, and returns false otherwise * / return(self find(Key) != 0). keys() : Array /* Returns an array with all the Keys stored in the dictionary. (NOTE: the Keys are not copied) */ return(KeyList shallowCopy). removeKey(Key: Object) : Object |Index: Integer, Value: Object| /* Removes the Key and Value in this dictionary and returns the Value associated with Key. If the Key is not found, it returns nil */ Index := self find(Key); if Index == 0 then return(nil) else Value := ValueList get(Index); Store Value before it is deleted */ KeyList put(Index, KeyList get(Occupation)) put(Occupation, nil); Move the Key and Value at the last position to Index */ ValueList put(Index, ValueList get(Occupation)) put(Occupation, nil); Occupation := Occupation - 1; Update the occupation of this dictionary */ if (Occupation < MaxSize div(2)) & (MaxSize > 1) then If less then half is occupied, shrink this dictionary by two */ MaxSize := MaxSize div(2); KeyList size(MaxSize); ValueList size(MaxSize) fi; return(Value) fi.

/* /* /* /*

help() : Object /* This class implements a dictionary. With "atput()" you can add keys (any Object) and store a value (also any Object) along with it. Retrieving the value stored at a certain key can be done with "at()". The order in which keys are stored can and will change during the lifetime of an instance of Dictionary. The same applies to the values. Warning: do not use method find(), this method is only used by the implementatio n and as

the implementation can be changed at any time, you should not rely on this metho d. */ return(nil). at(Key: Object) : Object |Index: Integer| /* Returns the value stored at Key. If the key is not found, it returns nil */ Index := self find(Key); if Index == 0 then return(nil) else return(ValueList get(Index)) fi. find(Key: Object) : Integer |Index: Integer, notFound: Boolean| /* Returns the non-zero index if Key is present in KeyList. If Key is not found, it returns 0. This method is merely used by other methods of this class */ Index := Occupation; notFound := true; while notFound & (Index > 0) do notFound := KeyList get(Index) != Key; Index := Index - 1 od; if notFound then return(0) else return(Index + 1) fi. init() : Dictionary /* Initialises a dictionary */ MaxSize := 1; Occupation := 0; KeyList := new(Array) size(MaxSize); ValueList := new(Array) size(MaxSize); values */ return(self). values() : Array /* Returns an array with all the Values stored in this dictionary. (NOTE: the Va lues are not copied) */ return(ValueList shallowCopy). printString() : String |Index: Integer, PrintOut: String| /* Displays the contents of the dictionary */ if Occupation == 0 then return("Empty") else

/* this list stores the keys */ /* this list stores the

Index := 1; PrintOut := ""; while Index <= Occupation do PrintOut append("[") append(KeyList get(Index) printString) append(", " ) append(ValueList get(Index) printString) append("] "); Index := Index + 1 od; return(PrintOut) fi. atPut(Key, Value: Object) : Dictionary |Index: Integer| /* Sets the value at Key to be Value. If Key is not found, creates a new entry. Returns this dictionary */ Index := self find(Key); /* Find the index of Key in the internal List */ if Index == 0 then /* Index == 0 iff Key has not be en found */ Occupation := Occupation + 1; Index := Occupation; /* Use the next free position in List */ if Occupation > MaxSize then /* Double the size of List if there is n ot enough space to store the new key */ MaxSize := MaxSize * 2; KeyList size(MaxSize); ValueList size(MaxSize) fi; KeyList put(Index, Key) /* Add the new key to the key li st */ fi; ValueList put(Index, Value); return(self). occupation: Integer /* Returns the number of keys stored in the dictionary */ return(Occupation).

data class LongRunSampleVariance extends PerformanceMonitor instance variables AverageSquaredReward: LongRunSampleAverage, AverageReward: LongRunSampleAverage instance methods setBatchSize(m: Integer) : LongRunSampleVariance /* This method initialises the size of the batches for the batch-means technique. */ if m > 0 then BatchSize := m; AverageReward setBatchSize(BatchSize); AverageSquaredReward setBatchSize(BatchSize) else

self error("BatchSize parameter for Long Run Sample Variance must be large r than 0") fi; return(self). rewardBM(Reward: Real) : LongRunSampleVariance /* Implementing the technique of batch-means, this method processes a reward for th e Long Run Sample Variance. */ self rewardRC(Reward, (AverageReward getCurrentLength = 0) | (AverageReward g etCurrentLength = BatchSize)); return(self). help() : Object /* An instance of this class represents a monitor for Long Run Sample Variance perf ormance metrics. For more information on the use of this class, see the superclass PerformanceMon itor. */ return(nil). withParameters(A, CL: Real) : LongRunSampleVariance /* This method initialises the accuracy A and confidence level CL for a Long Run Sa mple Variance, where A and CL must be a Real within the interval [0.0, 1.0). */ if (A <= 0.0) | (A >= 1.0) then self error("Accuracy parameter for Long Run Sample Variance must be within the interval (0.0, 1.0)") fi; Accuracy := A; if (CL < 0.0) | (CL >= 1.0) then self error("ConfidenceLevel parameter for Long Run Sample Variance must be within the interval [0.0, 1.0)") fi; ConfidenceLevel := CL; AverageReward := new(LongRunSampleAverage) withConfidenceLevel((ConfidenceLev el + 1) / 2); AverageSquaredReward := new(LongRunSampleAverage) withConfidenceLevel((Confid enceLevel + 1) / 2); IntervalEstimation := (AverageSquaredReward getIntervalEstimation) - ((Averag eReward getIntervalEstimation) sqr); self setDefaultBatchSize(); return(self). rewardRC(Reward: Real, RecurrenceCondition: Boolean) : LongRunSampleVariance /* Implementing the technique of regenerative cycles, this method processes a rewar d for the Long Run Sample Variance.

*/ AverageReward rewardRC(Reward, RecurrenceCondition); AverageSquaredReward rewardRC(Reward * Reward, RecurrenceCondition); if RecurrenceCondition then IntervalEstimation := (AverageSquaredReward getIntervalEstimation) - ((Ave rageReward getIntervalEstimation) sqr) fi; return(self). printHeading() : String /* This method displays the heading for the Long Run Sample Variance. */ return("Statistics for Long Run Sample Variance with Accuracy " append(Accura cy printString)). logTo(Name: String) : LongRunSampleVariance /* This method initialises the Log File for the Long Run Sample Variance. The Log F ile will have the name "Name.log", where the extension ".log" is appended automa tically. */ LogFile := new(FileOut) destination(Name + ".log") open; LogFile writeString("Statistics for the Long Run Sample Variance " append(Nam e printString) append(" with Accuracy ") append(Accuracy printString) cr cr); LogFile writeString(IntervalEstimation logHeading() append(" Accurate :") cr); LogFile writeString("------------------------------------------------------------------------------------------------------------------------" cr); LogFile close; return(self).

cluster class Platform(NoC_BandwidthPerConnection: Real, NoC_ConnectionSetUpLate ncy: Real, Node_InternalBandwidth: Real, Node_InternalConnectionSetUpLatency: Re al, PowerPerActiveConnection: Real, PowerPerStoredByte: Real, Proc1: String, Pro c2: String, Proc3: String, Proc4: String) behaviour specification (Node3: ProcessorNode(Node_InternalBandwidth, Node_InternalConnectionSetUpLatenc y, "Node3", "PB", PowerPerActiveConnection, PowerPerStoredByte, Proc3, 1/1)[Comp utations/Computations, Communications/Communications, Power/Power, Monitor/Monit or] || Node1: ProcessorNode(Node_InternalBandwidth, Node_InternalConnectionSetUp Latency, "Node1", "PB", PowerPerActiveConnection, PowerPerStoredByte, Proc1, 1/1 )[Computations/Computations, Communications/Communications, Power/Power, Monitor /Monitor] || Node4: ProcessorNode(Node_InternalBandwidth, Node_InternalConnectio nSetUpLatency, "Node4", "PB", PowerPerActiveConnection, PowerPerStoredByte, Proc 4, 1/1)[Computations/Computations, Communications/Communications, Power/Power, M onitor/Monitor] || Node2: ProcessorNode(Node_InternalBandwidth, Node_InternalCon nectionSetUpLatency, "Node2", "PB", PowerPerActiveConnection, PowerPerStoredByte , Proc2, 1/1)[Computations/Computations, Communications/Communications, Power/Po wer, Monitor/Monitor] || NoC: NetworkOnChip(NoC_BandwidthPerConnection, NoC_Conn ectionSetUpLatency, "NoC", PowerPerActiveConnection, PowerPerStoredByte)[Monitor

/Monitor, Power/Power, Communications/Communications] || PlatformMonitor: Platfo rmMonitor[SimulationController/SimulationController, Monitor/Monitor] || Battery : EnergySource[Power/Power, Monitor/Monitor])\{Monitor, Power}[CommunicationReso urces/Communications, ComputationResources/Computations]

data class PlatformStatus extends Object instance variables Monitors: Array, Accuracies: Array instance methods getNumberOfMonitors() : Integer return(Accuracies getSize()). accurate : Boolean |i: Integer, Accurate: Boolean| Accurate := true; i := 1; while Accurate & (i <= Accuracies getSize) do Accurate := Accurate & Accuracies get(i); i := i + 1 od; return(Accurate). getMonitor(ID: Integer) : String return(Monitors get(ID)). init : PlatformStatus Accuracies := new(Array); Monitors := new(Array); return(self). printString : String |i: Integer, PrintOut: String| PrintOut := "Accuracy Status for Monitors at the following Components" cr cr; i := 1; while i <= Monitors getSize do PrintOut := PrintOut + Monitors get(i) printString + ": " + Accuracies g et(i) printString cr; i := i + 1 od; return(PrintOut). register(ID: Integer, Accurate: Boolean) : PlatformStatus Accuracies put(ID, Accurate); return(self). addMonitor(Name: String) : PlatformStatus |i: Integer| i := Accuracies getSize + 1; Monitors size(i); Accuracies size(i); Monitors put(i, Name); Accuracies put(i, false); return(self).

process class ControlBuffer(Name: String, TokenSize: Integer) instance variables MapTo: String, TransferID: Integer, Status: ControlBufferMonitor initial method call Initialise()() instance methods NotifyPlatformAboutMapping()() Communication!Use(MapTo). HandleOutput()() [Status available]Out?InspectTokenAvailability; Out!TokenAvailable(Status inspect); Out?ReleaseRoom; Communication!ReleaseRoom(MapTo, 1, 1){Status remove(currentTime)}; HandleOutput()(). DetermineMapping()() |InputTask, OutputTask: String| In?MappedTo(InputTask); Out?MappedTo(OutputTask); if InputTask = OutputTask then MapTo := InputTask else MapTo := "NoC" fi. HandleInput()() |NumberOfTokens, ID: Integer, Scenario, Connection: String| In?ReserveRoom(NumberOfTokens | Status room(NumberOfTokens)); Communication!ReserveRoom(Name, MapTo, NumberOfTokens, TokenSize); Communication?TransferInitiated(Connection | Connection = Name){Status reserve(N umberOfTokens, currentTime)}; In!ReservationSuccessful; In?WriteTokens(Scenario){TransferID := TransferID + 1}; par Communication!Transfer(Name, MapTo, TransferID); Communication?TransferCompleted(Connection, ID | (Connection = Name) & (ID = TransferID)){Status write(NumberOfTokens, Scenario)} and HandleInput()() rap. Initialise()() TransferID := 0; Status := new(ControlBufferMonitor) init(Name, -1, new(Queue) init, new(Queue) i nit, TokenSize, false, false); DetermineMapping()(); NotifyPlatformAboutMapping()(); par HandleInput()() and HandleOutput()() rap.

process class SimulationController(AccuracyCheckInterval: Real, MaximumSimulatio nTime: Real) instance variables Status: Array initial method call Initialise()() instance methods CheckAccuracyStatus()() |Accurate: Boolean| delay(AccuracyCheckInterval); Monitor!ApplicationStatus; Monitor?ApplicationAccuracyStatus(Accurate){Status put(1, Accurate)}; Monitor!PlatformStatus; Monitor?PlatformAccuracyStatus(Accurate){Status put(2, Accurate)}; if (Status get(1) & Status get(2)) not then CheckAccuracyStatus()() fi. Initialise()() |Iterate: Boolean| Monitor?Iterate(Iterate); Status := new(Array) size(2); if Iterate then abort CheckAccuracyStatus()() with delay(MaximumSimulationTime) else delay(MaximumSimulationTime) fi; abort while true do Monitor!StopSimulation od with delay(1.0e-12).

data class Distribution extends Object instance variables Random: RandomGenerator instance methods initialise() : Distribution /* Initialises the RandomGenerator Random. This method is only used in the subclass es. */ Random := new(RandomGenerator) randomiseSeed; return(self). printString() : String /* This method displays information about the distribution. */ return("Unspecified Distribution"). ofType(Type: String) : Distribution /*

This method returns an object representing a distribution of one of the followin g types: - "Bernoulli" " for the parameter Type - "DiscreteUniform" returns form" for the parameter Type - "Exponential" returns or the parameter Type - "Normal" the parameter Type - "Uniform" r the parameter Type */ returns a Bernoulli distribution, use "Bernoulli a Dicrete Uniform distribution, use "DiscreteUni an Exponential distribution, use "Exponential" f returns a Normal distribution, use "Normal" for returns a Uniform distribution, use "Uniform" fo

if Type = "Bernoulli" then return(new(Bernoulli)) else if Type = "DiscreteUniform" then return(new(DiscreteUniform)) else if Type = "Exponential" then return(new(Exponential)) else if Type = "Normal" then return(new(Normal)) else if Type = "Uniform" then return(new(Uniform)) else self error("Unknown Distribution Type") fi fi fi fi fi. help() : Object /* This class is an abstract superclass of the subclasses Bernoulli, DiscreteUnifor m, Exponential, Normal and Uniform. To obtain a distribution of a specific type, use the method *** MANDATORY *** ofType("DistributionType") where "DistributionType" is one of the following: "Bernoulli" "DiscreteUniform" "Exponential" "Normal" "Uniform" returns a Bernoulli distribution returns a Dicrete Uniform distribution returns an Exponential distribution returns a Normal distribution returns a Uniform distribution

To initialise parameter(s) for a distribution, use the method *** MANDATORY *** - Bernoulli distribution withParameter(SuccessProbability) where Su ccessProbability denotes the success probability, which must be a Real within th e interval [0.0, 1.0].

- Discrete Uniform distribution withParameter(LowerBound, UpperBound) where the Integers Lower Bound and UpperBound are the bounds of the discrete interval [LowerBound, UpperB ound] in which the sample values are. Notice that LowerBound must be smaller then or equal to Upperbound. - Exponential distribution withParameter(Lambda) where Lambda denotes the reciprocal of the expected value for the Exponential di stribution, which must be a Real different from 0.0. - Normal distribution withParameters(Mean, Variance) where th e Mean and Variance are respectively the mean and variance of the Normal distrib ution and must be Reals. - Uniform distribution withParameter(LowerBound, UpperBound) where the LowerBound and UpperBound are the Real bounds of the interval (LowerBound, UpperBound) in whic h the sample values are. Notice that LowerBound must be smaller then Upperbound. To obtain a sample value for a distribution, use the method sample() */ return(nil).

process class EnergySource() instance variables Status: BatteryStatus initial method call Initialise()() instance methods Initialise()() Status := new(BatteryStatus) init; Monitor!InitialiseMonitor("Battery"); abort par HandleConsumptions()() and CheckAccuracyStatus()() rap with Monitor?StopSimulation{Status log}. HandleConsumptions()() |Power: Real| sel Power?StartConsumption(Power){Status startConsumption(Power, currentTime)} or Power?StopConsumption(Power){Status stopConsumption(Power, currentTime)} les;

HandleConsumptions()(). CheckAccuracyStatus()() |ID: String| Monitor?Status(ID | ID = "Battery"); Monitor!AccuracyStatus(Status accurate); CheckAccuracyStatus()().

process class Task4(MapsToNode: Char, Name: String, PriorityAssignment: Integer) extends Task instance variables initial method call Initialise()() instance methods Execute(Scenario: String)() |N: String| if Scenario = "S1" then Computation!Execute(Name, Scenario, Priority, MapTo); Computation?ExecutionCompleted(N | N = Name) fi. ReserveSpaceForWrites(Scenario: String)() if Scenario = "S1" then Out!ReserveRoom(4096); Out?ReservationSuccessful fi. NotifyBuffersAboutMapping()() par In!MappedTo(MapTo) and Out!MappedTo(MapTo) and Control!MappedTo(MapTo) rap. PerformWrites(Scenario: String)() if Scenario = "S1" then Out!WriteTokens fi. ReleaseSpaceForReads(Scenario: String)() if Scenario = "S1" then In!ReleaseRoom fi. CheckTokenAvailabilityForReads(Scenario: String)() if Scenario = "S1" then In!InspectTokenAvailability(2048);

In?TokensAvailable fi.

/* Data part */ data class Object instance variables instance methods error(ErrorMessage: String): Object primitive. deepCopy: Object primitive. = (Operand2: Object): Boolean primitive. != (Operand2: Object): Boolean primitive. == (Operand2: Object): Boolean primitive. !==(Operand2: Object): Boolean primitive. printString: String primitive. shallowCopy: Object primitive. /* Abstract superclass of Integer and Real. */ data class Number extends Object instance variables instance methods /* Definition of primitive classes */ data class Integer extends Object instance variables instance methods + (Operand2: Number): Number primitive. / (Operand2: Number): Number primitive. * (Operand2: Number): Number primitive. - (Operand2: Number): Number primitive. < (Operand2: Number): Boolean primitive. > (Operand2: Number): Boolean primitive. <= (Operand2: Number): Boolean primitive. >= (Operand2: Number): Boolean primitive. unaryMinus: Integer primitive. abs: Integer primitive. & (Operand2: Integer): Integer primitive. | (Operand2: Integer): Integer primitive. not: Integer primitive. sqrt: Number primitive. power(Operand2: Number): Number primitive. sqr: Integer primitive. div(Operand2: Integer): Integer primitive. modulo(Operand2: Number): Number primitive. asInteger: Integer primitive. asReal: Real primitive. asString: String primitive.

printString: String primitive. fac: Integer primitive. monus(n: Integer): Integer if n > self then 0 else self - n fi. data class Real extends Object instance variables instance methods + (Operand2: Number): Real primitive. / (Operand2: Number): Real primitive. * (Operand2: Number): Real primitive. - (Operand2: Number): Real primitive. < (Operand2: Number): Boolean primitive. > (Operand2: Number): Boolean primitive. <= (Operand2: Number): Boolean primitive. >= (Operand2: Number): Boolean primitive. unaryMinus: Real primitive. acos: Real primitive. asin: Real primitive. atan: Real primitive. atan2(Denom: Real): Real primitive. nom). cos: Real primitive. sin: Real primitive. tan: Real primitive. abs: Real primitive. log: Real primitive. ln: Real primitive. sqrt: Real primitive. exp: Real primitive. power(Operand2: Number): Real primitive. sqr: Real primitive. ceiling: Integer primitive. floor: Integer primitive. round: Integer primitive. div(Operand2: Number): Integer primitive. modulo(Operand2: Number): Real primitive. ulo Operand2 < Operand2. asInteger: Integer primitive. nearest integer value asReal: Real primitive. asString: String primitive. printString: String primitive. primitive data class Boolean extends Object instance variables instance methods & (Operand2: Boolean): Boolean primitive. | (Operand2: Boolean): Boolean primitive. not: Boolean primitive. // 0 <= self mod // Rounds to the

// Computes atan(self/de

printString: String primitive. primitive data class Char extends Object instance variables instance methods printString: String primitive. /* End of definition of primitive classes */ primitive data class Array extends Object instance variables instance methods get(FromPosition: Integer): Object primitive. getSize: Integer primitive. size(newSize: Integer): Array primitive. printString: String | i, s: Integer, Str: String | Str := "Array ("; i := 0; s := self getSize; while i < s do Str append(self get(i := i + 1) printString) appe nd(if i < s then "," else ")" fi) od; Str. put(AtPosition: Integer, Element: Object): Array primitive. putAll(Element: Object): Array primitive. primitive data class String extends Object instance variables instance methods + (aString: String): String primitive. // Same as concat. < (Operand2: String): Boolean primitive. > (Operand2: String): Boolean primitive. <= (Operand2: String): Boolean primitive. >= (Operand2: String): Boolean primitive. append(aString: String): String primitive. copy(From, To: Integer): String primitive. // Returns a copy of the substring. concat(aString: String): String primitive. // Same as +. cr: String primitive. get(FromPosition: Integer): Char primitive. length: Integer primitive. printString: String primitive. put(AtPosition: Integer, aChar: Char): String primitive. tab: String primitive. primitive data class RandomGenerator extends Object instance variables instance methods random: Real primitive. l between (0, 1). randomInt(n: Integer): Integer primitive. teger between [0, n). randomiseSeed: RandomGenerator primitive. setSeed(aSeed: Integer): RandomGenerator primitive.

// Returns a rea // Returns an in

primitive data class FileOut extends Object instance variables instance methods append: FileOut primitive. destination(FileName: String): FileOut primitive. close: Object primitive. open: FileOut primitive. write(anObject: Object): FileOut self writeString(anObject printString append(' ')). writeln(anObject: Object): FileOut self writeString(anObject printString cr). writeString(aString: String): FileOut primitive. primitive data class FileIn extends Object instance variables instance methods open: FileIn primitive. close: Object primitive. readString: String primitive. readInteger: Integer primitive. readNumber: Object primitive. readReal: Real primitive. readBoolean: Boolean primitive. readChar: Char primitive. source(FileName: String): FileIn primitive.

You might also like