aboutsummaryrefslogtreecommitdiffstats
path: root/src/thread.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Update copyright year to 2017 in masterPaul Eggert2017-01-011-1/+1
| | | | | | Run admin/update-copyright in the master branch. This fixes files that were not already fixed in the emacs-25 branch before it was merged here.
* Rename primary_thread to main_threadPaul Eggert2016-12-301-1/+1
| | | | | | | | | | | | This avoids the confusion of using two different phrases "main thread" and "primary thread" internally to mean the same thing. See: http://lists.gnu.org/archive/html/emacs-devel/2016-12/msg01142.html * src/thread.c (main_thread): Rename from primary_thread, since the new name no longer clashes with main_thread_id and Emacs internals normally call this the "main thread". (init_main_thread): Rename from init_primary_thread. (main_thread_p): Rename from primary_thread_p. All uses changed.
* regex.h now includes sys/types.hPaul Eggert2016-12-251-1/+0
| | | | | | | * src/dired.c, src/emacs.c, src/search.c, src/syntax.c, src/thread.h: Do not include sys/types.h; no longer needed. * src/regex.h: Include <sys/types.h>, as that's what Gnulib and glibc regex.h does, and POSIX has blessed this since 2008.
* Reorder lisp.h to declare types before using themPaul Eggert2016-12-251-0/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | This puts basic functions for types to be after the corresponding type definitions. This is a more-common programming style in C, and will make it easier to port Emacs to gcc -fcheck-pointer-bounds, since the functions now have access to the corresponding types' sizes. This patch does not change the code; it just moves declarations and definitions and removes no-longer-needed forward declarations (Bug#25128). * src/buffer.c, src/data.c, src/image.c: Include process.h, for PROCESSP. * src/buffer.h (BUFFERP, CHECK_BUFFER, XBUFFER): * src/process.h (PROCESSP, CHECK_PROCESS, XPROCESS): * src/termhooks.h (TERMINALP, XTERMINAL): * src/window.h (WINDOWP, CHECK_WINDOW, XWINDOW): * src/thread.h (THREADP, CHECK_THREAD, XTHREAD, MUTEXP, CHECK_MUTEX) (XMUTEX, CONDVARP, CHECK_CONDVAR, XCONDVAR): Move here from lisp.h. * src/intervals.h: Include buffer.h, for BUFFERP. Include lisp.h, for Lisp_Object. * src/lisp.h: Reorder declarations and definitions as described above. Move thread includes to be later, so that they can use the reordered definitions. Move some symbols to other headers (noted elsewhere). Remove forward decls that are no longer needed. * src/thread.h: Include systhread.h here, not in lisp.h, since lisp.h itself does not need systhread.h.
* Remove interpreter’s byte stackPaul Eggert2016-12-231-9/+1
| | | | | | | | | | | | | | | | | | | | | This improves performance overall on my benchmark on x86-64, since the interpreted program-counter resides in a machine register rather than in RAM. * etc/DEBUG, src/.gdbinit: Remove xbytecode GDB command, as there is no longer a byte stack to decode. * src/bytecode.c (struct byte_stack, byte_stack_list) (relocate_byte_stack): Remove. All uses removed. (FETCH): Simplify now that pc is now local (typically, in a register) and no longer needs to be relocated. (CHECK_RANGE): Remove. All uses now done inline, in a different way. (BYTE_CODE_QUIT): Remove; now done by op_relative_branch. (exec_byte_code): Allocate a copy of the function’s bytecode, so that there is no problem if GC moves it. * src/lisp.h (struct handler): Remove byte_stack member. All uses removed. * src/thread.c (unmark_threads): Remove. All uses removed. * src/thread.h (struct thread_state): Remove m_byte_stack_list member. All uses removed. m_stack_bottom is now the first non-Lisp field.
* ; Spelling fixesPaul Eggert2016-12-221-2/+2
|
* Fix last change with thread marking under GC_CHECK_MARKED_OBJECTSEli Zaretskii2016-12-221-0/+1
| | | | | | | * src/thread.c (primary_thread_p): New function. * src/alloc.c (mark_object): Use 'primary_thread_p' to bypass tests meant for thread objects allocated dynamically. * src/thread.h (primary_thread_p): Add prototype.
* Fix crashes upon C-g on Posix TTY framesEli Zaretskii2016-12-191-0/+8
| | | | | | | | | | | | | | | | | | * src/thread.h (struct thread_state): New member not_holding_lock. (maybe_reacquire_global_lock): Add prototype. * src/thread.c: Include syssignal.h. (maybe_reacquire_global_lock): New function. (really_call_select): Set the not_holding_lock member of the thread state before releasing the lock, and rest it after re-acquiring the lock when the select function returns. Block SIGINT while doing this to make sure we are not interrupted on TTY frames. * src/sysdep.c (block_interrupt_signal, restore_signal_mask): New functions. * src/syssignal.h (block_interrupt_signal, restore_signal_mask): Add prototypes. * src/keyboard.c (read_char) [THREADS_ENABLED]: Call maybe_reacquire_global_lock. (Bug#25178)
* Fix commentsEli Zaretskii2016-12-171-2/+2
| | | | | | * src/thread.h (struct thread_state): Fix comments. * src/process.c (wait_reading_process_output): Fix a typo in commentary.
* Undo part of last changeEli Zaretskii2016-12-111-5/+0
| | | | | | | * src/thread.h: * src/keyboard.c: * src/keyboard.h: Undo part of last change: input_available_clear_time is again a global variable.
* Avoid aborts when a thread signals an errorEli Zaretskii2016-12-111-0/+9
| | | | | | | | | | | | * src/thread.h (struct thread_state): Add members m_waiting_for_input and m_input_available_clear_time. (waiting_for_input, input_available_clear_time): New macros. * src/keyboard.c (waiting_for_input, input_available_clear_time): Remove; they are now macros that reference the current thread. (Bug#25171) * src/w32select.c: Don't include keyboard.h. * test/src/thread-tests.el (thread-errors): New test.
* ; Fix copyright years in new filesGlenn Morris2016-12-101-1/+1
|
* Fix compilation warnings due to prototype of thread_selectEli Zaretskii2016-12-091-1/+1
| | | | | | | | * src/thread.h <int select_func>: Make the 5th and 6th arguments be 'const'. * src/process.c [WINDOWSNT]: * src/w32proc.c: Make the 5th and 6th argument to sys_select be 'const'.
* Fix compilation on Debian GNU/LinuxEli Zaretskii2016-12-091-0/+1
| | | | | * src/thread.h: Include sys/types.h, for ssize_t that regex.h uses. Reported by Robert Marshall <robert.marshall@codethink.co.uk>.
* Fix compilation problems.Eli Zaretskii2016-12-051-12/+0
|
* Merge branch 'concurrency'Eli Zaretskii2016-12-041-1/+5
| | | | | | | | | | | | | | Conflicts (resolved): configure.ac src/Makefile.in src/alloc.c src/bytecode.c src/emacs.c src/eval.c src/lisp.h src/process.c src/regex.c src/regex.h
* Fix the MS-Windows buildEli Zaretskii2015-11-021-0/+4
| | | | | | | | | | | | | | | | | * src/thread.h [WINDOWSNT]: Include sys/socket.h. * src/sysselect.h: Don't define fd_set and FD_* macros for MS-Windows here. * src/w32.h: Define them here. * src/process.h (sys_select): Declare prototype. * src/sysdep.c: * src/process.c: * src/filelock.c: * src/emacs.c: * src/callproc.c: Move inclusion of sys/select.h after lisp.h. * nt/inc/socket.h: Include w32.h instead of sysselect.h
* merge from trunkKen Raeburn2015-11-011-14/+8
|
* make thread_check_current_buffer return boolTom Tromey2013-08-271-1/+1
|
* fix whitespace_regexp warningTom Tromey2013-08-261-1/+3
|
* merge from trunkTom Tromey2013-07-061-2/+2
| | | | | | this merges frmo trunk and fixes various build issues. this needed a few ugly tweaks. this hangs in "make check" now
* remove unused field from struct thread_stateTom Tromey2013-07-031-6/+0
|
* merge from trunk; clean up some issuesTom Tromey2013-06-031-3/+0
|
* don't let kill-buffer kill a buffer if it is current in any threadTom Tromey2013-03-181-0/+2
|
* merge from trunkTom Tromey2013-03-171-2/+2
|
* condition variablesTom Tromey2012-08-191-0/+16
| | | | | This implements condition variables for elisp. This needs more tests.
* comment fixesTom Tromey2012-08-181-1/+7
|
* refactor systhread.hTom Tromey2012-08-181-3/+13
| | | | | | 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.
* process changesTom Tromey2012-08-151-0/+22
| | | | | | | | | | | | | | | 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.
* This adds thread-blocker, a function to examine what a thread isTom Tromey2012-08-151-0/+4
| | | | blocked on. I thought this would be another nice debugging addition.
* This adds names to mutexes. This seemed like a nice debuggingTom Tromey2012-08-151-1/+8
| | | | extension.
* This supplies the mutex implementation for Emacs Lisp.Tom Tromey2012-08-151-0/+3
| | | | | | | 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.
* This adds most of the thread features visible to emacs lisp.Tom Tromey2012-08-151-0/+25
| | | | | | | | | | | | | | | | | | 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.
* This turns thread_state into a pseudovector and updates various bitsTom Tromey2012-08-151-0/+3
| | | | of Emacs to cope.
* This introduces some new functions to handle the specpdl. The basicTom Tromey2012-08-151-0/+6
| | | | | | | | | | | | | | 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.
* This introduces the low-level system threading support. It also addsTom Tromey2012-08-151-0/+4
| | | | | | | | | | | | | | | | | | | 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.
* This parameterizes the GC a bit to make it thread-ready.Tom Tromey2012-08-151-0/+5
| | | | | | | | | | | | | 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.
* This introduces a thread-state object and moves various C globalsTom Tromey2012-08-151-0/+140
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.