usleep
I'm not sure what you are saying, but yes there are 1 million microseconds in a second.... 1000000 micro seconds that is. So my loop seems correct. Also, I am running this on a 2 GhZ processor, so I doubt the 1000 calls to usleep can add that much overhead. I think something is wrong with the library or the kernel. ----- Original Message -----
From: Alan Bort <[email protected]>
Date: 11 Jun 2003 19:08:34 +0300
To: Lee Chin <[email protected]>
Subject: Re: usleep
Quoted 40 lines
for the #include statemen I assume you are using some sort of C languagbe (even C, C++ or C#) Well... my man of usleep says that it makes the system wait for any number of microseconds... make the maths.
Anyway... I really don't remebmer the value of a microsecond... I THINK it was something like "1 x 10 ^ -6" or something alike... (excuse the quotation aberration).
Quoted 23 lines · Lee Chin
I would think the following code would wait for 1 second each itteration before printing hello, but it waits way too long. Replacing the for loop body with a usleep(1000000) works great... what am I missing here?
Thanks
Lee#include <
unistd.h>int
main(){ while (1) { int i; printf("hello\n"); for(i = 0; i < 50; i++) { usleep(1000); } }}
Signature · 5 lines
Alan Bort Linux Registered User 298277 -Country Manager- [http://counter.li.org] [ http://www.linuxquestions.org ] Username: Ciccio [ http://es.tldp.org ] Ciccio.-
Signature · 9 lines
__________________________________________________________ Sign-up for your own FREE Personalized E-mail at Mail.com http://www.mail.com/?sr=signup - To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.linux-learn.org/faqs