void doWork() {
      int x = 0, y = 0;
      Memory memory = Memory.getCurrentMemoryArea();

      devices.Console.println("Thread 1 allocating in: " + memory.getName());

      y = memory.consumedMemory();

      while (count < 5) {
        x = memory.consumedMemory();
        if (x != y) {
          devices.Console.println("T1 Fail 1");
          fail = true;
        }

        new SmallObject();

        y = memory.consumedMemory();
        if (y != x + sizeOfSmallObject) {
          devices.Console.println("T1 Fail 2, y = " + y + ", x = " + x);
          fail = true;
        }
        count++;
        delay();
      }
    }
 public synchronized void go() {
   if (count > 0) {
     devices.Console.println("    before notify");
     count--;
     notify();
     devices.Console.println("    after notify");
   }
 }
    @Override
    public void handleAsyncEvent() {
      devices.Console.println("---------- PEH2.handleAsyncEvent");

      shared.go();

      devices.Console.println("     PEH2: " + count);
      count++;
    }
 public MyMission getNextMission() {
   count++;
   if (count >= 1) {
     devices.Console.println("\nMySeq.getNextMission:null");
     return null;
   } else {
     devices.Console.println("\nMySeq.getNextMission");
     return mission;
   }
 }
 public synchronized void waitForGo() {
   count++;
   devices.Console.println("> before wait; count = " + count);
   try {
     wait();
   } catch (InterruptedException e) {
     e.printStackTrace();
   }
   devices.Console.println("< after wait; count = " + count);
   if (count > 0) throw new Error("wait error; count = " + count);
 }
  public static void main(String[] args) {
    new POSIX64BitMachineFactory();

    long start = System.currentTimeMillis();
    long end;

    devices.Console.println("Waiting 1 sec");

    do {
      end = System.currentTimeMillis();
    } while (end - start < 1000);

    devices.Console.println("Done");
    VMTest.markResult(false);
  }
    @Override
    @IcecapCompileMe
    public void handleAsyncEvent() {
      devices.Console.println("---------- PEH1.handleAsyncEvent");

      shared.waitForGo();

      count++;
      devices.Console.println("      PEH1: " + count);

      if (count == 3) {
        m.requestTermination();
        devices.Console.println("     Mission T");
      }
    }
    public void initialize() {
      devices.Console.println("** MyMission.initialize");

      new Thread1(new PriorityParameters(Priorities.PR96), storageParameters_Handlers).register();

      new Thread2(new PriorityParameters(Priorities.PR95), storageParameters_Handlers).register();
    }
Beispiel #9
0
  /** Runs a TestCase. */
  public void runProtected(final Test test, Protectable p) {
    try {
      // devices.Console.println("TestResult.runProtected");
      p.protect();
    } catch (AssertionFailedError e) {
      devices.Console.println("TestResult.runProtected: failure");

      addFailure(test, e);
    } catch (ThreadDeath e) { // don't catch ThreadDeath by accident
      throw e;
    } catch (Throwable e) {
      devices.Console.println("TestResult.runProtected: error");

      addError(test, e);
    }
  }
 /** Print out the contents of the queues. For testing only. */
 public void printQueues() {
   vm.ClockInterruptHandler.instance.disable();
   devices.Console.println("");
   //		devices.Console.println("PriorityScheduler: current process: "
   //				+ current.getTarget() + "; index: " + current.index);
   // devices.Console.println("----------- ready queue ----------");
   pFrame.readyQueue.print();
   // devices.Console.println("----------- sleeping queue ----------");
   pFrame.sleepingQueue.print();
   // devices.Console.println("----------- lock queue ----------");
   pFrame.lockQueue.print();
   // devices.Console.println("----------- wait queue ----------");
   pFrame.waitQueue.print();
   devices.Console.println("");
   vm.ClockInterruptHandler.instance.enable();
 }
 @Override
 public void handleAsyncEvent() {
   devices.Console.println("Running");
   ++eventCounter;
   if (eventCounter == 3) {
     sequencer.requestSequenceTermination();
   }
 }
  public static void main(String[] args) {
    storageParameters_Sequencer =
        new StorageParameters(
            Const.OUTERMOST_SEQ_BACKING_STORE,
            Const.PRIVATE_MEM,
            Const.IMMORTAL_MEM,
            Const.MISSION_MEM);

    storageParameters_Handlers =
        new StorageParameters(Const.PRIVATE_BACKING_STORE, Const.PRIVATE_MEM, 0, 0);

    configParameters = new ConfigurationParameters(-1, -1, new long[] {Const.HANDLER_STACK_SIZE});

    devices.Console.println("\n***** TestSCJWaitAndNotify1 main.begin *****");
    new LaunchLevel2(new MyApp());
    devices.Console.println("***** TestSCJWaitAndNotify1 main.end *****");

    if (count == 0) VMTest.markResult(false);
  }
 @Override
 protected MyMission getNextMission() {
   if (count == 10) {
     devices.Console.println("MySeq.count: " + count + "; null");
     return null;
   } else {
     count++;
     // devices.Console.println("MySequencer.getNextMission.count: " + count);
     return mission;
   }
 }
