1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-30 00:51:50 -08:00
Commit graph

20 commits

Author SHA1 Message Date
Tom Tromey
b94de89342 another docstring fixlet 2012-08-19 03:38:30 -06:00
Tom Tromey
266c1c2fd9 minor docstring fixup 2012-08-19 03:36:50 -06:00
Tom Tromey
1fb339bccd add condition-mutex and condition-name 2012-08-19 03:31:57 -06:00
Tom Tromey
9dad5e59e3 ensure name of a thread is a string 2012-08-19 03:26:42 -06:00
Tom Tromey
3cbf5b1d3b ensure name of a mutex is a string 2012-08-19 03:26:09 -06:00
Tom Tromey
977c4aa65f use NILP 2012-08-19 03:25:06 -06:00
Tom Tromey
5651640d57 condition variables
This implements condition variables for elisp.
This needs more tests.
2012-08-19 03:23:03 -06:00
Tom Tromey
b3c78ffa31 refactor systhread.h
This refactors systhread.h to move the notion of a "lisp mutex"
into thread.c.  This lets us make make the global lock and
post_acquire_global_lock static.
2012-08-18 19:59:47 -06:00
Tom Tromey
f52cfea0dc write docstrings for the thread functions 2012-08-17 07:51:19 -06:00
Tom Tromey
abb9e9d865 declare unbind_for_thread_switch and rebind_for_thread_switch in lisp.h 2012-08-17 07:16:16 -06:00
Tom Tromey
6c0d5ae507 process changes
This changes wait_reading_process_output to handle threads better.  It
introduces a wrapper for select that releases the global lock, and it
ensures that only a single thread can select a given file descriptor
at a time.

This also adds the thread-locking feature to processes.  By default a
process can only have its output accepted by the thread that created
it.  This can be changed using set-process-thread.  (If the thread
exits, the process is again available for waiting by any thread.)

Note that thread-signal will not currently interrupt a thread blocked
on select.  I'll fix this later.
2012-08-15 13:19:24 -06:00
Tom Tromey
dbb33d4e99 This adds thread-blocker, a function to examine what a thread is
blocked on.  I thought this would be another nice debugging addition.
2012-08-15 13:16:33 -06:00
Tom Tromey
8d3566c6a0 This adds names to mutexes. This seemed like a nice debugging
extension.
2012-08-15 13:14:14 -06:00
Tom Tromey
51100bb8d3 This supplies the mutex implementation for Emacs Lisp.
A lisp mutex is implemented using a condition variable, so that we can
interrupt a mutex-lock operation by calling thread-signal on the
blocking thread.  I did things this way because pthread_mutex_lock
can't readily be interrupted.
2012-08-15 13:11:22 -06:00
Tom Tromey
1dcacbc647 This adds most of the thread features visible to emacs lisp.
I roughly followed the Bordeaux threads API:

http://trac.common-lisp.net/bordeaux-threads/wiki/ApiDocumentation

... but not identically.  In particular I chose not to implement
interrupt-thread or destroy-thread, but instead a thread-signalling
approach.

I'm still undecided about *default-special-bindings* (which I did not
implement).  I think it would be more emacs-like to capture the let
bindings at make-thread time, but IIRC Stefan didn't like this idea
the first time around.

There are one or two semantics issues pointed out in the patch where I
could use some advice.
2012-08-15 13:09:32 -06:00
Tom Tromey
60a9d2a772 This turns thread_state into a pseudovector and updates various bits
of Emacs to cope.
2012-08-15 13:07:04 -06:00
Tom Tromey
e160922c66 This introduces some new functions to handle the specpdl. The basic
idea is that when a thread loses the interpreter lock, it will unbind
the bindings it has put in place.  Then when a thread acquires the
lock, it will restore its bindings.

This code reuses an existing empty slot in struct specbinding to store
the current value when the thread is "swapped out".

This approach performs worse than my previously planned approach.
However, it was one I could implement with minimal time and
brainpower.  I hope that perhaps someone else could improve the code
once it is in.
2012-08-15 13:04:34 -06:00
Tom Tromey
14b3dc5e4f This introduces the low-level system threading support. It also adds
the global lock.  The low-level support is a bit over-eager, in that
even at the end of the present series, it will not all be used.  I
think thiat is ok since I plan to use it all eventually -- in
particular for the emacs lisp mutex implementation.

I've only implemented the pthreads-based version.  I think it should
be relatively clear how to port this to other systems, though.

I'd also like to do a "no threads" port that will turn most things
into no-ops, and have thread-creation fail.  I was thinking perhaps
I'd make a future (provide 'threads) conditional on threads actually
working.

One other minor enhancement available here is to make it possible to
set the name of the new thread at the OS layer.  That way gdb, e.g.,
could display thread names.
2012-08-15 13:03:17 -06:00
Tom Tromey
2d525b793f This parameterizes the GC a bit to make it thread-ready.
The basic idea is that whenever a thread "exits lisp" -- that is,
releases the global lock in favor of another thread -- it must save
its stack boundaries in the thread object.  This way the boundaries
are always available for marking.  This is the purpose of
flush_stack_call_func.

I haven't tested this under all the possible GC configurations.
There is a new FIXME in a spot that i didn't convert.

Arguably all_threads should go in the previous patch.
2012-08-15 13:01:36 -06:00
Tom Tromey
68b3248243 This introduces a thread-state object and moves various C globals
there.  It also introduces #defines for these globals to avoid a
monster patch.

The #defines mean that this patch also has to rename a few fields
whose names clash with the defines.

There is currently just a single "thread"; so this patch does not
impact Emacs behavior in any significant way.
2012-08-15 12:56:38 -06:00