From: "Salvatore D'Angelo" <dangelo.sasaman@tiscalinet.it>
To: linux-kernel@vger.kernel.org
Subject: gettimeofday problem
Date: Mon, 24 Jun 2002 10:55:31 +0200 [thread overview]
Message-ID: <3D16DE83.3060409@tiscalinet.it> (raw)
Hi,
I am writing a small piece of code that use the gettimeofday routine and
I have noticed a very strange behaviour. If I call the routine two times
in sequence I expect that the second value is greater than or equal to
the first one, but it is not true.
please check the following code.
Sometimes happen that the string "Strange Behaviour" is printed with
kernel 2.4.18.
I tried to find in the Linux Archive patches to solve this problem, but
I didn't find anything (there are emails that talk about gettimeofday,
but probably they do not answer to my questions).
The same thing happen in Java using the System.currentTimeMillis() routine.
#include <fstream.h>
#include <sys/time.h>
// this routine calculate the current time returning its value in long
long format.
long long currentTimeMillis() {
long long t;
struct timeval tv;
gettimeofday(&tv, 0);
t = tv.tv_sec;
t = (t *1000) + (tv.tv_usec/1000);
return t;
}
void main() {
for (;;) {
long long a = currentTimeMillis();
long long b = currentTimeMillis();
if (a>b) {
cout << "Strange Behaviour" << endl;
}
}
}
next reply other threads:[~2002-06-24 8:54 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-06-24 8:55 Salvatore D'Angelo [this message]
[not found] ` <200206240934.g5O9YL524660@budgie.cs.uwa.edu.au>
2002-06-24 10:20 ` Salvatore D'Angelo
2002-06-24 12:46 ` Matti Aarnio
2002-06-24 13:57 ` Salvatore D'Angelo
2002-06-24 18:56 ` Karim Yaghmour
2002-06-26 11:01 ` Gabriel Paubert
2002-07-01 2:30 ` Pavel Machek
2002-07-01 2:29 ` Pavel Machek
2002-06-24 19:44 ` Richard B. Johnson
2002-06-24 23:34 ` Frank van de Pol
2002-06-25 11:42 ` Richard B. Johnson
2002-06-28 18:04 ` george anzinger
2002-06-25 13:36 ` Chris Friesen
2002-06-26 10:58 ` Gabriel Paubert
2002-06-25 0:37 Christian Robert
2002-06-25 0:43 ` Brad Hards
2002-06-25 2:03 ` Christian Robert
2002-06-25 2:47 ` John Alvord
2002-06-25 9:17 ` Christian Robert
2002-06-25 10:00 ` Jan Hudec
2002-07-19 12:17 ` Amos Waterland
2002-06-25 11:45 ` Richard B. Johnson
2002-06-25 11:50 ` Brad Hards
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3D16DE83.3060409@tiscalinet.it \
--to=dangelo.sasaman@tiscalinet.it \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®