[Tutor] Re: how do I sleep?

dman dsh8290@rit.edu
Wed, 28 Nov 2001 12:32:24 -0500


On Wed, Nov 28, 2001 at 10:07:21AM +0000, Pablo Prieto wrote:
| Hello again.
| 
| >Hi Pablo.  Just a tip : when posting a question start by composing a
| >new message with a relevant Subject: line, rather than replying to an
| >unrelated message.
| 
| Sorry. I forgot to changed it and I sent it .

Ok, not that big of a deal (if you don't make a habit of it).

| >import time
| ># a long loop
| >while 1 :
| >    print "this takes lots of time ;-)"
| >    time.sleep( 5 )  # 5 seconds, approximately
| >
| >
| >The disadvantage of doing this is that your long loop now takes a lot
| >more time (as measured by a clock on the wall).  I don't know about
| >NT, but a decent kernel will perform the time-slicing between
| >processes on its own.
| 
| I'm sure you know enough about NT to know it's an indecent kernel :)

yeah :-).

| Anyway, there must be a way to give control to the NT otherwise it would be
| unusable a serious Python program in NT (not to talk about '95 flavour
| O.S.'s).
| 
| I think I'm gonna search in the API. I'll tell you if something good
| happens.

I'm not aware of anything like that (in Python or C) other than
"sleep".  If you sleep, then your process isn't doing anything and the
kernel will (should!) give the CPU to another process that is doing
something.  That's what you're looking for, right?

-D

-- 

Contrary to popular belief, Unix is user friendly.
It just happens to be selective about who it makes friends with.
                                               -- Dave Parnas