Search in sources :

Example 21 with SysDevice

use of com.jopdesign.io.SysDevice in project jop by jop-devel.

the class Measure method sort.

public static void sort() {
    SPBubbleSort bs = new SPBubbleSort();
    SysDevice sys = IOFactory.getFactory().getSysDevice();
    int frequ = new STScheduler(1).getMsCycles() * 1000;
    int shift = frequ / 10 / (TDMA_LENGTH) * TDMA_LENGTH + 1;
    bs.read();
    int time;
    int start = sys.cntInt + shift;
    for (int i = 0; i < 100; ++i) {
        sys.deadLine = start;
        time = sys.cntInt;
        bs.execute();
        time = sys.cntInt - time;
        System.out.println(time);
        start += shift;
    }
}
Also used : SysDevice(com.jopdesign.io.SysDevice)

Example 22 with SysDevice

use of com.jopdesign.io.SysDevice in project jop by jop-devel.

the class STAppController method main.

/**
     * Creation of all tasks, shared memory objects, and scheduling tables
     */
public static void main(String[] args) {
    STAppController[] tskList = new STAppController[3];
    // SampleSet + SampleCurr (double period)
    tskList[0] = new STAppController(2 * 3);
    // Controller
    tskList[1] = new STAppController(1 * 3);
    // Guard + Monitor
    tskList[2] = new STAppController(2 * 3);
    /* create all tasks and shared memory objects */
    SharedIMem InSetVal = new SharedIMem();
    SharedIMem InCurrVal = new SharedIMem();
    SharedIMem ShmSetVal = new SharedIMem();
    SharedIMem ShmCurrVal = new SharedIMem();
    SharedIMem ShmCtrlVal = new SharedIMem();
    SharedIMem ShmStatus = new SharedIMem();
    STSampler TskSampleSet = new STSampler(InSetVal, ShmSetVal);
    STSampler TskSampleCurr = new STSampler(InCurrVal, ShmCurrVal);
    STController TskController = new STController(ShmSetVal, ShmCurrVal, ShmCtrlVal);
    STGuard TskGuard = new STGuard(ShmStatus, 3);
    STMonitor TskMonitor = new STMonitor(ShmSetVal, ShmCurrVal, ShmCtrlVal, TskGuard);
    //System.out.println("STAppController.main().A");System.out.flush();
    TskGuard.addTask(TskSampleSet);
    TskGuard.addTask(TskSampleCurr);
    TskGuard.addTask(TskController);
    tskList[0].setMajorCycle(100000);
    tskList[1].setMajorCycle(200000);
    tskList[2].setMajorCycle(200000);
    // WCET estimation
    wcetrun = new RRunner(TskSampleSet);
    /* Construction of task list 0 */
    tskList[0].tabCyclicExec[0].tsk = new RRunner(TskSampleSet);
    tskList[0].tabCyclicExec[0].tactivation = 0;
    tskList[0].tabCyclicExec[1].tsk = new XRunner(TskSampleSet);
    tskList[0].tabCyclicExec[1].tactivation = 0;
    tskList[0].tabCyclicExec[2].tsk = new WRunner(TskSampleSet);
    tskList[0].tabCyclicExec[2].tactivation = 0;
    tskList[0].tabCyclicExec[3].tsk = new RRunner(TskSampleCurr);
    tskList[0].tabCyclicExec[3].tactivation = 0;
    tskList[0].tabCyclicExec[4].tsk = new XRunner(TskSampleCurr);
    tskList[0].tabCyclicExec[4].tactivation = 0;
    tskList[0].tabCyclicExec[5].tsk = new WRunner(TskSampleCurr);
    tskList[0].tabCyclicExec[5].tactivation = 0;
    /* Construction of task list 1 */
    tskList[1].tabCyclicExec[0].tsk = new RRunner(TskController);
    tskList[1].tabCyclicExec[0].tactivation = 0;
    tskList[1].tabCyclicExec[1].tsk = new XRunner(TskController);
    tskList[1].tabCyclicExec[1].tactivation = 0;
    tskList[1].tabCyclicExec[2].tsk = new WRunner(TskController);
    tskList[1].tabCyclicExec[2].tactivation = 0;
    /* Construction of task list 2 */
    tskList[2].tabCyclicExec[0].tsk = new RRunner(TskGuard);
    tskList[2].tabCyclicExec[0].tactivation = 0;
    tskList[2].tabCyclicExec[1].tsk = new XRunner(TskGuard);
    tskList[2].tabCyclicExec[1].tactivation = 0;
    tskList[2].tabCyclicExec[2].tsk = new WRunner(TskGuard);
    tskList[2].tabCyclicExec[2].tactivation = 0;
    tskList[2].tabCyclicExec[3].tsk = new RRunner(TskMonitor);
    tskList[2].tabCyclicExec[3].tactivation = 0;
    tskList[2].tabCyclicExec[4].tsk = new XRunner(TskMonitor);
    tskList[2].tabCyclicExec[4].tactivation = 0;
    tskList[2].tabCyclicExec[5].tsk = new WRunner(TskMonitor);
    tskList[2].tabCyclicExec[5].tactivation = 0;
    //--- tskList[0].syncWithMEMTDMA(); 
    measureExecTimes(tskList);
    //System.out.println("STAppController.main().G");System.out.flush();
    /* start the other CPUs */
    Startup.setRunnable(tskList[1], 0);
    Startup.setRunnable(tskList[0], 1);
    /* Set a reasonable start time for each task */
    /* f_clk=60MHz --> 60000=1ms */
    SysDevice sys = IOFactory.getFactory().getSysDevice();
    // (current time + 100ms)
    int localtime = ((sys.cntInt + 60000 * 100) / MEM_TDMA_ROUND) * MEM_TDMA_ROUND;
    tskList[0].time = localtime;
    tskList[1].time = localtime;
    tskList[2].time = localtime;
/* calc. starting time... */
//tskList[2].startCPUs();
//tskList[2].run();
}
Also used : SysDevice(com.jopdesign.io.SysDevice)

