Package edu.vt.realtime

Examples of edu.vt.realtime.Timespec


  public static boolean transfer(Timespec deadline, Timespec period_ts, String[] lockedAccounts, String subAccountNum1, String subAccountNum2, int amount) {

    IBankAccount subAccount1 = null;
    IBankAccount subAccount2  = null;
    Address server1 = null, server2 = null;
    Timespec currenttime = new Timespec();
    char num1 = subAccountNum1.split("-")[1].charAt(0);
    char num2 = subAccountNum2.split("-")[1].charAt(0);
    boolean locked1 = false;
    boolean locked2 = false;
    String strAccount1, strAccount2;
View Full Code Here


 
  private static final long serialVersionUID = 7526471155622776147L;
 
  public int compare(Object o1, Object o2){
   
    Timespec t1 = (Timespec) o1;
    Timespec t2 = (Timespec) o2;
    if (t1.getSeconds() < t2.getSeconds() || (t1.getSeconds() == t2.getSeconds() &&
        t1.getNanoseconds() < t2.getNanoseconds()))
      return -1;
    else if((t1.getSeconds() == t2.getSeconds()) && (t1.getNanoseconds() == t2.getNanoseconds()))
        return 0;
    else
      return 1;
   
  }
View Full Code Here

    boolean timedout = false;
    long timeoutPeriod = edu.vt.rt.hyflow.benchmark.Benchmark.timout();
    int count =0;
    //this.aborts = ChronosScheduler.initAborts();
    this.aborts = edu.vt.rt.hyflow.benchmark.Benchmark.getAbortHandler();
    Timespec deadline = new Timespec();
    deadline.setTime(deadlineSec, deadlineNSec);
    Timespec period_ts = new Timespec();
    period_ts.setTime(period_tsSec, period_tsNSec);
    Timespec iota_time = new Timespec();
    iota_time.setTime(0, 5000000); // 5 mSec
    //deadline.subtract(iota_time);
    //period_ts.subtract(iota_time);
   
    Timespec currenttime = new Timespec();
    currenttime.getTime();
    if(currenttime.greaterThan(deadline)) {
      //System.out.println("T_O AB1");
      //System.out.println("Currenttime= " + currenttime.getSeconds() + " S " + currenttime.getNanoseconds() + " ns");
      //System.out.println("Currenttime= " + deadline.getSeconds() + " S " + deadline.getNanoseconds() + " ns");
     
      throw new InterruptedException();
    }
    ChronosScheduler.beginSegment(Priorities.TASK_RUN.getNativeId(), 2, deadline, period_ts, 0);

    while(!destroied && !lock.compareAndSet(false, true)){
      //if(enableTimeout && System.currentTimeMillis() - start > timeoutPeriod){
     
      currenttime.getTime();
      if(currenttime.greaterThan(deadline)) {
        timedout = true;
        break;
      }
      //  timouts++;
      //  break;
View Full Code Here

  @Override
  public void unlock(long deadlineSec, long deadlineNSec, long period_tsSec, long period_tsNSec) throws InterruptedException {
    //this.aborts = ChronosScheduler.initAborts();
    this.aborts = edu.vt.rt.hyflow.benchmark.Benchmark.getAbortHandler();
    Timespec deadline = new Timespec();
    deadline.setTime(deadlineSec, deadlineNSec);
    Timespec period_ts = new Timespec();
    period_ts.setTime(period_tsSec, period_tsNSec);
    Timespec iota_time = new Timespec();
    iota_time.setTime(0, 5000000); // 5 mSec
    //deadline.subtract(iota_time);
    //period_ts.subtract(iota_time);
   
    ChronosScheduler.beginSegment(Priorities.TASK_RUN.getNativeId(), 0, deadline, period_ts, 0);
    //lock.unlock();
View Full Code Here

     
      if(ObjThreadMap.containsKey(ObjID)) {
        HashMap<Timespec, ArrayList<threadAddressArray>> innerMap = ObjThreadMap.get(ObjID);

        // Find the existing earliest deadline for this object
        Timespec existingEarliestDeadline = null;
        DeadlineStatus compareResult = DeadlineStatus.NOTFOUND;
       
        for(Timespec deadlineKeys: innerMap.keySet()) {
          if(existingEarliestDeadline == null) {
            existingEarliestDeadline = deadlineKeys;
          } else {
            compareResult = earlierDeadline(existingEarliestDeadline, deadlineKeys);
            if(compareResult == DeadlineStatus.LATER) {
              existingEarliestDeadline = deadlineKeys;
            }
          }
        }

        if(existingEarliestDeadline == null) {
          // Not a possible case -- still add entry and return
          System.out.println("Not a possible case -- If Obj exists, deadline should exist --- still implemented");
          HashMap<Timespec, ArrayList<threadAddressArray>> newObjEntry = new HashMap<Timespec, ArrayList<threadAddressArray>>();
          ArrayList<threadAddressArray> newThreadEntry = new ArrayList<threadAddressArray>();
          newThreadEntry.add(new threadAddressArray(thread_id, hashCode, threadAddress, false));
          newObjEntry.put(deadline, newThreadEntry);
          ObjThreadMap.put(ObjID, newObjEntry);
         
          return true;
        }
       
        // Otherwise compare with the earliest deadline
        // Iterate over the key-set
        DeadlineStatus compareDeadline = earlierDeadline(existingEarliestDeadline, deadline);

        if(compareDeadline == DeadlineStatus.EARLIER) {

          Timespec Key = null;
          boolean deadlineExists = false;
          for(Timespec deadlineKeys: innerMap.keySet()) { 
            if(earlierDeadline(deadlineKeys, deadline) == DeadlineStatus.EQUAL) {
              deadlineExists = true;
              Key = deadlineKeys;
View Full Code Here

    try {
      if(ObjThreadMap.containsKey(ObjID)) {
        HashMap<Timespec, ArrayList<threadAddressArray>> innerMap = ObjThreadMap.get(ObjID);
       
        // Find the existing earliest Deadline
        Timespec existingEarliestDeadline = null;
        DeadlineStatus compareResult = DeadlineStatus.NOTFOUND;
       
        for(Timespec deadlineKeys: innerMap.keySet()) {
          if(existingEarliestDeadline == null) {
            existingEarliestDeadline = deadlineKeys;
View Full Code Here

                  /********/
                  DummyObject dummyObject = SignalWaitingTxRequest.threadObjectMap.get(thread);
                  //System.out.println("Local node contains waiting thread " + thread);
                  if(dummyObject == null) {
                   
                    Timespec newDeadline = deadline.copy();
                    Timespec iota = new Timespec(0, 5000);
                    newDeadline.subtract(iota);
                    if(DTL2Directory.chronosJavaThreadMap.containsKey(thread)) {
                      if(DTL2Directory.threadPhaseMap.get(thread) != DTL2Directory.IN_COMMIT_PHASE)
                      {
                        // Boost the priority of lower priority task to reduce the priority inversion
View Full Code Here

   *  It firstly copies all ObjIDs and corresponding deadlines to respective arraylists
   *  and then deletes the entries for which deadline is blown
   */
  public static void cleanup() {

    Timespec currentTime =new Timespec();
    currentTime.getTime();

    lock.lock();
    try {
      ArrayList<String> ObjIDList = new ArrayList<String>();
      for(String key : ObjThreadMap.keySet()) {
View Full Code Here

TOP

Related Classes of edu.vt.realtime.Timespec

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.