sleep()

new topic     » topic index » view thread      » older message » newer message

hey all,

The help file doesn't say sleep(0) is valid, or what it would do, so i put
together a small
program to check it out...

----------------------------------------------
include get.e
include misc.e

object key, wastetime
wastetime = 0

puts(1,"t= "&sprintf("%d",time())&"\n")

for loop = 1 to 10000000 do
 wastetime += 1
end for

puts(1,"t= "&sprintf("%d",time())&"\n")

for loop = 1 to 10000000 do
 --sleep(0)
end for

puts(1,"t= "&sprintf("%d",time())&"\n")

for loop = 1 to 10000000 do
 sleep(0)
end for

puts(1,"t= "&sprintf("%d",time())&"\n")

key = wait_key()
abort(0)
------------------------------------

which prints out:

t= 0 -- init the time()
t= 1 -- the inc of wastetime takes a sec
t= 2 -- doing nothing 10,000,000 times takes a sec too
t= 10 -- sleeping(0) 10,000,000 times takes 8 secs

So am i correct in assuming that sleep(0) tells windose's task manager to jump
tasks,
to let the next application in it's list run, but without a *timed* sleep
applied to the Eu
program? If this is what is happening, shouldn't this be in the help files? 

Or is the overhead in the sleep(0) call taking the 8 secs, and windose is not
telling the
task manager to go do something else? If this is the case, Robert, can you make
it tell
the OS to goto the next task without a timed sleep, rather like the cooperative 
timesliced multitasking in win3.1?

Kat

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu