Changeset 202 in flair-src for trunk/lib/FlairCore
- Timestamp:
- Nov 2, 2017, 3:04:47 PM (7 years ago)
- Location:
- trunk/lib/FlairCore/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairCore/src/Thread.cpp
r139 r202 91 91 if (status != 0) { 92 92 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()); 95 95 } 96 96 // Printf("rt_task_sleep_until, resume time: %lld, actual time: … … 99 99 Time current = GetTime(); 100 100 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)); 102 110 } 103 111 #endif … … 112 120 } 113 121 #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 115 129 #endif 116 130 } … … 124 138 } 125 139 #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 127 147 #endif 128 148 } -
trunk/lib/FlairCore/src/Thread_impl.cpp
r186 r202 232 232 #else 233 233 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 } 235 239 #endif 236 240 ComputeLatency(GetTime()); … … 326 330 if(last!=0) 327 331 #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);}} 329 334 #ifdef __XENO__ 330 335 Printf(" number of context switches: %i\n", info.ctxswitches); … … 349 354 Printf(" max latency (ns): %lld\n", max_latency); 350 355 Printf(" latency moy (ns): %lld\n", mean_latency / cpt); 351 Printf(" iter tions: %lld\n", cpt);356 Printf(" iterations: %lld\n", cpt); 352 357 } 353 358 }
Note:
See TracChangeset
for help on using the changeset viewer.