Pausing without hogging the CPU

Graeme McKerrell (graemem@pdd.3com.com)
Mon, 22 Jan 96 10:11:06 GMT

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

At the moment I use the following:

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

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

I'm sure that the problem can be solved 'nicely' as scotty's SNMP access
routines perform exactly the fucntionality I require i.e. stall the
processing of a script whilst still letting background tasks take
place.

I orignially was trying to just use the 'after' command to wait for
the required time, but found that no other 'after' triggered tasks got
updated!

Any help would be appreciated
Yours
Graeme McKerrell

-- 
 ______________________________________________________
/     ___                                              \
|   ,'   `                                        """   | 
|   |        ;--,  .~~~,  .~~~,  .~~,~~.  .~~~,   O O   | 
|   |  ``;   |     |   |  |---'  |  !  |  |---'  ` ^ '  | 
|   `.__,'  .!.    `._.'. `._.'  `.   .'  `._.'  (\_/)  |
|                                                 \_/   |
|               graemem@pdd.3com.com                    | 
\______________________________________________________/