Example 23 with SysDevice

use of com.jopdesign.io.SysDevice in project jop by jop-devel.

the class EjipBenchCMPEjipOld method main.

public static void main(String[] args) {
    // Initialization for benchmarking 
    int start = 0;
    int stop = 0;
    int time = 0;
    init();
    SysDevice sys = IOFactory.getFactory().getSysDevice();
    int nrCpu = Runtime.getRuntime().availableProcessors();
    System.out.println("Ejip benchmark");
    // our work list
    Runnable[] work = new Runnable[] { // first one (or more) can printout
    new Runnable() {

        public void run() {
            ipLink.loop();
        }
    }, new Runnable() {

        public void run() {
            resultServer();
        }
    }, new Runnable() {

        public void run() {
            request();
        }
    }, new Runnable() {

        public void run() {
            macServer();
        }
    }, // more heavy tasks at the end
    new Runnable() {

        public void run() {
            net.loop();
        }
    } };
    Runner[] runner = Runner.distributeWorklist(work, nrCpu);
    for (int i = 0; i < nrCpu - 1; i++) {
        Startup.setRunnable(runner[i + 1], i);
    }
    received = 0;
    System.out.println("Start");
    // Start of measurement
    // Start of all other CPUs
    sys.signal = 1;
    start = (int) System.currentTimeMillis();
    runner[0].run();
    // End of measurement
    stop = (int) System.currentTimeMillis();
    time = stop - start;
    System.out.println("TimeSpent: " + time);
}
Also used : SysDevice(com.jopdesign.io.SysDevice)

Example 24 with SysDevice

use of com.jopdesign.io.SysDevice in project jop by jop-devel.

the class EjipBenchCMPSlow method main.

