mode5

Embed Size (px)

Citation preview

  • 7/30/2019 mode5

    1/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", "TriMedia", "MIPS", "ARM11")[Monitor/SimulationController, Communication/CommunicationResources, Computation/ComputationResources] || Application: Application(1/300,500, false,"44444444"_, 12345678, "S2")[Monitor/SimulationController, Computation/Tasks, Communication/Buffers])\{Communication, Computation, Monitor}

    data class BatteryStatusextends Objectinstance variablesObservedAveragePower: Real, PreviousUpdateTime: Real, AveragePower: LongRunTimeAverage, Power: Real, PeakPower: Real, NumberOfSamples: Integer, ObservedAverageTime: Real

    instance methodsaccurate : 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) thenLogFile writeString("Observed Average Power: " + (ObservedAveragePower / Obser

    vedAverageTime) printString + " Watts")elseLogFile 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" crcr + "Peak Power Consumption: " + PeakPower printString + " Watts" cr cr;if (NumberOfSamples < 20000) then

  • 7/30/2019 mode5

    2/74

    PrintString := PrintString + "Observed Average Power: " + (ObservedAveragePower / ObservedAverageTime) printString + " Watts"elsePrintString := PrintString + "Statistics for Average Power Consumption:" cr +

    AveragePower printStatisticsfi;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 - PreviousUpdateTime) / 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 - PreviousUpdateTime) / NumberOfSamples;PreviousUpdateTime := CurrentTime;

    Power := Power - P;AveragePower rewardBM(Power, CurrentTime);return(self).

    data class Exponentialextends Distributioninstance variablesLambda: Real

    instance methodssample() : Real |Sample: Real|/*Returns a Real sample value for the Exponential distribution.*/

    Sample := -(Random random ln) / Lambda;if Sample > 0.0 then

    return(Sample)elsereturn(self sample)

    fi.

    printString() : String/*

  • 7/30/2019 mode5

    3/74

    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 reciprocalof 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 from0.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 Taskinstance variables

    initial method call

    Initialise()()

    instance methodsNotifyBuffersAboutMapping()()

    parIn1!MappedTo(MapTo)

    andIn2!MappedTo(MapTo)

    andOut!MappedTo(MapTo)

    andControl!MappedTo(MapTo)

    rap.

    CheckTokenAvailabilityForReads(Scenario: String)()

    if Scenario = "S2" thenIn1!InspectTokenAvailability(4096);In1?TokensAvailable

    fi;if Scenario = "S1" then

    In2!InspectTokenAvailability(4096);

  • 7/30/2019 mode5

    4/74

    In2?TokensAvailablefi.

    ReleaseSpaceForReads(Scenario: String)()

    if Scenario = "S2" thenIn1!ReleaseRoom

    fi;if Scenario = "S1" then

    In2!ReleaseRoomfi.

    PerformWrites(Scenario: String)()

    Out!WriteTokens.

    ReserveSpaceForWrites(Scenario: String)()

    Out!ReserveRoom(1024);Out?ReservationSuccessful.

    data class LongRunSampleAverageextends PerformanceMonitorinstance variablesAverageSquaredSum: Real, AverageSumLengthProduct: Real, Constant: Real, TransientMode: Boolean, AverageSum: Real, CurrentSum: Real, AverageLength: Real, CurrentLength: Integer, AverageSquaredLength: Real, NumberOfCycles: Integer

    instance methodsgetCurrentLength() : 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 thenBatchSize := m

    elseself 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 the Long Run Sample Average.*/

  • 7/30/2019 mode5

    5/74

    self rewardRC(Reward, (CurrentLength = 0) | (CurrentLength = BatchSize));

    return(self).

    help() : Object/*An instance of this class represents a monitor for Long Run Sample Average performance metrics.For more information on the use of this class, see the superclass PerformanceMonitor.*/

    return(nil).

    withParameters(A, CL: Real) : LongRunSampleAverage/*This method initialises the accuracy A and the confidence level CL for a Long Run Sample Average, where A and CL must be a Real within the interval [0.0, 1.0).*/

    if (A = 1.0) thenself 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 mustbe 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) thenself 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, ConfidenceLevel);

    Constant := (2.0 sqrt) * (self calculateInverseErfC(1.0 - ConfidenceLevel));

    TransientMode := true;

    NumberOfCycles := 0;CurrentLength := 0;AverageSum := 0.0;AverageLength := 0.0;

  • 7/30/2019 mode5

    6/74

    AverageSquaredSum := 0.0;AverageSquaredLength := 0.0;AverageSumLengthProduct := 0.0;

    self setDefaultBatchSize;

    return(self).

    rewardRC(Reward: Real, RecurrenceCondition: Boolean) : LongRunSampleAverage |PointEstimation, StandardDeviation, Variance, Factor, HalfWidth: Real|/*Implementing the technique of regenerative cycles, this method processes a reward 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 / NumberOfCycles);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 undefined for Variance zero, which is the case if only one Batch has been completed yet */

    PointEstimation := AverageSum / AverageLength;

    Variance := ((1 / Factor) * (AverageSquaredSum - (2 * PointEstimation * AverageSumLengthProduct) + (PointEstimation sqr * AverageSquaredLength)));if Variance > 0 then StandardDeviation := Variance sqrt else Standar

    dDeviation := 0.0 fi; /* Have to take rounding errorsinto account */

    HalfWidth := (Constant * StandardDeviation) / (AverageLength * (NumberOfCycles asReal sqrt));

    IntervalEstimation := new(ConfidenceInterval) withParameters(PointEstimation - HalfWidth, PointEstimation + HalfWidth, ConfidenceLevel)

    fifi;CurrentSum := Reward; /* Current Rewar

    d is part of the newly started Cycle */

    CurrentLength := 1else

    if TransientMode not then /* Continue to completecurrent Cycle if not in TransientMode anymore */

    CurrentSum := CurrentSum + Reward;CurrentLength := CurrentLength + 1

    fifi;

    return(self).

  • 7/30/2019 mode5

    7/74

    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(Accuracy 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 complementerror function (erfc) for the Real value y which must be within the interval (0.0, 1.0].*/

    z := y;w := 0.916461398268964 - z ln;u := w sqrt;

    s := (u ln + 0.488826640273108) / w;t := 1 / (u + 0.231729200323405);x := u * (1 - s * (s * 0.124610454613712 + 0.5)) -

    ((((-0.0728846765585675 * t + 0.269999308670029) * t +0.150689047360223) * t + 0.116065025341614) * t +0.499999303439796) * t;

    t := 3.97886080735226 / (x + 3.97886080735226);u := t - 0.5;s := (((((((((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 := ((((((((((((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 := x + s * (x * s + 1);

    return(x).

    logTo(Name: String) : LongRunSampleAverage/*This method initialises the Log File for the Long Run Sample Average. The Log File will have the name "Name.log", where the extension ".log" is appended automatically.*/

    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);

  • 7/30/2019 mode5

    8/74

    LogFile writeString(IntervalEstimation logHeading append(" Accurate:") cr);

    LogFile writeString("-------------------------------------------------------------------------------------------------------------------------" cr);

    LogFile close;

    return(self).

    process class Task2(MapsToNode: Char, Name: String, PriorityAssignment: Integer)extends Taskinstance variables

    initial method callInitialise()()

    instance methodsNotifyBuffersAboutMapping()()

    parIn!MappedTo(MapTo)

    andOut1!MappedTo(MapTo)and

    Out2!MappedTo(MapTo)and

    Control!MappedTo(MapTo)rap.

    ReserveSpaceForWrites(Scenario: String)()

    if Scenario = "S1" thenOut1!ReserveRoom(1024);Out1?ReservationSuccessful;

    Out2!ReserveRoom(1024);Out2?ReservationSuccessfulfi;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.

  • 7/30/2019 mode5

    9/74

    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: ControlBuffer("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, F1T2/In, G1T2/Control] || F3: DataBuffer("F3", 0, 1)[Buffers/Communication, T1F3/In, 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, Tasks/Computation, T3F4/Out1, F2T3/In, G2T3/Control] || F6: DataBuffer("F6", 0, 1)[Buffers/Communication, T4F6/In, F12T6/Out] || F7: DataBuffer("F7", 0, 1)[Buffers/Communication, T2F7/In, F7T7/Out] || F8: DataBuffer("F8", 0, 1)[Buffers/Communication, 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/Out] || 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/Communication, T1G4/In, F7T5/Out] || Task6: Task6(Mapping get(6), "Task6", PriorityAssignment/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: Task1(Iterate, Mapping get(1), "Task1", PriorityAssignment/10000000, ScenarioPart1)[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/Computation, 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, Mapping get(8), "Task8", PriorityAssignment/1)[Tasks/Computation, G7T8/Control, Monitor/Monitor, T8F12/Out, F11T8/In2, F10T8/In1])\{T1F3, F10T8, F9T7, T5F8, T3F4, F7T7, T1F1, T2F7, F7T5, F11T8, G3T4, F11T6, T1G1, F3T4, F4T5, T1G2, G2T3, F13T6, T1F2, 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 variablesStatus: PlatformStatus

    initial method callInitialise()()

    instance methodsCheckAccuracyStatus()() |Name: String, MonitorID: Integer, Accurate: Boolean|

    SimulationController?PlatformStatus;MonitorID := 1;while MonitorID

  • 7/30/2019 mode5

    10/74

    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 SchedulerStatusextends Objectinstance variables

    NumberOfTasks: Integer, TaskList: QueueElement, Policy: String

    instance methodsremoveTask(OldTask: ScheduledTask) : Integer |E: QueueElement|

    E := TaskList getPrev;while E getElement getName != OldTask getName do

    E := E getPrevod;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 thenE 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).

  • 7/30/2019 mode5

    11/74

    printString : String |PrintOut: String, E: QueueElement|

    PrintOut := "Operating System with Policy: " + Policy printString cr cr + "Listof 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 getPrevod;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

    elseif Policy = "PB" thenE := TaskList getNext;Found := false;while (E != TaskList) & (Found not) do

    if E getElement getPriority < Priority thenE := E getNext

    elseFound := true

    fiod;E := E getPrev

    else

    self error("Unkown Scheduling Policy")fifi;NE setNext(E getNext) setPrev(E);E setNext(NE);NE getNext setPrev(NE);NumberOfTasks := NumberOfTasks + 1;return(NewTask).

    data class DataBufferMonitor

    extends Objectinstance variablesName: String, Trace: Boolean, ReservedLocations: Integer, TokenSize: Integer, VarianceOccupation: LongRunTimeVariance, PreviousTime: Real, Monitor: Boolean, AvailableTokens: Integer, MaximumOccupation: Integer, AverageOccupation: LongRunTimeAverage, BufferSize: Integer, TraceFile: FileOut

    instance methodsremove(NumberOfTokens: Integer, CurrentTime: Real) : DataBufferMonitor |Occupation: Integer|

  • 7/30/2019 mode5

    12/74

    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); VarianceOccupation 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: " + Name cr cr;Result append("Observed Maximum Buffer Occupancy: " + MaximumOccupation printString cr cr);Result append("Average Buffer Occupancy:" cr + AverageOccupation logStatistics cr cr);Result append("Variance in Buffer Occupancy:" cr + VarianceOccupation logStatistics 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; 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;self reserve(IT, 0.0); self write(IT);return(self).

  • 7/30/2019 mode5

    13/74

    room(NumberOfTokens: Integer) : Boolean

    if BufferSize > 0 thenreturn((ReservedLocations + AvailableTokens + NumberOfTokens) PreviousTime) then

    TraceFile writeString("At time: " + PreviousTime printString + " Occupation:" + (Occupation * TokenSize) printString cr)fi;ReservedLocations := ReservedLocations + NumberOfTokens; Occupation := Occupation + NumberOfTokens;if Monitor then

    if (Occupation * TokenSize) > MaximumOccupation then MaximumOccupation := Occupation * TokenSize fi;

    AverageOccupation rewardBM(Occupation * TokenSize, CurrentTime); VarianceOccupation rewardBM(Occupation * TokenSize, CurrentTime)fi;

    PreviousTime := CurrentTime;return(self).

    data class ApplicationStatusextends Objectinstance variablesNumberOfFirings: Integer, NumberOfDeadlineMisses: Integer, Throughput: LongRunRateAverage, NextDeadline: Real, TimeOfLastFiring: Real, DesiredThroughput: Real

    instance methods

    fired(CurrentTime: Real) : ApplicationStatus

    NumberOfFirings := NumberOfFirings + 1;Throughput rewardBM(1, CurrentTime);if CurrentTime > NextDeadline then NumberOfDeadlineMisses := NumberOfDeadlineMisses + 1 fi;NextDeadline := NextDeadline + 1.0 / DesiredThroughput;TimeOfLastFiring := CurrentTime;return(self).

    printString : String

    if NumberOfFirings > 0 then

    if NumberOfFirings = 1 thenreturn("Throughput Results: " cr + Throughput logStatistics cr cr + (100 *

    (NumberOfDeadlineMisses / NumberOfFirings)) printString + "% Deadline Misses" cr cr + "Latency: " + TimeOfLastFiring printString)

    elsereturn("Throughput Results: " cr + Throughput printString cr cr + (100 * (

    NumberOfDeadlineMisses / NumberOfFirings)) printString + "% Deadline Misses")fi

    elsereturn("Waiting for first frame")

  • 7/30/2019 mode5

    14/74

    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(1000);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 logStatistics cr cr + (100 * (NumberOfDeadlineMisses / NumberOfFirings)) printString + "%Deadline Misses" cr cr + "Latency: " + TimeOfLastFiring printString)

    elseLogFile writeString("Throughput Results: " cr + Throughput logStatist

    ics cr cr + (100 * (NumberOfDeadlineMisses / NumberOfFirings)) printString + "%Deadline Misses")

    fifi;LogFile close;return(self).

    data class Queueextends Objectinstance variablesPrimQueue: QueueElement, Size: Integer, Occupation: Integer, Unbounded: Integer,QueuingPolicy: String

    instance methodshelp() : Object/*Instances of this class represent a (un)bounded queue with FIFO or LIFO queueingpolicy.

    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")

  • 7/30/2019 mode5

    15/74

    where "Policy" is one of the following two possibilities:

    - "FIFO" sets the queueing policyto FIFO- "LIFO" sets the queueling policy to LIFO

    To change the size of a queue, use either the method

    - setSize(Value) where Value is an Integer largerthen 0 indicating the queue size- unboundedSize() to obtain an unbounded queue

    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 thenself error("Queue is Empty.")

    fi;if QueuingPolicy = "FIFO" then

    QE := PrimQueue getPrevelse

    if QueuingPolicy = "LIFO" thenQE := PrimQueue getNext

    elseself 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 thenself 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;

  • 7/30/2019 mode5

    16/74

    return(self).

    printString(): String |QE: QueueElement, PrintOut: String|

    /* Displays the contents of the Queue. */

    if Occupation = 0 thenPrintOut := "Empty"

    elsePrintOut := "( ";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 thenself error("Queue is empty.")

    fi;if QueuingPolicy = "FIFO" then

    QE := PrimQueue getPrev

    elseif QueuingPolicy = "LIFO" thenQE := PrimQueue getNext

    elseself error("Unknown Queuing Policy")

    fifi;

    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") thenQueuingPolicy := Policy;

    return(self)

  • 7/30/2019 mode5

    17/74

    elsereturn(self error("Unknown Queuing Policy"))

    fi.

    setSize(S: Integer) : Queue

    /* Sets the Size of the Queue */

    if S

  • 7/30/2019 mode5

    18/74

    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 thenreturn(ExecutionTimes at(Task getName) at(Task getScenario) / Frequency)

    elsereturn(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 Utilisation:" cr + Utilisation logStatistics cr cr + "Data Memory Results: " cr cr + MemoryResults);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 readString;ExecutionTimes := new(Dictionary) init;MemoryUsages := new(Dictionary) init;i := 1;while i

  • 7/30/2019 mode5

    19/74

    return(self).

    getPowerConsumption : Real

    return(PowerConsumption).

    getMemoryUsage(Task: ScheduledTask) : Real

    return(MemoryUsages at(Task getName) at(Task getScenario)).

    printString : String

    if Running thenreturn("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 printStatistics)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 thenTask 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 thenreturn(false)

    elsereturn(true)

    fi.

    data class LongRunRateAverageextends PerformanceMonitor

    instance variablesAverageReward: LongRunSampleAverage, AverageTime: LongRunSampleAverage, LastTime: Real

    instance methodsgetCurrentLength() : Integer

    return(AverageReward getCurrentLength).

    setBatchSize(m: Integer) : LongRunRateAverage

  • 7/30/2019 mode5

    20/74

    if m > 0 thenBatchSize := m;AverageReward setBatchSize(BatchSize);AverageTime setBatchSize(BatchSize)

    elseself 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) | (AverageReward getCurrentLength = BatchSize));

    return(self).

    help() : Object/*An instance of this class represents a monitor for Long Run Rate Average performance metrics.For more information on the use of this class, see the superclass PerformanceMonitor.*/

    return(nil).

    withParameters(A, CL: Real) : LongRunRateAverage

    if (A = 1.0) thenself 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) thenself 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 getIntervalEstimation);

    self setDefaultBatchSize();return(self).

    rewardRC(Reward, CurrentTime: Real, RecurrenceCondition: Boolean) : LongRunRateAverage

  • 7/30/2019 mode5

    21/74

    if LastTime != nil thenAverageReward rewardRC(Reward, RecurrenceCondition);AverageTime rewardRC(CurrentTime - LastTime, RecurrenceCondition)

    fi;LastTime := CurrentTime;if RecurrenceCondition then

    IntervalEstimation := (AverageReward getIntervalEstimation) / (AverageTimegetIntervalEstimation)

    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(Accuracy printString))

    fi.

    logTo(Name: String) : LongRunTimeAverage/*This method initialises the Log File for the Long Run Rate Average. The Log Filewill have the name "Name.log", where the extension ".log" is appended automatically.*/

    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 Taskinstance variables

    initial method callInitialise()()

    instance methodsNotifyBuffersAboutMapping()()

    parIn!MappedTo(MapTo)

    andOut1!MappedTo(MapTo)

  • 7/30/2019 mode5

    22/74

    andOut2!MappedTo(MapTo)

    andControl!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!WriteTokensfi.

    ReserveSpaceForWrites(Scenario: String)()

    Out1!ReserveRoom(4096);Out1?ReservationSuccessful;if Scenario = "S2" then

    Out2!ReserveRoom(4096);Out2?ReservationSuccessful

    fi.

    data class CommunicationStatusextends Objectinstance variables

    AverageNumberOfConcurrentConnections: LongRunTimeAverage, NumberOfConcurrentConnections: Integer, AchievedMaximumNumberOfConcurrentConnections: Integer, ActiveConnections: Set

    instance methodsaccurate : 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, CurrentTime);return(self).

    activate(Connection: String, CurrentTime: Real) : CommunicationStatus

  • 7/30/2019 mode5

    23/74

    ActiveConnections add(Connection);NumberOfConcurrentConnections := NumberOfConcurrentConnections + 1;if NumberOfConcurrentConnections > AchievedMaximumNumberOfConcurrentConnectionsthen AchievedMaximumNumberOfConcurrentConnections := NumberOfConcurrentConnections fi;AverageNumberOfConcurrentConnections rewardBM(NumberOfConcurrentConnections, CurrentTime);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 Maximum Number of Concurrent Connections: " + AchievedMaximumNumberOfConcurrentConnections printString cr cr + "Statistics for Average Number of Concurrent Connections:" cr + AverageNumberOfConcurrentConnections logStatistics cr cr + "Buffer Memory 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 printString cr cr + "Active Connections:" cr + ActiveConnections printString cr cr +"Achieved Maximum Number of Concurrent Connections: " + AchievedMaximumNumberOfConcurrentConnections printString cr cr + "Statistics for Average Number of Concurrent Connections:" cr + AverageNumberOfConcurrentConnections printStatistics).

    process class Task7(MapsToNode: Char, Name: String, PriorityAssignment: Integer)extends Taskinstance variables

    initial method callInitialise()()

    instance methods

    NotifyBuffersAboutMapping()()

    parIn1!MappedTo(MapTo)

    andIn2!MappedTo(MapTo)

    andIn3!MappedTo(MapTo)

    andOut!MappedTo(MapTo)

  • 7/30/2019 mode5

    24/74

    andControl!MappedTo(MapTo)

    rap.

    CheckTokenAvailabilityForReads(Scenario: String)()

    if Scenario = "S1" thenIn1!InspectTokenAvailability(1024);In1?TokensAvailable

    elseIn1!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 Distributioninstance variablesLowerBound: Real, IntervalLength: Real

    instance methodssample() : 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((LowerBound + IntervalLength) printString) append(")")).

    withParameters(LB, UB: Real) : Uniform/*Initialises the parameters of the Uniform distribution. LB and UB represent resp

  • 7/30/2019 mode5

    25/74

    ectively the lower and upper bounds of the interval (LB,UB) in which the samplevalues 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 smallerthen 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 MemoryStatusextends Objectinstance variablesOccupation: Integer, MaximumOccupation: Integer, AverageOccupation: LongRunTimeAverage

    instance methodsaccurate : 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 + "Statistics for Average Occupation:" cr + AverageOccupation logStatistics).

  • 7/30/2019 mode5

    26/74

    allocate(NumberOfBytes: Integer, CurrentTime: Real) : MemoryStatus

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

    data class LongRunTimeVarianceextends PerformanceMonitorinstance variablesAverageSquaredReward: LongRunTimeAverage, AverageReward: LongRunTimeAverage

    instance methodssetBatchSize(m: Integer) : LongRunTimeVariance/*This method initialises the size of the batches for the batch-means technique.*/

    if m > 0 thenBatchSize := m;

    AverageReward setBatchSize(BatchSize);AverageSquaredReward setBatchSize(BatchSize)else

    self error("BatchSize parameter for Long Run Time Variance must be largerthan 0")

    fi;

    return(self).

    rewardBM(Reward, CurrentTime: Real) : LongRunTimeVariance/*Implementing the technique of batch-means, this method processes a reward for the Long Run Time Variance.

    */

    self rewardRC(Reward, CurrentTime, (AverageReward getCurrentLength = 0) | (AverageReward getCurrentLength = BatchSize));

    return(self).

    help() : Object/*An instance of this class represents a monitor for Long Run Time Variance performance metrics.For more information on the use of this class, see the superclass PerformanceMonitor.

    */

    return(nil).

    withParameters(A, CL: Real) : LongRunTimeVariance/*This method initialises the accuracy A and confidence level CL for a Long Run Sample Variance, where A and CL must be a Real within the interval [0.0, 1.0).*/

  • 7/30/2019 mode5

    27/74

    if (A = 1.0) thenself 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) thenself 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((ConfidenceLevel + 1) / 2);

    IntervalEstimation := (AverageSquaredReward getIntervalEstimation) - ((AverageReward getIntervalEstimation) sqr);

    self setDefaultBatchSize();

    return(self).

    rewardRC(Reward, CurrentTime: Real, RecurrenceCondition: Boolean) : LongRunTimeV

    ariance/*Implementing the technique of regenerative cycles, this method processes a reward for the Long Run Time Variance.*/

    AverageReward rewardRC(Reward, CurrentTime, RecurrenceCondition);AverageSquaredReward rewardRC(Reward * Reward, CurrentTime, RecurrenceConditi

    on);if RecurrenceCondition then

    IntervalEstimation := (AverageSquaredReward getIntervalEstimation) - ((AverageReward 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(AccuracyprintString)).

    logTo(Name: String) : LongRunTimeVariance/*

    This method initialises the Log File for the Long Run Time Variance. The Log File will have the name "Name.log", where the extension ".log" is appended automatically.*/

    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);

  • 7/30/2019 mode5

    28/74

    LogFile writeString("-------------------------------------------------------------------------------------------------------------------------" cr);

    LogFile close;

    return(self).

    data class Bernoulliextends Distributioninstance variablesSuccessProbability: Real

    instance methodsyieldsSuccess() : 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 probability 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 interval [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).

  • 7/30/2019 mode5

    29/74

    data class MarkovChainextends Objectinstance variablesTransitions: Array, CurrentState: String, NumberOfStates: Integer, StateSpace: Array, Random: Uniform

    instance methodsinit : 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

  • 7/30/2019 mode5

    30/74

    i := 1;while i

  • 7/30/2019 mode5

    31/74

    temp put(5,MapsToNode);MapTo := temp;

    Priority := PriorityAssignment modulo(10);

    NotifyBuffersAboutMapping()();NotifyPlatformAboutMapping()();Fire()().

    ReleaseSpaceForReads(Scenario: String)()

    skip.

    CheckTokenAvailabilityForReads(Scenario: String)()

    skip.

    data class Normalextends Distributioninstance variablesStandardDeviation: Real, Mean: Real

    instance methodssample() : 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((StandardDeviation * StandardDeviation) printString) append(")")).

    withParameters(M, V: Real) : Normal/*Initialises the parameters of the Normal distribution. M and V represent respectively the mean and variance and must be Reals.*/

    self initialise;Mean := M;StandardDeviation := V sqrt;

  • 7/30/2019 mode5

    32/74

    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, Buffers/Access] || RouterNetwork: CommunicationUnit(BandwidthPerConnection, ConnectionSetUpLatency, NetworkName, PowerPerActiveConnection)[Communications/Communications, Buffers/Memory, Power/Power, Monitor/Monitor])\{Buffers}

    data class ControlBufferMonitorextends Objectinstance variablesName: String, Trace: Boolean, ReservedLocations: Integer, VarianceOccupation: LongRunTimeVariance, TokenSize: Integer, PreviousTime: Real, Monitor: Boolean, AvailableTokens: Integer, MaximumOccupation: Integer, AverageOccupation: LongRunTimeAverage, Buffer: Queue, BufferSize: Integer, TraceFile: FileOut

    instance methodsremove(CurrentTime: Real) : Integer |Occupation: Integer|

    Occupation := ReservedLocations + AvailableTokens;if Trace & (CurrentTime > PreviousTime) thenTraceFile 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); VarianceOccupation rewardBM(Occupation * TokenSize, CurrentTime)fi;PreviousTime := CurrentTime;return(Buffer remove).

    accurate : Boolean

    return(AverageOccupation accurate).

    available : Boolean

    return(AvailableTokens >= 1).

    getResults : String |Result: String|

  • 7/30/2019 mode5

    33/74

    Result := "-------------------------------" cr + "Statistics for Channel: " + Name cr cr;Result append("Observed Maximum Buffer Occupancy: " + MaximumOccupation printString cr cr);Result append("Average Buffer Occupancy:" cr + AverageOccupation logStatistics cr cr);Result append("Variance in Buffer Occupancy:" cr + VarianceOccupation logStatistics cr cr);return(Result).

    write(NumberOfTokens: Integer, Scenario: Integer) : ControlBufferMonitor |Counter: 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: Boolean) : 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 thenreturn((ReservedLocations + AvailableTokens + NumberOfTokens)

  • 7/30/2019 mode5

    34/74

    Occupation := ReservedLocations + AvailableTokens;if Trace & (CurrentTime > PreviousTime) then

    TraceFile writeString("At time: " + PreviousTime printString + " Occupation:" + (Occupation * TokenSize) printString cr)fi;ReservedLocations := ReservedLocations + NumberOfTokens; Occupation := Occupation + NumberOfTokens;if Monitor then

    if (Occupation * TokenSize) > MaximumOccupation then MaximumOccupation := Occupation * TokenSize fi;

    AverageOccupation rewardBM(Occupation * TokenSize, CurrentTime); VarianceOccupation rewardBM(Occupation * TokenSize, CurrentTime)fi;PreviousTime := CurrentTime;return(self).

    data class PerformanceMonitorextends Objectinstance variablesBatchSize: Integer, ConfidenceLevel: Real, Accuracy: Real, IntervalEstimation: C

    onfidenceInterval, LogFile: FileOut

    instance methodsprintStatistics() : String/*This method displays the statistics for about the long-run average performance metric.*/

    if Accuracy = nil thenreturn(IntervalEstimation printString)

    elsereturn(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" returns a Long Run Sample Average performance metric monitor- "LongRunTimeAverage" returns a Long Run Time Average performa

  • 7/30/2019 mode5

    35/74

    nce metric monitor- "LongRunSampleVariance" returns a Long Run Sample Variance performance metric monitor- "LongRunTimeVariance" returns a Long Run Time Variance performance metric monitor

    To initialise the Accuracy (1 minus the Relative Error) and ConfidenceLevel fora 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 ConfidenceLevel 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 oneof the methods

    rewardRC(Reward, RecurrenceCondition)for performance metric types Long Run Sample Average and Long Run Sample Variance estimated with the technique of regenerative cycles

    rewardRC(Reward, currentTime, RecurrenceCondition)for performance metric types Long Run Time Average and Long Run Time Variance estimated with the technique of regenerative cycles

    rewardBM(Reward)for performance metric types Long Run Sample Average and Long Run Sample Variance estimated with the batch-means technique

    rewardBM(Reward, currentTime)for performance metric types Long Run Time Average and Long Run Time Variance estimated with the batch-means techniquewhere 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 different Batch Size, use method

    setBatchSize(BatchSize)

    To check whether the obtained accuracy is not larger than the desired accuracy as specified by the variable "Accuracy" when initialising the long run average performance metric with the "withParameters" method, use method

    accurate()

    To initialise the logging capabilities of a long run average performance metricmonitor, 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 appended automatically.

    To append a line with the current statistics of a long run average performance metric, use the method

    log()*/

    return(nil).

    logStatistics() : String/*This method returns the statistics for about the long-run average performance metric for logging purposes*/

    return(IntervalEstimation logHeading tab + "Accurate:" cr + IntervalEstimation l

  • 7/30/2019 mode5

    36/74

    ogStatistics tab + IntervalEstimation accurate(Accuracy) printString).

    log() : PerformanceMonitor/*This method logs one line in the log file with the current statistics for the long-run average performance metric.*/

    if LogFile = nil thenself error("Can not log statistics: Log File not initialised.")

    elseLogFile 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 performance metrics of one of the following types:

    - "LongRunSampleAverage" returns a monitor for Long Run Sample Average performance metrics, use "LongRunSampleAverage" for the parameter Type- "LongRunTimeAverage" returns a monitor for Long Run Time Average performance metrics, use "LongRunTimeAverage" for the parameter Type- "LongRunSampleVariance" returns a monitor for Long Run Sample Variance performance metrics, use "LongRunSampleVariance" for the parameter Type

    - "LongRunTimeVariance" returns a monitor for Long Run Time Variance performancemetrics, use "LongRunTimeVariance" for the parameter Type- "LongRunRateAverage" returns a monitor for Long Run Rate Average performance metrics, use "LongRunRateAverage" for the parameter Type*/

    if Type = "LongRunSampleAverage" thenreturn(new(LongRunSampleAverage))

    elseif Type = "LongRunTimeAverage" then

    return(new(LongRunTimeAverage))else

    if Type = "LongRunSampleVariance" then

    return(new(LongRunSampleVariance))else

    if Type = "LongRunTimeVariance" thenreturn(new(LongRunTimeVariance))

    elseif Type = "LongRunRateAverage" then

    return(new(LongRunRateAverage))else

    self error("Unknown Performance Monitor Type")fi

  • 7/30/2019 mode5

    37/74

    fifi

    fifi.

    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 variablesStatus: ProcessorStatus

    initial method callInitialise()()

    instance methodsInitialise()() |InUse: Boolean, Results: String|

    OS?Use(InUse);

    if InUse thenMemory!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) & (VoltageScaleFactor != 1/1) then

    Status error("Invalid voltage scale factor")fi;abort

    parExecuteTask()()

    andCheckAccuracyStatus()()

    rapwith

    Monitor?StopSimulation; Memory?SimulationResults(Results){Status log(NodeName, 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 getMemoryUsage(Task)) fi;StartTime := currentTime; Preempt := false;abort

    delay(Status getExecutionTime(Task) / VoltageScaleFactor)

  • 7/30/2019 mode5

    38/74

    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 ScheduledTaskextends Objectinstance variablesScenario: 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 + " with Priority " + Priority printString).

    getRemainingExecutionTime : Real

    return(RemainingExecutionTime).

  • 7/30/2019 mode5

    39/74

    process class CommunicationUnit(BandwidthPerConnection: Real, ConnectionSetUpLatency: Real, NodeName: String, PowerPerActiveConnection: Real)instance variablesStatus: CommunicationStatus

    initial method callInitialise()()

    instance methodsCheckAccuracyStatus()() |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, TransferID: Integer|

    Communications?ReserveRoom(Channel, MapTo, NumberOfTokens, TokenSize | (Status inactive(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)

    andTransfer()()

    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, TokenSize: 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 doCommunications?InitialiseTokens(MapTo, NumberOfTokens, TokenSize | MapT

    o = NodeName);Memory!Allocate(NumberOfTokens * TokenSize)

    odwith delay(1.0e-12);

  • 7/30/2019 mode5

    40/74

    abortpar

    Transfer()()and

    ReleaseBufferSpace()()and

    CheckAccuracyStatus()()rap

    withMonitor?StopSimulation; Memory?SimulationResults(Results){Status log(NodeN

    ame, Results)}fi.

    process class Task1(Iterate: Boolean, MapsToNode: Char, Name: String, PriorityAssignment: Integer, ScenarioPart1: String)instance variablesPriority: Integer, MapTo: String, MarkovChain: MarkovChain

    initial method callInitialise()()

    instance methodsExecute(Scenario: String)() |N: String|

    Computation!Execute(Name, Scenario, Priority, MapTo);Computation?ExecutionCompleted(N | N = Name).

    NotifyBuffersAboutMapping()()

    parIn! MappedTo(MapTo)

    andD_T2!MappedTo(MapTo)

    and

    D_T3!MappedTo(MapTo)andD_T4!MappedTo(MapTo)

    andC_T2!MappedTo(MapTo)

    andC_T3!MappedTo(MapTo)

    andC_T4!MappedTo(MapTo)

    andC_T5!MappedTo(MapTo)

    andC_T6!MappedTo(MapTo)

    andC_T7!MappedTo(MapTo)

    andC_T8!MappedTo(MapTo)

    rap.

    ReserveSpaceForWrites(Scenario: String)()

    D_T2!ReserveRoom(2048);D_T2?ReservationSuccessful;

  • 7/30/2019 mode5

    41/74

    D_T3!ReserveRoom(1024);D_T3?ReservationSuccessful;

    if Scenario = "S1" thenD_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!WriteTokensfi;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 := ScenarioPart1 fi;if MarkovChain hasState(Scenario) not then Scenario := new(Object) error("Uknownscenario: " + 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);

  • 7/30/2019 mode5

    42/74

    MapTo := temp;

    Priority := PriorityAssignment modulo(10);

    NotifyBuffersAboutMapping()();NotifyPlatformAboutMapping()();

    {MarkovChain := new(MarkovChain) init;MarkovChain addState("S1");

    MarkovChain addTransition("S1", "S1", 0, 1/2);MarkovChain addTransition("S1", "S2", 1/2, 1);

    MarkovChain addState("S2");MarkovChain addTransition("S2", "S2", 0, 2/3);MarkovChain addTransition("S2", "S1", 2/3, 1);

    MarkovChain setInitialState("S1")};

    abort Fire()() with Monitor?StopSimulation.

    ReleaseSpaceForReads(Scenario: String)()

    In!ReleaseRoom.

    CheckTokenAvailabilityForReads(Scenario: String)()

    In!InspectTokenAvailability(1);In?TokensAvailable.

    data class DiscreteUniformextends Distributioninstance variablesIntervalLength: Integer, LowerBound: Integer

    instance methodssample() : 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 represent respectively the lower and upper bounds of the discrete interval [LB,UB] in which the sample values are and must be Integers.Notice that LB must be smaller then or equal to UB.*/

    self initialise;

  • 7/30/2019 mode5

    43/74

    if LB > UB thenself 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 QueueElementextends Objectinstance variablesNext: QueueElement, Prev: QueueElement, Element: Object

    instance methodsgetNext: 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).

  • 7/30/2019 mode5

    44/74

    setElement(element: Object): QueueElement

    Element := element;

    return(self).

    data class ConfidenceIntervalextends Objectinstance variablesConfidenceLevel: Real, LowerBound: Real, UpperBound: Real

    instance methodslogHeading() : String/*This method returns the statistics heading for logging purposes.*/

    return("Point Estimation:" tab + "Confidence Interval:" tab tab + "ConfidenceLevel:" tab + "Relative Error:").

    sqr() : ConfidenceInterval |Lower, Upper: Real|

    /*This method implements the square operation on confidence intervals.*/

    if self extendedLowerGreaterEqualZero thenLower := self extendedTimes(LowerBound, LowerBound);Upper := self extendedTimes(UpperBound, UpperBound)

    elseif self extendedUpperLessZero then

    Lower := self extendedTimes(UpperBound, UpperBound);Upper := self extendedTimes(LowerBound, LowerBound)

    elseLower := 0.0;

    Upper := self extendedMax(self extendedTimes(LowerBound, LowerBound), self 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 arithmetic for the extended Real numbers.*/

    if (x = nil) | (y = nil) thenreturn(nil)

    elseif x < y then

    return(x)else

    return(y)fi

    fi.

  • 7/30/2019 mode5

    45/74

    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 rulesof arithmetic for the extended Real numbers.*/

    if LowerBound = nil thenreturn(true)

    elsereturn(LowerBound < 0.0)

    fi.

    accurate(Accuracy: Real) : Boolean |RelativeError: Real|/*This method returns whether the point estimate is sufficiently accurate with respect to Accuracy.*/

    RelativeError := self getRelativeError;if RelativeError = nil then

    return(false)else

    return(RelativeError

  • 7/30/2019 mode5

    46/74

    elseif CI extendedUpperLessZero then

    Lower := self extendedTimes(UpperBound, CI getUpperBound);Upper := self extendedTimes(LowerBound, CI getLowerBound)

    elseLower := self extendedTimes(LowerBound, CI getUpperBound);Upper := self extendedTimes(LowerBound, CI getLowerBound)

    fifi

    elseif CI extendedLowerGreaterEqualZero then

    Lower := self extendedTimes(LowerBound, CI getUpperBound);Upper := self extendedTimes(UpperBound, CI getUpperBound)

    elseif CI extendedUpperLessZero then

    Lower := self extendedTimes(UpperBound, CI getLowerBound);Upper := self extendedTimes(LowerBound, CI getLowerBound)

    elseLower := 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

    fifi;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 tab + "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 bound 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.

  • 7/30/2019 mode5

    47/74

    */

    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 for the extended Real numbers.*/

    if (LowerBound = nil) | (UpperBound = nil) thenreturn(nil)

    elseif LowerBound > 0.0 thenreturn((UpperBound - LowerBound) / (2 * LowerBound))

    elseif UpperBound < 0.0 then

    return((LowerBound - UpperBound) / (2 * UpperBound))else

    return(nil)fi

    fifi.

    logStatistics() : String |RelativeError: Real, LogOut: String|

    /*This method returns the statistics for logging purposes.*/

    if (LowerBound = nil) | (UpperBound = nil) thenLogOut := "Not Specified" tab + "["

    elseLogOut := (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 tabfi;LogOut append(ConfidenceLevel printString tab tab tab);

  • 7/30/2019 mode5

    48/74

    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 extendedLowerLessZero) & (self extendedUpperGreaterZero) thenLower := nil;Upper := nil

    elseLower := self extendedReciprocal(UpperBound);Upper := self extendedReciprocal(LowerBound)

    fi;

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

    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 for the extended Real numbers.*/

    if (x = nil) | (y = nil) thenreturn(nil)

    elsereturn(x + y)

    fi.

    extendedUpperGreaterZero() : Boolean/*This method checks whether UpperBound is greater then 0.0 using the extended rules of arithmetic for the extended Real numbers.*/

    if UpperBound = nil thenreturn(true)

    else

  • 7/30/2019 mode5

    49/74

  • 7/30/2019 mode5

    50/74

    */

    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 rulesof arithmetic for the extended Real numbers.*/

    if UpperBound = nil thenreturn(false)

    elsereturn(UpperBound < 0.0)

    fi.

    extendedNegate(x: Real) : Real

    /*This method returns the result of -x using the extended rules of arithmetic forthe extended Real numbers.*/

    if x = nil thenreturn(nil)

    elsereturn(-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) thenPrintOut := "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

  • 7/30/2019 mode5

    51/74

    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 forthe extended Real numbers.*/

    if x = nil thenreturn(0.0)

    elseif x = 0.0 then

    return(nil)elsereturn(1 / x)

    fifi.

    process class Task8(DesiredLatency: Real, DesiredThroughput: Real, Iterate: Boolean, MapsToNode: Char, Name: String, PriorityAssignment: Integer)extends Taskinstance variables

    Status: ApplicationStatus

    initial method callInitialise()()

    instance methodsNotifyBuffersAboutMapping()()

    parIn1!MappedTo(MapTo)

    andIn2!MappedTo(MapTo)

    and

    Out!MappedTo(MapTo)and

    Control!MappedTo(MapTo)rap.

    ReserveSpaceForWrites(Scenario: String)()

    Out!ReserveRoom(1);Out?ReservationSuccessful.

  • 7/30/2019 mode5

    52/74

    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

    parFire()()

    andCheckAccuracyStatus()()

    rap

    withMonitor?StopSimulation{Status log}.

    ReleaseSpaceForReads(Scenario: String)()

    if Scenario = "S1" thenIn1!ReleaseRoom

    fi;

    In2!ReleaseRoom.

    CheckAccuracyStatus()()

    Monitor?ApplicationStatus;Monitor!ApplicationAccuracyStatus(Status accurate);CheckAccuracyStatus()().

    CheckTokenAvailabilityForReads(Scenario: String)()

    if Scenario = "S1" thenIn1!InspectTokenAvailability(1024);In1?TokensAvailable

    fi;

  • 7/30/2019 mode5

    53/74

    In2!InspectTokenAvailability(2048);In2?TokensAvailable.

    process class Task5(MapsToNode: Char, Name: String, PriorityAssignment: Integer)extends Taskinstance variables

    initial method callInitialise()()

    instance methodsNotifyBuffersAboutMapping()()

    parIn!MappedTo(MapTo)

    andOut!MappedTo(MapTo)

    andControl!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 variablesMapTo: String, TransferID: Integer, Status: DataBufferMonitor

    initial method callInitialise()()

    instance methodsNotifyPlatformAboutMapping()()

    Communication!Use(MapTo).

    HandleOutput()() |NumberOfTokens: Integer|

  • 7/30/2019 mode5

    54/74

    Out?InspectTokenAvailability(NumberOfTokens | Status available(NumberOfTokens));Out!TokensAvailable;Out?ReleaseRoom;Communication!ReleaseRoom(MapTo, NumberOfTokens, TokenSize){Status remove(NumberOfTokens, 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(NumberOfTokens, 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, NumberOfInitialTokens, TokenSize) fi;

    parHandleInput()()

    andHandleOutput()()

    rap.

    cluster class ProcessorNode(CommunicationBandwidth: Real, ConnectionSetUpLatency: Real, NodeName: String, OSPolicy: String, PowerPerActiveConnection: Real, PowerPerStoredByte: Real, ProcessorType: String, VoltageScaleFactor: Real)

    behaviour specification(OperatingSystem: OperatingSystem(NodeName, OSPolicy)[ScheduledTask/Processor, Computations/Task] || InterConnect: CommunicationUnit(CommunicationBandwidth, ConnectionSetUpLatency, NodeName, PowerPerActiveConnection)[Communications/Communications, BufferMemory/Memory, Power/Power, Monitor/Monitor] || BufferMemory: Stor

  • 7/30/2019 mode5

    55/74

    ageUnit(PowerPerStoredByte)[Monitor/Monitor, Power/Power, BufferMemory/Access] || Processor: ProcessingUnit(NodeName, ProcessorType, VoltageScaleFactor)[DataMemory/Memory, ScheduledTask/OS, Power/Power, Monitor/Monitor] || DataMemory: StorageUnit(PowerPerStoredByte)[Monitor/Monitor, Power/Power, DataMemory/Access])\{ScheduledTask, BufferMemory, DataMemory}

    data class Setextends Objectinstance variablesElements: Dictionary

    instance methodsadd(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

  • 7/30/2019 mode5

    56/74

    instance methodsInitialise()() |InUse: Boolean|

    Access?Use(InUse);if InUse then

    Status := new(MemoryStatus) init;abort

    parHandleAccesses()()

    andCheckAccuracyStatus()()

    rapwith

    Monitor?StopSimulation; Access!SimulationResults(Status logString)fi.

    HandleAccesses()() |NumberOfBytes: Integer|

    selAccess?Allocate(NumberOfBytes){Status allocate(NumberOfBytes, currentTime)};Power!StartConsumption(PowerPerByte * NumberOfBytes)

    orAccess?Free(NumberOfBytes){Status free(NumberOfBytes, currentTime)};

    Power!StopConsumption(PowerPerByte * NumberOfBytes)les;HandleAccesses()().

    CheckAccuracyStatus()()

    Access?Status;Access!AccuracyStatus(Status accurate);CheckAccuracyStatus()().

    data class LongRunTimeAverageextends PerformanceMonitorinstance variablesPreviousReward: Real, LastTime: Real, AverageRewardTimeProduct: LongRunSampleAverage, AverageTime: LongRunSampleAverage

    instance methodsgetCurrentLength() : 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 thenBatchSize := m;AverageRewardTimeProduct setBatchSize(BatchSize);AverageTime setBatchSize(BatchSize)

  • 7/30/2019 mode5

    57/74

    elseself 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 the 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 performance metrics.For more information on the use of this class, see the superclass PerformanceMonitor.

    */

    return(nil).

    withParameters(A, CL: Real) : LongRunTimeAverage/*This method initialises the accuracy A and confidence level CL for a Long Run Time Average, where A and CL must be a Real within the interval [0.0, 1.0).*/

    if (A = 1.0) thenself 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 be a Real within the interval [0.0, 1.0).*/

    if (CL < 0.0) | (CL >= 1.0) thenself error("ConfidenceLevel parameter for Long Run Time Average must be wi

  • 7/30/2019 mode5

    58/74

    thin the interval [0.0, 1.0)")fi;ConfidenceLevel := CL;

    AverageRewardTimeProduct := new(LongRunSampleAverage) withConfidenceLevel((ConfidenceLevel + 1) / 2);

    AverageTime := new(LongRunSampleAverage) withConfidenceLevel((ConfidenceLevel+ 1) / 2);

    IntervalEstimation := (AverageRewardTimeProduct getIntervalEstimation) / (AverageTime getIntervalEstimation);

    self setDefaultBatchSize();

    return(self).

    rewardRC(Reward, CurrentTime: Real, RecurrenceCondition: Boolean) : LongRunTimeAverage/*Implementing the technique of regenerative cycles, this method processes a reward for the Long Run Time Average.*/

    if LastTime != nil thenAverageRewardTimeProduct rewardRC(PreviousReward * (CurrentTime - LastTime

    ), RecurrenceCondition);AverageTime rewardRC(CurrentTime - LastTime, RecurrenceCondition)fi;PreviousReward := Reward;LastTime := CurrentTime;

    if RecurrenceCondition thenIntervalEstimation := (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(Accuracy printString))

    fi.

    logTo(Name: String) : LongRunTimeAverage/*This method initialises the Log File for the Long Run Time Average. The Log Filewill have the name "Name.log", where the extension ".log" is appended automatically.*/

    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);

  • 7/30/2019 mode5

    59/74

    LogFile writeString(IntervalEstimation logHeading append(" Accurate:") cr);

    LogFile writeString("-------------------------------------------------------------------------------------------------------------------------" cr);

    LogFile close;

    return(self).

    process class OperatingSystem(NodeName: String, Policy: String)instance variablesStatus: SchedulerStatus

    initial method callInitialise()()

    instance methodsInitialise()() |MapTo: String, InUse: Boolean|

    InUse := false;abort while true do Task?Use(MapTo | MapTo = NodeName){InUse := true} od with delay(1.0e-12);

    Processor!Use(InUse);if InUse thenStatus := new(SchedulerStatus) init(Policy);Schedule()()

    fi.

    Schedule()() |Task, Scenario, MapToNode: String, Priority, NumberOfWaitingTasks:Integ