1. 14 Jul, 2017 1 commit
    • Paul Eggert's avatar
      Improve stack-overflow heuristic on GNU/Linux · 9dee1c88
      Paul Eggert authored
      Problem reported by Steve Kemp (Bug#27585).
      * src/eval.c (near_C_stack_top): Remove.  All uses replaced
      by current_thread->stack_top.
      (record_in_backtrace): Set current_thread->stack_top.
      This is for when the Lisp interpreter calls itself.
      * src/lread.c (read1): Set current_thread->stack_top.
      This is for recursive s-expression reads.
      * src/print.c (print_object): Set current_thread->stack_top.
      This is for recursive s-expression printing.
      * src/thread.c (mark_one_thread): Get stack top first.
      * src/thread.h (struct thread_state.stack_top): Now void *, not char *.
      9dee1c88
  2. 02 May, 2017 1 commit
  3. 18 Jan, 2017 2 commits
    • Eli Zaretskii's avatar
      Fix a bug with signaling a thread that waits for condvar · 5fefaaa8
      Eli Zaretskii authored
      * src/thread.c (lisp_mutex_lock_for_thread): New function,
      with all the guts of lisp_mutex_lock.
      (lisp_mutex_lock): Call lisp_mutex_lock_for_thread.
      (condition_wait_callback): Don't call post_acquire_global_lock
      before locking the mutex, as that could cause a signaled thread to
      exit prematurely, because the condvar's mutex is recorded to be
      not owned by any thread, and with-mutex wants to unlock it as part
      of unwinding the stack in response to the signal.
      5fefaaa8
    • Eli Zaretskii's avatar
      Rudimentary error handling for non-main threads · 57153260
      Eli Zaretskii authored
      * src/thread.c (last_thread_error): New static variable.
      (syms_of_threads): Staticpro it.
      (record_thread_error, Fthread_last_error): New functions.
      (syms_of_threads): Defsubr Fthread_last_error.
      
      * doc/lispref/threads.texi (Basic Thread Functions): Document
      thread-last-error.
      
      * test/src/thread-tests.el (thread-errors, thread-signal-early)
      (threads-condvar-wait): Test the values returned by
      thread-last-error.
      57153260
  4. 13 Jan, 2017 1 commit
    • Eli Zaretskii's avatar
      Fix a bug in waiting for condition variable · 03e4ab0d
      Eli Zaretskii authored
      * src/thread.c (lisp_mutex_lock, lisp_mutex_unlock)
      (lisp_mutex_unlock_for_wait, condition_wait_callback)
      (condition_notify_callback): Improve commentary.
      (condition_wait_callback): Call post_acquire_global_lock before
      attempting to lock the mutex, to make sure the lock's owner is
      recorded correctly.
      
      * test/src/thread-tests.el (threads-condvar-wait): New test.
      03e4ab0d
  5. 01 Jan, 2017 1 commit
  6. 30 Dec, 2016 1 commit
    • Paul Eggert's avatar
      Rename primary_thread to main_thread · 108ef803
      Paul Eggert authored
      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.
      108ef803
  7. 24 Dec, 2016 2 commits
    • Paul Eggert's avatar
      Remove interpreter’s byte stack · a815e5f1
      Paul Eggert authored
      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.
      a815e5f1
    • Paul Eggert's avatar
      Use max_align_t instead of void * · e2767bd0
      Paul Eggert authored
      * src/thread.c (run_thread): Don’t assume void * is aligned enough.
      e2767bd0
  8. 23 Dec, 2016 1 commit
  9. 22 Dec, 2016 2 commits
  10. 19 Dec, 2016 1 commit
    • Eli Zaretskii's avatar
      Fix crashes upon C-g on Posix TTY frames · fe3188b1
      Eli Zaretskii authored
      * 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)
      fe3188b1
  11. 12 Dec, 2016 2 commits
    • Eli Zaretskii's avatar
      Avoid crashing if a new thread is signaled right away · 825f4dd4
      Eli Zaretskii authored
      * src/thread.c (post_acquire_global_lock): Don't raise the pending
      signal if the thread's handlers were not yet set up, as that will
      cause Emacs to exit with a fatal error.  This can happen if a
      thread is signaled as soon as make-thread returns, before the new
      thread had an opportunity to acquire the global lock, set up the
      handlers, and call the thread function.
      
      * test/src/thread-tests.el (thread-signal-early): New test.
      825f4dd4
    • Eli Zaretskii's avatar
      Fix point motion in cloned buffers · a416e1d6
      Eli Zaretskii authored
      * src/thread.c (post_acquire_global_lock): Call
      set_buffer_internal_2 instead of tricking set_buffer_internal_1
      into resetting the current buffer even if it didn't change.  This
      avoids bug#25165, caused by failing to record the modified values
      of point and mark, because current_buffer was set to NULL.  Also,
      don't bother re-setting the buffer if there was no thread switch,
      as that just wastes cycles.
      * src/buffer.c (set_buffer_internal_2): New function, with most of
      the body of set_buffer_internal_1, but without the test for B
      being identical to the current buffer.
      (set_buffer_internal_1): Call set_buffer_internal_2 if B is not
      identical to the current buffer.
      * src/buffer.h (set_buffer_internal_2): Add prototype.
      
      * test/src/thread-tests.el (thread-sticky-point): New test.
      a416e1d6
  12. 10 Dec, 2016 4 commits
  13. 08 Dec, 2016 1 commit
  14. 05 Dec, 2016 1 commit
  15. 18 Oct, 2013 1 commit
  16. 01 Sep, 2013 1 commit
    • Eli Zaretskii's avatar
      Fix crashes when unbind_for_thread_switch signals an error. · bed10876
      Eli Zaretskii authored
       src/eval.c (unbind_for_thread_switch): Accept a 'struct
       thread_state *' argument and use specpdl_ptr and specpdl of that
       thread.  Fixes crashes if find_symbol_value signals an error.
       src/thread.c (post_acquire_global_lock): Update current_thread
       before calling unbind_for_thread_switch.  Pass the previous thread
       to unbind_for_thread_switch.
      bed10876
  17. 27 Aug, 2013 2 commits
  18. 26 Aug, 2013 2 commits
  19. 11 Jul, 2013 1 commit
  20. 07 Jul, 2013 1 commit
  21. 06 Jul, 2013 1 commit
  22. 05 Jul, 2013 1 commit
  23. 04 Jul, 2013 1 commit
    • Tom Tromey's avatar
      unlink thread later · 2efa60a3
      Tom Tromey authored
      unlink thread from global list later
      also remove some unnecessary destruction code
      2efa60a3
  24. 03 Jul, 2013 2 commits
  25. 06 Jun, 2013 1 commit
    • Tom Tromey's avatar
      fix a few latent issues in the thread patch · 313dfb62
      Tom Tromey authored
      * we called unbind_for_thread_switch unconditionally, but this
        is wrong if the previous thread exited
      * likewise, exiting a thread should clear current_thread
      * redundant assignment in run_thread
      * clean up init_threads - no need to re-init the primary thread
      
      This patch still sometimes causes weird hangs in "make check".
      However, I think that is a kernel bug, since Emacs enters the zombie
      state but its parent process hangs in wait.  This shouldn't happen.
      313dfb62
  26. 18 Mar, 2013 1 commit
  27. 27 Aug, 2012 1 commit
  28. 20 Aug, 2012 1 commit
  29. 19 Aug, 2012 2 commits