Re: [tkined] Question regarding Scotty job & snmp extensions

Juergen Schoenwaelder (schoenw@gaertner.de)
Thu, 4 Sep 1997 14:29:45 +0200

Heiko Boch <boch@lrc.di.epfl.ch> said:

Heiko> Are SNMP callbacks equal to jobs?

A job is just a wrapper around the Tcl event loop to schedule events
to execute a Tcl command in regular intervals. An SNMP callback is a
Tcl command that is evaluated exactly once when either a) an SNMP
response is received or b) a timeout occurs.

Heiko> In particular, is it possible that a SNMP callback interrupts
Heiko> processing of a job or vice versa?

Everything in Tcl is event driven. This means that an evaluation is
never interrupted. This means in practice:

a) You don't have to care about any synchronization because a single
command sequence or procedure is never interrupted.

b) You have to write non-blocking code, which means that you have to
implement things that might take some considerable amount of time
in an asynchronous fashion.

c) In some case, you can process events within some blocking code
(e.g. a loop) by using the update or vwait Tcl commands. However,
you have be very careful here because you can't really control
which events are processed and which not. This can lead to all kind
of funny side effects if an event deletes some information your
loop depends on. You also have to be careful not to stack update
calls on each other in an uncontrolled way.

I recommend to avoid c) wherever feasible. There is a paper by John
Ousterhout about the issue of threads-driven versus event-driven
programming, which gives you more background information. You will
find it somewhere on John's WWW page.
Juergen

-- 
Juergen Schoenwaelder  schoenw@ibr.cs.tu-bs.de http://www.cs.tu-bs.de/~schoenw
Technical University Braunschweig, Dept. Operating Systems & Computer Networks
Bueltenweg 74/75, D-38106 Braunschweig, Germany.     (Tel. +49 531 / 391-3283)
--
!! This message is brought to you via the `tkined & scotty' mailing list.
!! Please do not reply to this message to unsubscribe. To subscribe or
!! unsubscribe, send a mail message to <tkined-request@ibr.cs.tu-bs.de>.
!! See http://wwwsnmp.cs.utwente.nl/~schoenw/scotty/ for more information.