aboutsummaryrefslogtreecommitdiffstats
path: root/src/systhread.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Add thread-naming support for OpenBSDTimo Myyrä2020-06-281-0/+8
| | | | | | | | | OpenBSD has pthread_set_name_np; FreeBSD appears to have both this call and pthread_setname_np (the latter call is used in preference). * configure.ac: Detect pthread_set_name_np. * sys/systhread.c: Include <pthread_np.h> and call pthread_set_name_np if available.
* Cater for 3-argument version of pthread_setname_npRobert Pluim2020-02-031-3/+5
| | | | | | | | | | Fixes Bug#39363. * configure.ac: Add check for 3-argument version of pthread_setname_np. * src/systhread.c (sys_thread_set_name) [HAVE_PTHREAD_SETNAME_NP_3ARG]: Call pthread_setname_np with 3 arguments.
* Fix another compilation problem in a build without threadsEli Zaretskii2020-01-081-0/+4
| | | | | * src/systhread.c (sys_thread_set_name) [!THREADS_ENABLED]: Add a trivial implementation.
* Fix build without threadsEli Zaretskii2020-01-081-2/+1
| | | | | | * src/systhread.c (sys_thread_create) [!THREADS_ENABLED]: Update the function's signature to match prototype. Reported by Glenn Morris <rgm@gnu.org>. (Bug#38632)
* Fix BSD and macOS builds w.r.t. pthread_setname_np (bug#38632)Mattias Engdegård2020-01-071-28/+30
| | | | | | | | | | | | | | | pthread_setname_np takes only a single argument on BSD and macOS, and affects the current thread only. * configure.ac: Add check for single-argument pthread_setname_np * src/systhread.c (sys_thread_set_name): New (w32 and pthread versions). (sys_thread_create): Remove name argument and name-setting. (w32_beginthread_wrapper): Remove name-setting. * src/systhread.h (sys_thread_create, sys_thread_set_name): Update prototypes. * src/thread.c (run_thread): Call sys_thread_set_name. (Fmake_thread): Adapt call to sys_thread_create. * src/thread.h (struct thread_state): Adjust comment.
* Use pthread_setname_np to set thread nameRobert Pluim2020-01-061-6/+11
| | | | | | | | | | | | * configure.ac: Remove check for sys/prctl.h and prctl, check for pthread_setname_np instead. * systhread.c: Remove sys/prctl.h include. (sys_thread_create) [HAVE_PTHREAD_SETNAME_NP]: Use pthread_setname_np to set the name of the newly created thread (Bug#38632). * thread.c (Fmake_thread): Use ENCODE_SYSTEM instead of ENCODE_UTF_8 on the thread name.
* Update copyright year to 2020Paul Eggert2020-01-011-1/+1
| | | | Run "TZ=UTC0 admin/update-copyright $(git ls-files)".
* Support setting OS names of threads on MS-WindowsEli Zaretskii2019-12-201-1/+69
| | | | | | | | | | | | | | | | | | | * src/w32fns.c (setup_w32_kbdhook): Don't initialize is_debugger_present here... (globals_of_w32fns): ...initialize it here. Also initialize the new global variable set_thread_description. * src/systhread.c: [WINDOWSNT] Include mbctype.h (w32_set_thread_name): New function. (MS_VC_EXCEPTION): New macro. (THREADNAME_INFO, IsDebuggerPresent_Proc) (SetThreadDescription_Proc): New typedefs. (w32_beginthread_wrapper): Call w32_set_thread_name to set the name of the new thread. * src/thread.h (struct thread_state): New member thread_name. * src/thread.c (Fmake_thread): Set the thread_name field of the new thread object. (run_thread): Free the thread_name member after the thread exits.
* Merge from origin/emacs-26Paul Eggert2018-12-311-1/+1
|\ | | | | | | | | | | 2fcf2df Fix copyright years by hand 26bed8b Update copyright year to 2019 2814292 Fix value of default frame height. (Bug#33921)
| * Update copyright year to 2019Paul Eggert2019-01-011-1/+1
| | | | | | | | Run 'TZ=UTC0 admin/update-copyright $(git ls-files)'.
| * Require a larger stack size for threads on macOS (bug#30364)Paul Eggert2018-02-281-0/+9
| | | | | | | | | | | | | | * src/systhread.c (sys_thread_create) [THREADS_ENABLED && HAVE_PTHREAD && DARWIN_OS]: Require at least 8MB stack size for x64 and 4MB for x86 on macOS. Do not merge to master.
* | Make error checking for thread functions stricter.Philipp Stephani2018-06-091-18/+60
| | | | | | | | | | | | | | | | | | | | | | | | * src/systhread.c (sys_thread_create): Change return type to bool. Check for errors returned by pthread_attr_setstacksize and pthread_attr_destroy. (sys_mutex_init): Abort on errors. Enable mutex checks when checking is enabled. (sys_cond_init): Abort on errors. (sys_mutex_lock, sys_mutex_unlock, sys_cond_wait) (sys_cond_signal, sys_cond_broadcast, sys_cond_destroy): Check for errors in debug mode.
* | Require a larger stack size for threads (bug#30364)Aaron Jensen2018-02-271-0/+7
| | | | | | | | | | * src/systhread.c (sys_thread_create) [THREADS_ENABLED && HAVE_PTHREAD]: Require at least 8MB stack size for x64 and 4MB for x86.
* | Fix module support if threads are disabled (Bug#30106)Philipp Stephani2018-01-181-0/+18
|/ | | | | | * src/systhread.c (sys_thread_equal): New function. * src/thread.c (in_current_thread): Move from emacs-module.c; use sys_thread_equal.
* Update copyright year to 2018Paul Eggert2018-01-011-1/+1
| | | | Run admin/update-copyright.
* Make sure thread stack is properly aligned on MS-WindowsEli Zaretskii2017-10-141-3/+4
| | | | | | | * src/systhread.c: Include w32term.h instead of windows.h. (w32_beginthread_wrapper): Add ALIGN_STACK attribute, to ensure the thread's stack is correctly aligned. * src/w32term.h (ALIGN_STACK): Update commentary.
* Prefer HTTPS to FTP and HTTP in documentationPaul Eggert2017-09-131-1/+1
| | | | | | | | | | | | | Most of this change is to boilerplate commentary such as license URLs. This change was prompted by ftp://ftp.gnu.org's going-away party, planned for November. Change these FTP URLs to https://ftp.gnu.org instead. Make similar changes for URLs to other organizations moving away from FTP. Also, change HTTP to HTTPS for URLs to gnu.org and fsf.org when this works, as this will further help defend against man-in-the-middle attacks (for this part I omitted the MS-DOS and MS-Windows sources and the test tarballs to keep the workload down). HTTPS is not fully working to lists.gnu.org so I left those URLs alone for now.
* Fix threads on NS (bug#25265)Alan Third2017-07-011-0/+11
| | | | | | | | | | | | | src/nsterm.h (ns_select): Compiler doesn't like sigmask being const. (ns_run_loop_break) [HAVE_PTHREAD]: New function. src/nsterm.m (ns_select): Call thread_select from within ns_select. (ns_run_loop_break) [HAVE_PTHREAD]: New function. (ns_send_appdefined): Don't wait for main thread when sending app defined event. src/process.c (wait_reading_process_output): Call thread_select from within ns_select. src/systhread.c (sys_cond_broadcast) [HAVE_NS]: Break ns_select out of its event loop using ns_run_loop_break.
* Remove a few unused C functionsPaul Eggert2017-02-261-40/+0
| | | | | | | | | * src/eval.c (let_shadows_global_binding_p): * src/print.c (write_string): * src/systhread.c (sys_mutex_destroy, sys_thread_equal): Remove. * src/print.c (write_string): Rename from write_string_1. All uses changed.
* 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.
* ; Spelling fixesPaul Eggert2016-12-221-1/+1
|
* ; Fix copyright years in new filesGlenn Morris2016-12-101-1/+1
|
* ; * src/systhread.c [WINDOWSNT]: Fix typos in comments.old-branches/concurrencyEli Zaretskii2015-11-031-5/+5
|
* Improve MS-Windows implementation of threads.Eli Zaretskii2013-08-311-9/+73
| | | | | | | | | | | | | | | | | | src/systhread.c (sys_cond_init): Set the 'initialized' member to true only if initialization is successful. Initialize wait_count and wait_count_lock. (sys_cond_wait, sys_cond_signal, sys_cond_broadcast): If 'initialized' is false, do nothing. (sys_cond_wait): Fix the implementation to avoid the "missed wakeup" bug: count the waiting threads, and reset the broadcast event once the last thread was released. (sys_cond_signal, sys_cond_broadcast): Use SetEvent instead of PulseEvent. Don't signal the event if no threads are waiting. (sys_cond_destroy): Only close non-NULL handles. (sys_thread_create): Return zero if unsuccessful, 1 if successful. src/systhread.h (w32thread_cond_t): New member 'initialized'. Rename waiters_count and waiters_count_lock to wait_count and wait_count_lock, respectively.
* Enable thread support in the MS-Windows build.Eli Zaretskii2013-08-301-0/+149
| | | | | | | | | | | | | src/systhread.h (w32thread_critsect, w32thread_cond_t, sys_mutex_t) (sys_cond_t, sys_thread_t) [WINDOWSNT]: New data types. src/systhread.c (sys_mutex_init, sys_mutex_lock, sys_mutex_unlock) (sys_mutex_destroy, sys_cond_init, sys_cond_wait) (sys_cond_signal, sys_cond_broadcast, sys_cond_destroy) (sys_thread_self, sys_thread_equal, w32_beginthread_wrapper) (sys_thread_create, sys_thread_yield) [WINDOWSNT]: New functions. configure.ac (THREADS_ENABLED): Enable threads for MinGW, even if pthreads is not available.
* implement --enable-threads and a thread-less modeTom Tromey2013-08-261-2/+75
|
* pass the thread name to the OS if possibleTom Tromey2012-08-201-3/+13
| | | | use prctl to pass the thread name to the OS, if possible
* refactor systhread.hTom Tromey2012-08-181-61/+0
| | | | | | 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.
* This adds most of the thread features visible to emacs lisp.Tom Tromey2012-08-151-11/+4
| | | | | | | | | | | | | | | | | | 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 introduces the low-level system threading support. It also addsTom Tromey2012-08-151-0/+189
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.