www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/12/18/10:46:01

Message-ID: <19981218134712.25514.qmail@www0s.netaddress.usa.net>
Date: 18 Dec 98 08:47:12 EST
From: ADAM SCHROTENBOER <a DOT j DOT schrotenboer AT usa DOT net>
To: dj-admin AT delorie DOT com, djgpp AT delorie DOT com
Subject: Re: [Re: cpu eater]
Mime-Version: 1.0
Reply-To: djgpp AT delorie DOT com

If you want to release the time slice, write your own sleep function.

Maybe something like this:

void sleep(int msec)
{
  clock(); //Can't remember which fxn to use
  do
    _dpmi_yield();
  while(!(clock()>=msec));
}

I'm not sure that I wrote this right, but it should work.

dj-admin AT delorie DOT com wrote:
On Thu, 17 Dec 1998 10:56:03 -0500, in comp.os.msdos.djgpp you wrote:

>I am wondering why it appears that the sleep function with
>the code compiled under DJGPP on the NT seems to use 100% of my CPU???

Perhaps because DJGPP is DOS and DOS is not multitasking sleep just
wastes time rather than giving the time back to the OS to be used by
other processes.

>I was expecting the program to sleep quietly for 5 secs and then
>continue
>the while();
>
>The same code is working fine on the UNIX machine.
>if this is NT being silly then how can I get around this?

No this is not NT being silly because sleep works as expected when
compiled with VC  and Borland 5.0




____________________________________________________________________
Get free e-mail and a permanent address at http://www.netaddress.com/?N=1

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019