Re: Pausing without hogging the CPU

Juergen Schoenwaelder (schoenw@ibr.cs.tu-bs.de)
Tue, 20 Feb 1996 19:53:18 +0100

Hi!

Graeme McKerrell <graemem@pdd.3com.com> said:

Graeme> I am using an Object Oriented extension to scotty/TCL which I
Graeme> have written, and am aiming to be able to process events such
Graeme> as SNMP traps asynchronously. I am also maintaining an uptime
Graeme> counter for each object, which I am using for timing pauses
Graeme> and test times. The problem I have is how to make a script
Graeme> pause for a predetermined time without hogging too much of the
Graeme> CPU time.

Graeme> At the moment I use the following:

Graeme> 1) a background task which uses 'after' to rekick itself off
Graeme> every tenth of a second, as well as incrementing the uptime counter.
Graeme> 2) a pause function which sits in a loop monitoring the uptime
Graeme> variable for the required end time, whilst calling 'update' to allow
Graeme> the background tasks in.

Graeme> This setup has the disadvantage that sitting in the pause loop
Graeme> causes the CPU usage to go through the roof.

Can you please provide some more details what you are trying to do (or
a simple demo script)? Or did you already solve the problem (sorry for
the long delay)?

Juergen