strange do_gettimeofday behavior

Olaf Meyer (olafm@denali.cis.upenn.edu)
Wed, 3 Mar 1999 00:34:36 -0500 (EST)


I am experiencing rather strange behavior with the do_gettimeofday routine
on my intel based pc running 2.0.33. When I make to consecutive calls to the
do_gettimeofday function the last timestamp is smaller than the previous
taken timestamp!!

Here's a code snippet:

#define DIFF_USEC(low, hi) \
(1000000L * (hi.tv_sec - low.tv_sec) + (hi.tv_usec - low.tv_usec))

char buffer[ETH_HLEN+sizeof(short)];
struct timeval xmitStart, xmitEnd;

do_gettimeofday(&xmitStart);

memcpy(buffer, &ethHdr, ETH_HLEN);
memcpy(buffer+ETH_HLEN, &type, sizeof(short));

// this sends something over a network interface card
wrt_transmit_buffer(dev, buffer, sizeof(buffer));

do_gettimeofday(&xmitEnd);

diff = DIFF_USEC(xmitStart, xmitEnd);

How can diff be negative?
Please let me know if you have an explanation.

Thanks,

Olaf

P.S. please also e-mail me, since I'm not on the mailing list

-- 
 Olaf Meyer                       | mailto://olafm@seas.upenn.edu    |    _~o
 Computer and Information Science | http://www.seas.upenn.edu/~olafm |  _-\_<,
 University of Pennsylvania       |				     | (*)/'(*)
 Philadelphia, PA 19104-6389, USA | PGP: finger -l olafm@seas.upenn.edu

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/