[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MCL2.0 and Mac completion routines...



> 
> Greetings!
> 
> What is the best way to have an asynchronous ATP (or ADSP) completion 
> routine invoke function within MCL2.0? I'm assuming that defpascal
> and defccallable should not be invoked from within a completion routine 
> [I don't think that a GC at interrupt time would be welcomed...:-) ]
> 
> 

There are other constraints that make defpascal/defccallable unsuitable
for asynchronous callbacks.  (Among other things, the lisp kernel has
no way of knowing where the lisp's stack pointers were pointing when
the interrupt occured; asynchronous callbacks written in MCL would probably 
have to run on their own stacks or otherwise address this problem.)

> I can't use AppleEvents because the machine (a VAX) generating the message 
> isn't a Mac and doesn't support AppleEvents or the PPCToolBox (it does support
> ATP and ADSP). I don't want to use MacTCP because 
>   a) TCP/IP isn't installed
>   b) Some communications hardware gets confused when more than one 
>      protocol is being used. So... I'd love to stay within a single
>      protocol (AppleTalk!)
> 
> 
> These are the choices I can see:
> 
> 1. Code the callback routine in C, have it store its output in a 
>    global variable in a FF environment. Then I could poll this location 
>    via an ff-call....(from *eventhook* or something like that...)
> 
>    I don't like this because I have to chew up CPU cycles for something
>    that should be asynchrounous. However, it is simple and it would be
>    pretty painless.
> 
> 
> 2. Place the completion routine in a background task, and have this application
>    send an AppleEvent to MCL. From there it is easy...
> 
>    I don't like this because it I don't think it is elegant (and it might
>    be a pain to maintain... periodically one has to check that the 
>    background application is still there... or have it send an AE to 
>    MCL if it exits gracefully... but what if it doesn't?).
> 
> 
> 3. Use defccallable... but enclose the lisp function in the form
>    without-interrupts. 
> 
> I'm hoping that I've missed something in the documentation... after
> all... #'apropos sez that there are plenty of things that know about A5!
> 
> Any suggestions welcomed!
> 
> Thanks
> Sean Doyle
> doyle@sisu.mgh.harvard.edu
> 
> 
(3) isn't workable.  I'm not sure whether or not (2) is (can you post
AppleEvents at interrupt time ?).  If you choose (1), note that you
probably wouldn't be able to do much more than set a flag or two at
interrupt time and poll in the foreground regardless of whether the
completion routine was written in Lisp or some other language.

I don't remember the details, but I'm fairly sure that HyperLisp (MIDI
composition and performance software) has had to deal with asynchronous
callbacks from the MIDI manager.  You might ask Joe Chung (joe@media-lab.
media.mit.edu) for some of the gory details ...