Emacs and Threading, Take 2

I’ve recanted. Contrary to my earlier post on this topic, I now think implementing threading in Emacs is possible. A patch from Giuseppe Scrivano inspired me, and I started my own patch to do it.

This was sort of fun. I wrote a batch script in elisp to rewrite some of the Emacs sources — yay semantic patching!

Thanks to Giuseppe, this is now hosted on Gitorious. We’re both working there, on different branches, merging code back and forth. I’ve mostly been working on variable bindings, and he’s very active, both with low-level changes and cool things getting Gnus to work in a separate thread.

If you’re interested in helping out, we discuss it on emacs-devel, but really we’d welcome any sort of contact.

5 Comments

  • Oh yes, threading in Emacs would be so nice! Happy hacking.

  • I have read the post from Giuseppe on the mailing list, but it is not so informative, can you explain to us your overall design idea?
    I use to work on a two-level thread library in which we can create M user-level threads on top of N pthreads. I used to have the idea that put current Emacs into a “main” user thread, and create additional thread-safe data structures. these new data structures can be accessed by any user-level threads, but the concurrent access to the old structures are limited in certain ways(specific to detailed situations), so that we still have the backward compatibility. But it seems that most people do not like this idea.

  • [...] http://tromey.com/blog/?p=654 a few seconds ago from Gwibber [...]

  • @Lin Li:

    Our first goal is cooperative multi-threading. However, this is done using native threads, and we are trying not to make all our decisions in a way that will let us transition to preemptive threading in the future. The reason we started this way is that full threading is very hard: there are many data structures in Emacs that would require locks, and tracking down all of them is likely to be hard.

    The biggest part of the patch was implementing let bindings in a thread-safe way.

    Right now we also have buffer locking — only a single thread can work in a given buffer at a time. This is done to avoid problems with locks and with buffer-local bindings. Unfortunately it also causes some problems, so I think we’ll need something better here.

  • Can’t wait ’til I don’t have to run Gnus in a separate frame!

Join the Discussion

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>