Subject: Re: usleep doesn't work
To: None <email@example.com>
From: maximum entropy <firstname.lastname@example.org>
Date: 08/18/1997 05:44:22
>From: maximum entropy <email@example.com>
>>From: Rick Byers <firstname.lastname@example.org>
>>usleep() on my NetBSD-1.2G/i386 (Aug 14) appears to be broken. A call to
>>usleep(15000000) sleeps for 15 seconds on my NetBSD-1.2.1 box, but
>>promptly returns on my -current machine. Does this happen to others as
>>well? I'm just going to use nanosleep, but usleep being broken would
>>probably mess up some other things.
>I can verify that usleep((unsigned int)15000000) returns immediately,
>on NetBSD/i386 from around Aug 11.
>On NetBSD/vax from Aug 16 I cannot reproduce this.
>So, most likely either it's an i386-specific bug, or it's been fixed
It doesn't seem to be i386-specific, I think the libc on my vax is out
of date e.g. still using the old usleep() implementation.
It seems to be a simple integer overflow. Please try the following
--- /usr/src/lib/libc/gen/usleep.c Tue Jul 22 07:12:44 1997
+++ ./usleep.c Mon Aug 18 05:37:53 1997
@@ -55,8 +55,8 @@
struct timespec ts;
- ts.tv_sec = 0;
- ts.tv_nsec = useconds * 1000;
+ ts.tv_sec = useconds / 1000000;
+ ts.tv_nsec = (useconds % 1000000) * 1000;
entropy -- it's not just a good idea, it's the second law.
This message may refer to a product containing software developed by
Christopher G. Demetriou for the NetBSD Project.