Changeset 202 in flair-src for trunk/lib/FlairCore/src


Ignore:
Timestamp:
Nov 2, 2017, 3:04:47 PM (7 years ago)
Author:
Sanahuja Guillaume
Message:

modifs usleep

Location:
trunk/lib/FlairCore/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairCore/src/Thread.cpp

    r139 r202  
    9191  if (status != 0) {
    9292                char errorMsg[256];
    93     Err("%s, error rt_task_sleep_until (%s), resume time: %lld, actual time: "
    94         "%lld\n", ObjectName().c_str(), strerror_r(-status, errorMsg, sizeof(errorMsg)), time, GetTime());
     93    Err("%error rt_task_sleep_until (%s), resume time: %lld, actual time: "
     94        "%lld\n",strerror_r(-status, errorMsg, sizeof(errorMsg)), time, GetTime());
    9595        }
    9696// Printf("rt_task_sleep_until, resume time: %lld, actual time:
     
    9999  Time current = GetTime();
    100100  if (current < time) {
    101     usleep((time - current) / 1000);
     101    //usleep((time - current) / 1000);
     102    struct timespec req;
     103    req.tv_nsec = time - current;
     104    req.tv_sec = req.tv_nsec / 1000000000;
     105    req.tv_nsec %= 1000000000;
     106    struct timespec rem;
     107    if(nanosleep(&req,&rem)!=0) Err("error in nanosleep\n");//todo, handle EINTR
     108  } else {
     109    Err("error resume time is passed by %lldns\n", ( current-time));
    102110  }
    103111#endif
     
    112120        }
    113121#else
    114   usleep(time * 1000);
     122  //usleep(time * 1000);
     123  struct timespec req;
     124  req.tv_nsec = time * 1000000;
     125  req.tv_sec = req.tv_nsec / 1000000000;
     126  req.tv_nsec %= 1000000000;
     127  struct timespec rem;
     128  if(nanosleep(&req,&rem)!=0) Err("error in nanosleep\n");//todo, handle EINTR
    115129#endif
    116130}
     
    124138        }
    125139#else
    126   usleep(time);
     140  //usleep(time);
     141  struct timespec req;
     142  req.tv_nsec = time * 1000;
     143  req.tv_sec = req.tv_nsec / 1000000000;
     144  req.tv_nsec %= 1000000000;
     145  struct timespec rem;
     146  if(nanosleep(&req,&rem)!=0) Err("error in nanosleep\n");//todo, handle EINTR
    127147#endif
    128148}
  • trunk/lib/FlairCore/src/Thread_impl.cpp

    r186 r202  
    232232#else
    233233  self->SleepUntil(next_time);
    234   next_time += period;
     234  Time current = GetTime();
     235  if(current>next_time+period) self->Err("overrun of %lld\n", current-next_time);
     236  while (next_time < current) {
     237    next_time += period;
     238  }
    235239#endif
    236240  ComputeLatency(GetTime());
     
    326330  if(last!=0)
    327331#endif
    328     { Printf("Thread::%s :\n", self->ObjectName().c_str()); }
     332    { Printf("Thread::%s :\n", self->ObjectName().c_str());
     333    if(period_set) {Printf("    period (ns): %lld\n", period);}}
    329334#ifdef __XENO__
    330335    Printf("    number of context switches: %i\n", info.ctxswitches);
     
    349354      Printf("    max latency (ns): %lld\n", max_latency);
    350355      Printf("    latency moy (ns): %lld\n", mean_latency / cpt);
    351       Printf("    itertions: %lld\n", cpt);
     356      Printf("    iterations: %lld\n", cpt);
    352357    }
    353358  }
Note: See TracChangeset for help on using the changeset viewer.