On Thursday 18 July 2002 01:40 am, Amit Kucheria wrote: > On Wed, 17 Jul 2002, Karthik M wrote: > > hi everyone, > > > > as a follow up to the previous posting regarding > > effects of measurment, I was testing gettimeofday(). > > The results that i got out of my test program were not > > consistent and were varying. Wanted to get an opinion > > abt it. > > > > ----snip----- > > > > the values are varying a lot and did'nt have a clue > > why it was the case. Did a little search on google but > > could'nt find an answer. > > IMHO "Scheduling granularity" is the key here. The linux system on x86 > architectures has a heartbeat of 100Hz = 10ms. What this means is that > the system tries to complete its range of tasks such as scheduling > various subsystems, checking on blocked I/O, sending & receiving packets > etc etc. every 10ms. Since some tasks have more priority over others, > they might cause a delay for these low priority tasks which are > generally user processes. > If you include #include <sched.h> struct sched_param param; param.sched_priority = sched_get_priority_max(SCHED_FIFO); if( sched_setscheduler(0, SCHED_FIFO, ¶m) < 0) { printf("ERROR: Could not become realtime\n"); exit(0); } You should see a lot less variation. In the tens or hundereds rather than thousands because no other normal processes can go pefore yours. -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/