[Q][VM] mulithreaded ?

Andreas Raab andreas.raab at gmx.de
Sat Jul 19 18:47:10 UTC 2003


Tim,

> > 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.
> :-)

Actually you forgot the most important condition:

e) You do not pass any arguments around which may be relocated due to GC
activity. In my understanding that's the most important reason why we don't
use any kind of threaded calls within primitives.

Cheers,
  - Andreas



More information about the Squeak-dev mailing list