Callbacks from C into Squeak

John M McIntosh johnmci at smalltalkconsulting.com
Tue Dec 19 00:16:50 UTC 2006


With FFI on unix you can easily used the mmap calls to share memory  
between a VM an a child process. Of course this is memory outside of  
squeak object space, but you could use the logic for ExternalObject/ 
ExternalAddress to map shared memory addresses to enable the sharing  
of data between processes.

I'll note I share the drawing surface between the os-x carbon browser  
plugin and the child process headless VM that launched for  the  
plugin support. The plugin funnels UI and browser events to/from the  
VM via pipes and the VM draws to the shared surface as a Quartz  
bitmap and sends draw coordinates to the plugin which in turn takes  
the given coordinates and draws to the browser window using the  
shared bitmap.

There are some setup issues with mmap that aren't really well  
documented, look at the VM source code for clues, otherwise you'll  
waste a bunch of time trying to figure out why it doesn't work.

On Dec 18, 2006, at 3:14 PM, David T. Lewis wrote:

> On Mon, Dec 18, 2006 at 06:42:35PM +0100, Klaus D. Witzel wrote:
>> I've worked with mainframe computers of these people (beware: gif  
>> patent
>> holders)
>>
>> - http://www.google.com/search?q=WebTx+ipc+shared+memory
>>
>> for quite some time. We had a supplemental Unix box integrated  
>> into the
>> mainframe (other users choose to integrate MS boxen) for various  
>> purposes.
>> The interface was very versatile and the fastest transport was shared
>> memory (of course, for very high volume bank transactions ...).  
>> IIRC this
>> interface establishes connection using pipes and then just tells  
>> "new data
>> arrived" (like with your call/callback), after updating shared  
>> memory.
>>
>> Perhaps such a shared memory approach is of use for you, perhaps in
>> concert with Dave's pipe solution (but I don't know of any Squeak  
>> support
>> for shared memory).
>
> Interesting idea. There is no support for shared memory in Squeak  
> right
> now, but in principle it's no different from other OS and C runtime  
> calls
> in the OSProcessPlugin. I think that the shared memory interface  
> for Unix
> platforms is fairly well standardized, and there are Win32 analogues,
> so that it could be provided across most platforms.
>
> Dave
>
>

--
======================================================================== 
===
John M. McIntosh <johnmci at smalltalkconsulting.com>
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
======================================================================== 
===





More information about the Squeak-dev mailing list