summaryrefslogtreecommitdiff
path: root/erts/lib_src/pthread
Commit message (Collapse)AuthorAgeFilesLines
* Update copyright yearErlang/OTP2023-04-111-1/+1
|
* Avoid truncating thread names for better runtime observabilitylexprfuncall2023-04-061-16/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Erlang runtime gives many of its threads descriptive names. When those threads are part of a logical group, a unique ID is added to the name for disambiguation. After construction, many thread names in Erlang have a string length greater than 16 characters. To fit within operating system limits, Erlang then truncates them from right to left. To minimize confusion after truncation, the unique ID is always placed at the left of a thread name so its information is not likely to be lost. The convention used by Erlang presents challenges to the use of thread names as keys when reporting on thread activity at the operating system level. The more common convention, used by other runtimes, is to have the description followed by a unique ID. When followed, sorting threads by name places like workers next to each other and the unique ID can be dropped to create a grouping key. Placing the unique ID first, as Erlang does, means that a different strategy needs to be used for sorting the threads of an Erlang process. Furthermore, the truncation necessitates a complicated strategy for analyzing the description to identify a possible common substring to be used as a grouping key. This change switches the Erlang runtime to use the more common convention in order to make reporting on the thread usage in an Erlang process easier for tooling. To do so, it shortens the content of the initial printf(3) format strings to ensure their output is always 16 or fewer characters so the name is never truncated. It also moves the unique ID in the format string to the right of the description, so the names of worker threads appear next to each other after sorting alphabetically from left to right. To prevent the accidental creation of long thread names in the future, the silent truncation has been eliminated from the lowest-layer of thread functionality. It now returns an EINVAL when given a long name which will be caught when the runtime is started. This would break the NIF and driver libraries so the silent truncation has moved up to a higher layer in order to preserve compatibility. New unit tests have been added to test setting and getting thread names.
* Update copyright yearRickard Green2021-12-161-1/+1
|
* Merge branch 'maint'Rickard Green2021-12-131-1/+1
|\ | | | | | | | | * maint: Update copyright year
| * Update copyright yearRickard Green2021-12-131-1/+1
| |
* | Fix typos in erts/lib_srcKian-Meng, Ang2021-11-171-2/+2
| |
* | Merge branch 'maint'Rickard Green2021-11-111-2/+24
|\ \ | |/ | | | | | | * maint: Limit timeout value in calls to select()
| * Merge branch 'rickard/select-timeout-fix/GH-5339/OTP-17735' into maintRickard Green2021-11-111-2/+24
| |\ | | | | | | | | | | | | * rickard/select-timeout-fix/GH-5339/OTP-17735: Limit timeout value in calls to select()
| | * Limit timeout value in calls to select()Rickard Green2021-11-031-2/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We previously did not limit the timeout value when calling select() which could cause select() to fail when passed a huge timeout value causing a runtime system crash. We currently only use select() on Darwin which accepts a timeout value of up to 100 million seconds. However, according to posix, select() implementations are only required to provide 31 days as max timeout value. We therefore limit the timeout value to 31 days.
* | | Adapt configure scripts to autoconf 2.71 (step 1)Rickard Green2021-06-141-8/+2
|/ / | | | | | | Replace obsolete macros and fix warnings
* | Merge branch 'rickard/tse/OTP-16766/ERL-1304' into maintRickard Green2020-07-202-4/+29
|\ \ | | | | | | | | | | | | * rickard/tse/OTP-16766/ERL-1304: Fix multiple usage of same thread specific event at the same time
| * | Fix multiple usage of same thread specific event at the same timeRickard Green2020-07-162-4/+29
| | |
* | | Use destination buffer size for snprintf()Rickard Green2020-06-081-2/+12
| | |
* | | thread name setting on Haiku w/ 32 char namesCalvin Buckley2020-06-081-1/+17
| |/ |/| | | | | | | | | This uses a non-pthread API. Also double hard-coded assumptions; on vanilla 16-char pthread systems, the set thread name function will truncate for us.
* | Update copyright yearRickard Green2020-03-131-1/+1
| |
* | erts: Do not use named no_cpuid label in asmMatwey V. Kornilov2019-07-271-2/+2
|/ | | | | | | | | | Ask compiler to generate unique label name. Using named label has implications on optimizer, that may lead to the compilation errors as the following: pthread/ethread.c: Assembler messages: pthread/ethread.c:213: Error: symbol `no_cpuid' is already defined pthread/ethread.c:213: Error: symbol `no_cpuid' is already defined pthread/ethread.c:213: Error: symbol `no_cpuid' is already defined
* Update copyright yearRaimo Niskanen2017-05-041-1/+1
|
* Stack guard for PCRERickard Green2017-04-071-7/+18
|
* Improve accuracy of timeouts using premature timeoutsRickard Green2016-06-221-18/+56
| | | | | | | Improve accuracy of timeouts using a premature timeout then return to sleep with a shorter timeout just before requested timeout. This approach is only used on certain platforms where we know it improves the accuracy of the timeouts, e.g. MacOS X.
* Merge branch 'henrik/update-copyrightyear'Henrik Nord2016-04-133-3/+3
|\ | | | | | | | | * henrik/update-copyrightyear: update copyright-year
| * update copyright-yearHenrik Nord2016-03-153-3/+3
| |
* | Fix premature timeouts for ethread events on LinuxRickard Green2016-03-161-3/+3
|/
* Fix ethread events with timeoutRickard Green2015-08-271-9/+88
| | | | | | | | | | | | Lots of pthread platforms unnecessarily falled back on the pipe/select solution. This since we tried to use the same monotonic clock source for pthread_cond_timedwait() as used by OS monotonic time. This has been fixed on most platforms by using another clock source. Darwin can however not use pthread_cond_timedwait() with monotonic clock source and has to use the pipe/select solution. On darwin we now use select with _DARWIN_UNLIMITED_SELECT in order to be able to handle a large amount of file descriptors.
* Change license text to APLv2Bruce Yinhe2015-06-183-27/+30
|
* Merge branch 'rickard/time_api/OTP-11997'Rickard Green2015-03-202-36/+491
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * rickard/time_api/OTP-11997: (22 commits) Update primary bootstrap inets: Suppress deprecated warning on erlang:now/0 inets: Cleanup of multiple copies of functions Add inets_lib with common functions used by multiple modules inets: Update comments Suppress deprecated warning on erlang:now/0 Use new time API and be back-compatible in inets Remove unused functions and removed redundant test asn1 test SUITE: Eliminate use of now/0 Disable deprecated warning on erlang:now/0 in diameter_lib Use new time API and be back-compatible in ssh Replace all calls to now/0 in CT with new time API functions test_server: Replace usage of erlang:now() with usage of new API Replace usage of erlang:now() with usage of new API Replace usage of erlang:now() with usage of new API Replace usage of erlang:now() with usage of new API Replace usage of erlang:now() with usage of new API otp_SUITE: Warn for calls to erlang:now/0 Replace usage of erlang:now() with usage of new API Multiple timer wheels Erlang based BIF timer implementation for scalability Implement ethread events with timeout ... Conflicts: bootstrap/bin/start.boot bootstrap/bin/start_clean.boot bootstrap/lib/compiler/ebin/beam_asm.beam bootstrap/lib/compiler/ebin/compile.beam bootstrap/lib/kernel/ebin/auth.beam bootstrap/lib/kernel/ebin/dist_util.beam bootstrap/lib/kernel/ebin/global.beam bootstrap/lib/kernel/ebin/hipe_unified_loader.beam bootstrap/lib/kernel/ebin/inet_db.beam bootstrap/lib/kernel/ebin/inet_dns.beam bootstrap/lib/kernel/ebin/inet_res.beam bootstrap/lib/kernel/ebin/os.beam bootstrap/lib/kernel/ebin/pg2.beam bootstrap/lib/stdlib/ebin/dets.beam bootstrap/lib/stdlib/ebin/dets_utils.beam bootstrap/lib/stdlib/ebin/erl_tar.beam bootstrap/lib/stdlib/ebin/escript.beam bootstrap/lib/stdlib/ebin/file_sorter.beam bootstrap/lib/stdlib/ebin/otp_internal.beam bootstrap/lib/stdlib/ebin/qlc.beam bootstrap/lib/stdlib/ebin/random.beam bootstrap/lib/stdlib/ebin/supervisor.beam bootstrap/lib/stdlib/ebin/timer.beam erts/aclocal.m4 erts/emulator/beam/bif.c erts/emulator/beam/erl_bif_info.c erts/emulator/beam/erl_db_hash.c erts/emulator/beam/erl_init.c erts/emulator/beam/erl_process.h erts/emulator/beam/erl_thr_progress.c erts/emulator/beam/utils.c erts/emulator/sys/unix/sys.c erts/preloaded/ebin/erlang.beam erts/preloaded/ebin/erts_internal.beam erts/preloaded/ebin/init.beam erts/preloaded/src/erts_internal.erl lib/common_test/test/ct_hooks_SUITE_data/cth/tests/empty_cth.erl lib/diameter/src/base/diameter_lib.erl lib/kernel/src/os.erl lib/ssh/test/ssh_basic_SUITE.erl system/doc/efficiency_guide/advanced.xml
| * Implement ethread events with timeoutRickard Green2015-03-202-36/+491
| |
* | erts: Introduce thread suspend functionsLukas Larsson2014-12-191-0/+11
| | | | | | | | | | | | | | These functions allow any thread to suspend any other thread immediately and then resume all threads. This is useful when doing a crash dump in order to get a more accurate picture of what state the system is in.
* | erts: Add support for thread namesLukas Larsson2014-12-191-0/+35
|/
* Raspberry PI / Android a minimal cross-compile configurationDmitry Kolesnikov2014-03-211-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Enable a cross compile Erlang/OTP platform to Android or Raspberry PI using Android NDK. Port emulator and core application to support target HW platform. Exclude any add-on services required for OTP platform deployment into target hardware due to device fragmentation and jail-break requirements. * fix erts/emulator/beam/sys.h Disable redefinition of __noreturn macro * port erts/emulator/sys/unix/erl_child_setup.c Use techniques proposed by https://code.google.com/p/erlang4android to access system properties * fix erts/emulator/sys/unix/erl_unix_sys_ddll.c The static linking of emulator cannot find dlerror(), dlopen() symbols * port erts/emulator/sys/unix/sys.c make path to shell configurable at build time * port erts/etc/common/Makefile.in disable librt for *-linux-androideabi * port erts/lib_src/pthread/ethread.c Use techniques proposed by https://code.google.com/p/erlang4android to disable emulator crash if kernel threads are on. Replace unreliable pthread_sigmask() by sigprocmask() * port lib/erl_interface/src/connect/ei_connect.c Disable call to undefined gethostid() * port lib/erl_interface/src/connect/ei_resolve.c Use gethostbyname_r() on Android platform
* ose,erts: Specify name for tsd keysLukas Larsson2014-02-241-1/+1
| | | | | This simplified debugging on OSE and also limits the number of ppdata keys that are created when beam is restarted.
* Fix lwsync instruction feature testRickard Green2011-12-271-15/+34
| | | | | | | A feature test for the lwsync instruction performed on PowerPC hardware at runtime system startup got into an eternal loop if the instruction was not supported. This bug was introduced in erts-5.9/OTP-R15B.
* Improve ethread atomicsRickard Green2011-06-142-1/+132
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The ethread atomics API now also provide double word size atomics. Double word size atomics are implemented using native atomic instructions on x86 (when the cmpxchg8b instruction is available) and on x86_64 (when the cmpxchg16b instruction is available). On other hardware where 32-bit atomics or word size atomics are available, an optimized fallback is used; otherwise, a spinlock, or a mutex based fallback is used. The ethread library now performs runtime tests for presence of hardware features, such as for example SSE2 instructions, instead of requiring this to be determined at compile time. There are now functions implementing each atomic operation with the following implied memory barrier semantics: none, read, write, acquire, release, and full. Some of the operation-barrier combinations aren't especially useful. But instead of filtering useful ones out, and potentially miss a useful one, we implement them all. A much smaller set of functionality for native atomics are required to be implemented than before. More or less only cmpxchg and a membar macro are required to be implemented for each atomic size. Other functions will automatically be constructed from these. It is, of course, often wise to implement more that this if possible from a performance perspective.
* Use 32-bit atomics for ethr_thr_createRickard Green2010-12-151-7/+7
|
* Use 32-bit atomics for eventsRickard Green2010-12-151-14/+16
|
* Remove unused ethread time functionalityRickard Green2010-12-141-26/+0
|
* Introduce ethr_sint_t and use it for atomicsRickard Green2010-12-112-6/+10
| | | | | | The atomic memory operations interface used the 'long' type and assumed that it was of the same size as 'void *'. This is true on most platforms, however, not on Windows 64.
* Rewrite ethread libraryRickard Green2010-08-102-0/+696
Large parts of the ethread library have been rewritten. The ethread library is an Erlang runtime system internal, portable thread library used by the runtime system itself. Most notable improvement is a reader optimized rwlock implementation which dramatically improve the performance of read-lock/read-unlock operations on multi processor systems by avoiding ping-ponging of the rwlock cache lines. The reader optimized rwlock implementation is used by miscellaneous rwlocks in the runtime system that are known to be read-locked frequently, and can be enabled on ETS tables by passing the `{read_concurrency, true}' option upon table creation. See the documentation of `ets:new/2' for more information. The ethread library can now also use the libatomic_ops library for atomic memory accesses. This makes it possible for the Erlang runtime system to utilize optimized atomic operations on more platforms than before. Use the `--with-libatomic_ops=PATH' configure command line argument when specifying where the libatomic_ops installation is located. The libatomic_ops library can be downloaded from: http://www.hpl.hp.com/research/linux/atomic_ops/ The changed API of the ethread library has also caused modifications in the Erlang runtime system. Preparations for the to come "delayed deallocation" feature has also been done since it depends on the ethread library. Note: When building for x86, the ethread library will now use instructions that first appeared on the pentium 4 processor. If you want the runtime system to be compatible with older processors (back to 486) you need to pass the `--enable-ethread-pre-pentium4-compatibility' configure command line argument when configuring the system.