Re: mp:process-run-function and a blocking foreign call

Tapio Karras <[email protected]> Tue, 29 Nov 2005 17:50:03 -0800
Newsgroups gmane.lisp.allegro
Message-ID <[email protected]>
Hi Steven,

Glad I was able to help.

Basically, anything that is passed by reference needs to be allocated
in the static space. Basic data types, like integers, floats, etc.,
that are passed by value, don't need to be allocated in the static
space.

:foreign allocated objects are still potentially moved by GC, whereas
:foreign-static-gc allocated objects are in the static space and are
never moved by GC. This makes it very useful when objects must be
passed to a FFI call that releases the heap.

See details at 
http://www.franz.com/support/documentation/7.0/doc/operators/ff/allocate-fobject.htm

Remember that objects allocated in the static space are not always
freed automatically and you may have to free them explicitly.

Tapio

> On 11/29/2005 "Steven E. Harris" wrote:
> 
> Tapio Karras <[email protected]> writes:
> 
> > To allow other MP process to run during the call, the FFI call needs
> > to release the Lisp heap.
> >
> > Look for the :release-heap keyword of def-foreign-call
> 
> Thank you. That did it. I added the ":release-heap :when-ok" arguments
> to my def-foreign-call forms and all now works as expected.
> 
> > The additional challenge is to allocate all FFI arguments in static
> > space, so that they don't get moved by the GC as a result of the
> > other MP processes running while the FFI call is in progress.
> 
> I'm having a hard time understanding what the consequences are of
> using :foreign-static-gc as opposed to the default :foreign
> allocation. For now I went through my code and adapted it to accept an
> allocation option for passing on to all ff:allocate-fobject
> calls. However, I don't understand how to figure out /which/ FFI
> arguments actually need to be allocated in static space.
> 
> --
> Steven E. Harris