From: jmarin AT pyy DOT jmp DOT fi (Jukka Marin) Newsgroups: comp.os.msdos.djgpp Subject: usleep() and 95dos problems Date: 24 Jul 1997 07:07:03 GMT Organization: Muikku Internet Server (JMP-Electronics) Lines: 38 Message-ID: NNTP-Posting-Host: pyy.jmp.fi To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk I'm new to djgpp (and dos programming in general :-) I'm trying to write a packet protocol which requires small, but accurate time delays. I was happy to find the usleep() call - and unhappy to find out it doesn't work properly. Not on my hardware, at least. If I have a loop like this: while(1) { printf("huu\n"); for (i = 0; i < 1000; i++) usleep(1000); } The printf() is being run as fast as it can, it seems - ie. the usleep() call doesn't delay the execution at all. If I change the usleep argument to 100000, I get a delay - but I need 1 ms delays, not 100 ms ones. I am running the programs in a dos window of win95 on a 486/80. How can I create a delay of 1 ms - which is 1 ms on every machine from the lowliest 386 to the fastest K6/233? Another problem: If I hit ctrl-c while the machine is executing a long usleep(), I get a software error message from win 95 ("this program has performed an illegal operation an dwill be terminated" or some such). Is there a bug in the djgpp libraries or am I doing something wrong? (Even the loop above causes the problem, so I don't think the bug is in my code.) I'm using gcc2721b.zip, if that matters. Thanks in advance, -jm -- 1503 kHz @ 22:30 EET DST Mon-Fri ---> http://www.jmp.fi/~jmarin/ <---