This preview shows page 1. Sign up to view the full content.
Unformatted text preview: cu...homenet2run/tcpip/tcp-ip-illustrated/append_b.htm (1 of 3) [12/09/2001 14.48.00] Appendix B: Computer Clocks 36
79 Figure B.1 Distribution of time required to call gettimeofday 10,000 times on
The total clock time required to run the program was 0.38 seconds, on an otherwise idle
system. From this we can say that the time for the process to call gettimeofday is
about 37 microseconds. Since the ELC is rated around 21 MIPS (million instructions per
second), 37 microseconds corresponds to about 800 instructions. This seems reasonable
for the kernel to handle a system call from a user process, execute the system call, copy
back 8 bytes of results, and return to the user process. (MIPS ratings are questionable,
and it's hard to try to measure instruction times on current systems. All we're trying to do
is get a rough idea and see if the values make sense.)
From this simple experiment we can say that the values returned by gettimeofday do
contain microsecond resolution.
If we run similar tests under SVR4/386, however, the results are different. This is
because many 386 Unix systems, such as SVR4, only count the 10-ms clock interrupts,
and don't try to provide any higher resolution. Figure B.2 is the distribution of the 9,999
differences under SVR4 on an 25 Mhz 80386.
Microseconds Count 0
128 Figure B.2 Distribution of time required to call gettimeofday 10,000 times under
These values are worthless, since the differences are normally less than 10 ms, which is
treated as 0. About all we can do on these systems is measure the clock time on an idle
system, and divide by the number of loops. This provides an upper bound, since it
includes the time required to call printf 9,999 times, writing the results to a file. (In
the SPARC case. Figure B.1, the differences did not include the printf times since all
10,000 values were first obtained, and then the results were printed.) Under SVR4 the
clock time was 3.15 seconds, yielding 315 microseconds per system call. This sys...
View Full Document
This test prep was uploaded on 04/04/2014 for the course ECE EL5373 taught by Professor Guoyang during the Spring '12 term at NYU Poly.
- Spring '12