[Q][VM] mulithreaded ?

Tim Rowledge tim at sumeru.stanford.edu
Sat Jul 19 17:43:49 UTC 2003


Martin Drautzburg <martin.drautzburg at web.de> wrote:

> Is it true that
> 
> o in order to access an existing shared library I need to either
>   create a new primitive (named or numbered) or use the FFI framework.
Yes, in practical terms that is true. There _are_ other ways but not
ones I'd advise people to use.
> 
> o the VM is not multithreaded, i.e. squeak will be frozen while the
>   call is being executed.
Yes and no. Some platforms use threads for i/o handling but the vm per
se is not multithreaded.
> 
> What can I do if I have a library function that does not return
> instantly ? Would it be okay to create a thread in a wrapper C code ?
Yes  _IF_ and only if conditions such as the following apply:-
a) the plugin is for a very specific thing that only works with the
platform, so portatbility is irrelevant. For example it would be
entirely ok to write a VM plugin that interfaced with Windows-specific
APIs and to use Windows specific threading in it. After all, it won't be
any use on Mac or linux or RiscOS.
b) the plugin is private and you have no intention of ever letting
anyone else use it - then you can do anything you please!
c) you are able to wrap the calls in such a way that non-threaded
systems can still use them even if it is a bit inconvenient. See the
examples of sqResolverStartAddrLookup() in the unix SocketPlugin file
'sqUnixSocket.c'.
d) you are able to defend yourself against the machete waving hordes
that can't use your code because they don't have thread-enabled systems.
:-)


tim
--
Tim Rowledge, tim at sumeru.stanford.edu, http://sumeru.stanford.edu/tim
No program done by a hacker will work unless he is on the system.



More information about the Squeak-dev mailing list