From: Frank van de Pol <fvdpol@home.nl>
To: "Richard B. Johnson" <root@chaos.analogic.com>
Cc: "Salvatore D'Angelo" <dangelo.sasaman@tiscalinet.it>,
Chris McDonald <chris@cs.uwa.edu.au>,
linux-kernel@vger.kernel.org
Subject: Re: gettimeofday problem
Date: Tue, 25 Jun 2002 01:34:06 +0200 [thread overview]
Message-ID: <20020624233406.GA18854@idefix.fvdpol.home.nl> (raw)
In-Reply-To: <Pine.LNX.3.95.1020624153816.15499A-100000@chaos.analogic.com>
Richard,
I gave your test program a try, and the problem is reproducably triggered:
frank@idefix:~/projects$ ./tod
Failed after 2008
a = 1024961239107823, b = 1024961238254652
frank@idefix:~/projects$ ./tod
Failed after 1394
a = 1024961252215231, b = 1024961239964379
frank@idefix:~/projects$ ./tod
Failed after 110179
a = 1024961241574880, b = 1024961241573638
frank@idefix:~/projects$ ./tod
Failed after 4891
a = 1024961242145265, b = 1024961242144027
frank@idefix:~/projects$ ./tod
Failed after 45008
a = 1024961243210834, b = 1024961242943904
frank@idefix:~/projects$ ./tod
Failed after 6695
a = 1024961243405068, b = 1024961243403828
frank@idefix:~/projects$ ./tod
Failed after 1487
a = 1024961244216903, b = 1024961244093738
frank@idefix:~/projects$ ./tod
Failed after 3275
a = 1024961245674712, b = 1024961245673487
frank@idefix:~/projects$ ./tod
Failed after 42122
a = 1024961259065626, b = 1024961246333377
frank@idefix:~/projects$ ./tod
Failed after 425
a = 1024961253600435, b = 1024961252652402
frank@idefix:~/projects$
Possibly it might have to do with the fact that my machine is an SMP box
(dual pentium II)
$ uname -a
Linux idefix 2.4.18 #3 SMP Sat Apr 20 14:35:58 CEST 2002 i686 unknown
In fact it is almost symmetrical (one CPU seems to be faster than the other,
eventhough they are running at the same clock speed).
$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 3
model name : Pentium II (Klamath)
stepping : 4
cpu MHz : 333.225
cache size : 512 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov mmx
bogomips : 665.19
processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 5
model name : Pentium II (Deschutes)
stepping : 2
cpu MHz : 333.225
cache size : 512 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx
bogomips : 748.74
On Mon, Jun 24, 2002 at 03:44:02PM -0400, Richard B. Johnson wrote:
> On Mon, 24 Jun 2002, Salvatore D'Angelo wrote:
>
> > In this piece of code I convert seconds and microseconds in
> > milliseconds. I think the problem is not in my code, in fact I wrote the
> > following piece of code in Java, and it does not work too. In the for
> > loop the 90% of times b > a while for 10% of times not.
> >
> > class Prova {
> > public static void main(....) {
> > for (;;) {
> > long a = System.currentTimeMillis();
> > long b = System.currentTimeMillis();
> >
> > if (a > b) {
> > System.out.println("Wrong!!!!!!!!!!!!!");
> > }
> > }
> > }
> > }
> >
> >
>
> This has been running since I first read your mail about 10:00 this
> morning. The kernel is 2.4.18
>
> #include <stdio.h>
> #include <sys/time.h>
> #define MICRO 1000000
> #define ULL unsigned long long
> int main(void);
> static ULL tim(void);
>
> static ULL tim()
> {
> struct timeval t;
> (void)gettimeofday(&t, NULL);
> return (ULL)t.tv_sec * MICRO + (ULL)t.tv_usec;
> }
> int main()
> {
> ULL a, b, cnt;
> for(cnt=0;;cnt++)
> {
> a = tim();
> b = tim();
> if(b < a)
> break;
> }
> printf("Failed after %llu\n", cnt);
> printf("a = %llu, b = %llu\n", a, b);
> return 0;
> }
>
> It seems to work fine. That said, I didn't use your code or check
> for the possibility of a sign-change miscompare. I just made sure
> I don't have any by using unsigned stuff. You may want to try
> this code to see if you have a compiler (or coding) problem.
>
>
> Cheers,
> Dick Johnson
>
> Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).
>
> Windows-2000/Professional isn't.
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
+---- --- -- - - - -
| Frank van de Pol -o) A-L-S-A
| FvdPol@home.nl /\\ Sounds good!
| http://www.alsa-project.org _\_v
| Linux - Why use Windows if we have doors available?
next prev parent reply other threads:[~2002-06-24 23:34 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-06-24 8:55 Salvatore D'Angelo
[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 [this message]
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=20020624233406.GA18854@idefix.fvdpol.home.nl \
--to=fvdpol@home.nl \
--cc=chris@cs.uwa.edu.au \
--cc=dangelo.sasaman@tiscalinet.it \
--cc=linux-kernel@vger.kernel.org \
--cc=root@chaos.analogic.com \
/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®