I've read in one of the include header files that _sleep
is an obsolete function, could someone please explain
why _sleep(0) appears to free up the processor to such
a degree and also why is it now obsolete?
Also, if you highlight a MS-DOS window running a Sleep(0)
application, it raises its Performance Monitor line to
100% and every other process regardless drops to 0%. If
the MS-DOS window was running a _sleep(0) application,
this does not occur.
Regards,
Chris Mitchell.
Are you sure you want to do a Sleep(0)? If no other task
needs the CPU at that instant, the CPU is given back to your app
for another timeslice or until the next call to Sleep(0).
If you are doing much processing at all between Sleep(0) calls,
you will still be using a lot of the system except when the
system is very busy and there is always some task waiting for
the CPU. (Note, if you don't do much work between Sleep(0) calls
this isn't a problem... Your app will look like it is using lots
of CPU whenever the system isn't busy, but it won't be taking it
from anyone else).
I'd suggest using Sleep(200), or something tuned to your
needs. By sleeping for a non-zero but still short time, you
will avoid being called in a hard loop, and guarantee lots of
time for other applications.
Discussion of Sleep(0) vs _sleep(0) deleted.
The difference is that _sleep(0) results in a call
to Sleep(1). Sleep(0) obviously does not release the time slice
at all.
Jeffrey Altman * PO Box 220415 * Great Neck, NY * 11022-0415 * (516) 466-5495
NEW: OS/2 C-Kermit 5A(191):
ftp://kermit.columbia.edu/kermit/archives/cko191.zip
http://www.columbia.edu/kermit/cko191.html