[pypy-dev] interrupts, preemption, threads

Daniel Farina drfarina at gmail.com
Fri Jan 4 13:03:55 CET 2008


On Fri, 2008-01-04 at 12:35 +0100, Armin Rigo wrote:
> Hi Daniel,
> 
> On Fri, Jan 04, 2008 at 01:46:40AM -0800, Daniel Farina wrote:
> > I wasn't able to locate any of the keywords ['interrupt',
> > 'preemption', 'thread'] in the web documentation, so I come to
> > the list to ask what is roughly the status of these things in the
> > generated PyPy virtual machines on whatever applicable platforms.
> 
> We only have limited support for threads at the moment.  I think we have
> no specific support for high-level backends (JVM, CLI).  On the
> low-level backends (C, LLVM), you can use thread primitives to start
> threads and use locks as you would do in C.

That seems like a pretty useful subset already...

>   In addition there is
> support in the translator for automatically inserting custom code before
> and after every external function call.  We use this in PyPy's Python
> interpreter: it uses a global interpreter lock (GIL), which is released
> and reacquired around each external function call.  (This is similar to
> CPython but we don't have to put the release/reacquire code everywhere
> by hand.)
> 

Nifty. Noted.

> > - timeouts on arbitrary code fragments
> > - writing a preemptive scheduler of closures
> > - making use of two processors 
> > - triggering garbage collections
> 
> We have no specific support for all this.  Multiple threads will run on
> multiple processors just like in C.  Timeouts can be done in a
> platform-specific way with signals.  For the rest, our custom garbage
> collectors are not thread-safe, at least yet; only the Boehm collector
> is, but its performance is not very good in multithreaded programs.
> 

Is there going to be some cross-platform support for this? 

As for examples, I imagine pypy/module/signal[/test] is the place to go,
correct?
 
Thanks,
fdr





More information about the Pypy-dev mailing list