linux kernel - Why is clock_nanosleep sleeping for 20 ms when it is configured to sleep for 10 ms? -
i trying run task periodically every 10 ms. before executing task, want check consistency of clock_nanosleep
. took 10 values check time clock_nanosleep
sleeping, varying in between 19-22 ms, should 10 ms.
i running thread sched_fifo, pri-98, hrtimers enabled in linux. currently, using 3.14.29 linux kernel rt patch. clock_nanosleep
require configuration in linux apart hrtimers?
below code snippet running:
struct timespec arr[20]; while(1) { clock_gettime(clock_monotonic,&check1); if(i<20) { arr[i].tv_sec = check1.tv_sec; arr[i].tv_nsec = check1.tv_nsec; ++i; } check1.tv_nsec += p_ct->period; clock_nanosleep(clock_monotonic, timer_abstime, &check1, null); clock_gettime(clock_monotonic,&check); if(i<20) { arr[i].tv_sec = check.tv_sec; arr[i].tv_nsec = check.tv_nsec; ++i; } }
- check return values of
clock_gettime
,clock_nanosleep
. maybe there interruption signal - run 2 sequenced
clock_gettime
, calculate average execution time ofclock_gettime
. don't think around 9-12ms, let's check
code:
int r1 = clock_gettime(clock_monotonic,&check1); int r2 = clock_gettime(clock_monotonic,&check); if(i<20) { arr[i].tv_sec = check1.tv_sec; arr[i].tv_nsec = check1.tv_nsec; ++i; } if(i<20) { arr[i].tv_sec = check.tv_sec; arr[i].tv_nsec = check.tv_nsec; ++i; } printf("%d %d\n", r1, r2);
Comments
Post a Comment