@Override
    protected void initialize() {

      SharedResource shared = new SharedResource();

      MyPEH1 myPEH1 =
          new MyPEH1(
              new PriorityParameters(12),
              new PeriodicParameters(
                  new RelativeTime(Clock.getRealtimeClock()),
                  new RelativeTime(50, 0, Clock.getRealtimeClock())),
              storageParameters_Handlers,
              shared,
              this);
      myPEH1.register();

      PeriodicEventHandler myPEH2 =
          new MyPEH2(
              new PriorityParameters(12),
              new PeriodicParameters(
                  new RelativeTime(0, 0, Clock.getRealtimeClock()),
                  new RelativeTime(50, 0, Clock.getRealtimeClock())),
              storageParameters_Handlers,
              shared);
      myPEH2.register();

      Services.setCeiling(shared, 12);
    }
Esempio n. 2
0
  private PriorityScheduler() {
    int[] schedulerStack = new int[Const.PRIORITY_SCHEDULER_STACK_SIZE];

    this.pFrame = new PriorityFrame(Const.DEFAULT_PRIORITY_QUEUE_SIZE);

    this.prioritySchedulerImpl = new PrioritySchedulerImpl();

    vm.ClockInterruptHandler.initialize(this.prioritySchedulerImpl, schedulerStack);

    this.rtClock = Clock.getRealtimeClock();
    this.now = new AbsoluteTime(this.rtClock);
    rtClock.getTime(this.now);

    this.timeGrain = new RelativeTime(0, 0, this.rtClock);
    rtClock.getResolution(this.timeGrain);
    scheduler = this;
  }
Esempio n. 3
0
  public void addEvent(String message) {

    if (Const.ENABLE_LOG) {
      Clock.getRealtimeClock().getTime(ImmortalEntry.clk);

      logMilis[i] = ImmortalEntry.clk.getMilliseconds();
      logNanos[i] = ImmortalEntry.clk.getNanoseconds();
      logEvent[i] = message;

      i++;

      if (i == Const.MAX_LOG_EVENTS) {
        i = 0;
      }

      if (ImmortalEntry.eventsLogged < Const.MAX_LOG_EVENTS) {
        ImmortalEntry.eventsLogged++;
      }
    }
  }
Esempio n. 4
0
  @IcecapCompileMe
  ScjProcess move() {
    if (current == ScjProcess.idleProcess) {
      pFrame.readyQueue.insert(current);
    } else {
      current.gotoNextState(pFrame);
    }

    // Move processes from sleepingQueue to readyQueue
    ScjProcess process = pFrame.sleepingQueue.minimum();
    rtClock.getTime(now);

    while (process != null && process.next.compareTo(now) <= 0) {
      process.state = ScjProcess.State.READY;
      ScjProcess t = pFrame.sleepingQueue.extractMin();
      // devices.Console.println("PrSch.move:sleep --> ready: " + t.index);

      pFrame.readyQueue.insert(t);
      // look at "next" process in sleeping queue with smallest
      // activationTime
      process = pFrame.sleepingQueue.minimum();
    }

    // get next process from readyQueue
    ScjProcess nextProcess = pFrame.readyQueue.extractMax();
    nextProcess.state = ScjProcess.State.EXECUTING;
    current = nextProcess;

    if (current == ScjProcess.idleProcess
        && pFrame.sleepingQueue.heapSize == 0
        && pFrame.waitQueue.heapSize == 0
        && pFrame.lockQueue.heapSize == 0) {
      // devices.Console.println("PrioritySch.move: " + current.getTarget());
      // current.getTarget().cleanUp();  // HSO: is this call of cleanUp() necessary ? Then the
      // TCK-test does not work
      return null;
    } else {

      return nextProcess;
    }
  }