Beispiel #14
0
    private boolean scanStack() {
      boolean error = true;
      devices.Console.println("starting stack scan...");

      ThreadManager manager = Thread.getScheduler();

      Iterator<Thread> threads = manager.getThreads();

      while (threads.hasNext()) {
        Thread current = threads.next();
        if (current != Thread.currentThread()) {
          int[] stack = current.getStack();
          if (stack != null) {
            error = handleStack(current, stack);
          }
        }
      }
      devices.Console.println("done!");
      return error;
    }
  public static void main(String[] args) {
    Memory memory = Memory.getHeapArea();
    new SmallObject();
    int x = memory.consumedMemory();
    new SmallObject();
    int y = memory.consumedMemory();
    sizeOfSmallObject = y - x;

    x = memory.consumedMemory();
    new BiggerObject();
    y = memory.consumedMemory();
    sizeOfBiggerObject = y - x;

    devices.Console.println("small object is " + sizeOfSmallObject + " bytes");
    devices.Console.println("bigger object is " + sizeOfBiggerObject + " bytes");

    Const.setDefaultErrorReporter();
    vm.Memory.startMemoryAreaTracking();

    storageParameters_Sequencer =
        new StorageParameters(
            Const.OUTERMOST_SEQ_BACKING_STORE,
            Const.PRIVATE_MEM,
            Const.IMMORTAL_MEM,
            Const.MISSION_MEM);

    storageParameters_Handlers = new StorageParameters(Const.PRIVATE_BACKING_STORE, 2002, 0, 0);

    configParameters =
        new ConfigurationParameters(null, -1, -1, new long[] {Const.HANDLER_STACK_SIZE});

    devices.Console.println("\n********** TestSCJThreadMemory main.begin ******************");
    new LaunchLevel2(new MyApp());
    devices.Console.println("********* TestSCJThreadMemory main.end ********************");
    if (!fail) {
      args = null;
    }
  }
Beispiel #16
0
    protected boolean handleStack(Thread current, int[] stack) {
      short jtop = current.getJavaStackTop();
      devices.Console.println("thread [" + stack.length + "], top = " + jtop);
      for (short index = 0; index < jtop; index++) {
        devices.Console.println("stack[" + index + "] = " + stack[index]);
      }
      short ctop = (short) current.getCStackTop();

      if (ctop <= jtop) {
        return true;
      }

      if (ctop >= stack.length) {
        return true;
      }

      for (short index = ctop; index < stack.length; index++) {
        devices.Console.println("stack[" + index + "] = " + stack[index]);
      }
      if (jtop > 10) {
        return false;
      }
      return true;
    }
Beispiel #17
0
  private static boolean test() {
    DataSet ds = new DataSet();

    WordGenerator wordGen = new WordGenerator((short) 17);

    TextString next = wordGen.next();

    while (next != null) {
      if (!ds.contains(next)) {
        ds.add(next);
      }
      next = wordGen.next();
    }
    devices.Console.println("ds contains " + ds.size() + " distinct words");
    // System.out.println("ds contains " + ds.size() + " distinct words");
    return false;
  }
  public void handleAsyncEvent() {
    // read sensor
    float value = sensor.read();

    if (App.DEBUG) {
      int a1 = (int) value;
      int a2 = (int) ((value - a1) * 100);
      StringBuilder str = new StringBuilder(identifier);
      str.append(" read value: ");
      str.append(a1);
      str.append(".");
      str.append(a2);
      devices.Console.println(str.toString());
    }
    // write data to data store
    dataStore.put(value);
  }
 public MissionSequencer<MyMission> getSequencer() {
   devices.Console.println("MyApp.getSequencer");
   return new MySequencer();
 }
 public void run() {
   devices.Console.println("Thread1");
   doWork();
 }