public static void main(String[] args) {
    // Initialization for benchmarking 
    int start = 0;
    int stop = 0;
    int time = 0;
    EjipBenchCMPSlow ebench = new EjipBenchCMPSlow();
    SysDevice sys = IOFactory.getFactory().getSysDevice();
    int nrCpu = Runtime.getRuntime().availableProcessors();
    System.out.println("Ejip benchmark");
    Runnable rl = new Runnable() {

        public void run() {
            for (; ; ) {
                ipLink.loop();
            }
        }
    };
    Runnable rn = new Runnable() {

        public void run() {
            for (; ; ) {
                net.loop();
            }
        }
    };
    if (nrCpu > 2) {
        Startup.setRunnable(rl, 0);
        Startup.setRunnable(rn, 1);
    } else if (nrCpu == 2) {
        Startup.setRunnable(rn, 0);
    }
    for (int i = 0; i < nrCpu; i++) {
    //			Startup.setRunnable(r, i);
    }
    System.out.println("Start calculation");
    // Start of measurement
    // Start of all other CPUs
    sys.signal = 1;
    start = (int) System.currentTimeMillis();
    if (nrCpu == 1) {
        for (received = 0; received < CNT; ) {
            request();
            ipLink.loop();
            net.loop();
        }
    } else if (nrCpu == 2) {
        for (received = 0; received < CNT; ) {
            request();
            ipLink.loop();
        }
    } else {
        for (received = 0; received < CNT; ) {
            request();
        }
    }
    // End of measurement
    stop = (int) System.currentTimeMillis();
    time = stop - start;
    System.out.println("TimeSpent: " + time);
}
Also used : SysDevice(com.jopdesign.io.SysDevice)

Example 25 with SysDevice

use of com.jopdesign.io.SysDevice in project jop by jop-devel.

the class HashtableBenchCMP method main.

public static void main(String[] args) {
    // Initialization for benchmarking 
    int start = 0;
    int stop = 0;
    int time = 0;
    System.out.println("Hashtable Benchmark:");
    // Initialize the data Array 
    String string = new String("Test");
    data = new DataClass[max];
    for (int i = 0; i < max; i++) {
        data[i] = new DataClass(new Integer(i), string + i);
    }
    htable = new Hashtable(max);
    SysDevice sys = IOFactory.getFactory().getSysDevice();
    // Calculates the bounds for each CPU
    low_array = new int[sys.nrCpu];
    high_array = new int[sys.nrCpu];
    int rest = max % sys.nrCpu;
    int div = max / sys.nrCpu;
    for (int j = 0; j < sys.nrCpu; j++) {
        if (j == 0) {
            low_array[j] = j * div;
            if (rest != 0) {
                high_array[j] = (j + 1) * div;
                rest--;
            } else {
                high_array[j] = (j + 1) * div - 1;
            }
        } else {
            low_array[j] = high_array[j - 1] + 1;
            if (rest != 0) {
                high_array[j] = high_array[j - 1] + div + 1;
                rest--;
            } else {
                high_array[j] = high_array[j - 1] + div;
            }
        }
    }
    for (int i = 0; i < sys.nrCpu - 1; i++) {
        Runnable r = new HashtableBenchCMP(i + 1, low_array[i + 1], high_array[i + 1], htable);
        Startup.setRunnable(r, i);
    }
    // Start of measurement
    start = LowLevel.timeMillis();
    // Start of all other CPUs
    sys.signal = 1;
    // Fill Hashtable
    for (int j = low_array[0]; j < (high_array[0]); j++) {
        if (htable.containsKey(data[j].key)) {
        } else {
            htable.put(data[j].key, data[j].value);
        }
    }
    // Read Table
    for (int i = low_array[0]; i < high_array[0]; i++) {
        if (htable.contains(data[i].value)) {
            data[i].value = (String) htable.get(data[i].key);
        }
    }
    // Delete Hashtable
    for (int i = low_array[0]; i < (high_array[0]); i++) {
        if (htable.containsKey(data[i].key)) {
            htable.remove(data[i].key);
        }
    }
    while (true) {
        util.Timer.usleep(500);
        synchronized (lock) {
            if (signal == sys.nrCpu - 1)
                break;
        }
    }
    // End of measurement
    stop = LowLevel.timeMillis();
    System.out.println("StartTime: " + start);
    System.out.println("StopTime: " + stop);
    time = stop - start;
    System.out.println("TimeSpent: " + time);
}
Also used : Hashtable(java.util.Hashtable) SysDevice(com.jopdesign.io.SysDevice)

Aggregations

SysDevice (com.jopdesign.io.SysDevice)30 Vector (java.util.Vector)5 Hashtable (java.util.Hashtable)2 BenchLift (jbe.BenchLift)2 RtThread (joprt.RtThread)2 OutPort (com.jopdesign.io.OutPort)1 RetryException (com.jopdesign.sys.RetryException)1 Random (java.util.Random)1 AbortException (rttm.AbortException)1