diff options
author | Lukas Larsson <[email protected]> | 2014-12-19 10:53:27 +0100 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2014-12-19 10:53:27 +0100 |
commit | 3e3ef7b16fa03a7b9f4e5376387750a69957719f (patch) | |
tree | 40d74a3d6ccd8a4faa5c7194979584fa67517ea1 /erts/lib_src | |
parent | a4d72d2cae3a9bd3f0dccdb663f70d54a45fe10f (diff) | |
parent | bd4b900c09308a6c3ab41e3a2070cb90410ee01d (diff) | |
download | otp-3e3ef7b16fa03a7b9f4e5376387750a69957719f.tar.gz otp-3e3ef7b16fa03a7b9f4e5376387750a69957719f.tar.bz2 otp-3e3ef7b16fa03a7b9f4e5376387750a69957719f.zip |
Merge branch 'lukas/erts/crashdump_improvements/OTP-12377'
* lukas/erts/crashdump_improvements/OTP-12377:
erts: Make main thread safe from pipe closed event
erts: Improve crash dumps
erts: Rename sys_sigset to sys_signal
erts: Introduce thread suspend functions
erts: Remove usage of QUANTIFY signal
erts: Add support for thread names
ets: Increase data available in crash dumps and ets:info
erts: Start compilation of beam_emu earlier
Diffstat (limited to 'erts/lib_src')
-rw-r--r-- | erts/lib_src/pthread/ethread.c | 46 | ||||
-rw-r--r-- | erts/lib_src/win/ethread.c | 13 |
2 files changed, 59 insertions, 0 deletions
diff --git a/erts/lib_src/pthread/ethread.c b/erts/lib_src/pthread/ethread.c index 79784c5b84..7cf38580c5 100644 --- a/erts/lib_src/pthread/ethread.c +++ b/erts/lib_src/pthread/ethread.c @@ -42,6 +42,7 @@ #include <sys/types.h> #include <unistd.h> #include <signal.h> +#include <string.h> #include <limits.h> @@ -77,6 +78,8 @@ typedef struct { void *(*thr_func)(void *); void *arg; void *prep_func_res; + char *name; + char name_buff[16]; } ethr_thr_wrap_data__; static void *thr_wrapper(void *vtwd) @@ -98,6 +101,8 @@ static void *thr_wrapper(void *vtwd) tsep = twd->tse; /* We aren't allowed to follow twd after result has been set! */ + if (twd->name) + ethr_setname(twd->name); ethr_atomic32_set(&twd->result, result); @@ -315,6 +320,12 @@ ethr_thr_create(ethr_tid *tid, void * (*func)(void *), void *arg, twd.thr_func = func; twd.arg = arg; + if (opts && opts->name) { + snprintf(twd.name_buff, 16, "%s", opts->name); + twd.name = twd.name_buff; + } else + twd.name = NULL; + res = pthread_attr_init(&attr); if (res != 0) return res; @@ -445,6 +456,30 @@ ethr_self(void) } int +ethr_getname(ethr_tid tid, char *buf, size_t len) +{ +#if defined(ETHR_HAVE_PTHREAD_GETNAME_NP_3) + return pthread_getname_np((pthread_t) tid, buf, len); +#elif defined(ETHR_HAVE_PTHREAD_GETNAME_NP_2) + return pthread_getname_np((pthread_t) tid, buf); +#else + return ENOSYS; +#endif +} + +void +ethr_setname(char *name) +{ +#if defined(ETHR_HAVE_PTHREAD_SETNAME_NP_2) + pthread_setname_np(ethr_self(), name); +#elif defined(ETHR_HAVE_PTHREAD_SET_NAME_NP_2) + pthread_set_name_np(ethr_self(), name); +#elif defined(ETHR_HAVE_PTHREAD_SETNAME_NP_1) + pthread_setname_np(name); +#endif +} + +int ethr_equal_tids(ethr_tid tid1, ethr_tid tid2) { return pthread_equal((pthread_t) tid1, (pthread_t) tid2); @@ -565,6 +600,17 @@ int ethr_sigwait(const sigset_t *set, int *sig) return 0; } +int ethr_kill(const ethr_tid tid, const int sig) +{ +#if ETHR_XCHK + if (ethr_not_inited__) { + ETHR_ASSERT(0); + return EACCES; + } +#endif + return pthread_kill((const pthread_t)tid, sig); +} + #endif /* #if ETHR_HAVE_ETHR_SIG_FUNCS */ ETHR_IMPL_NORETURN__ diff --git a/erts/lib_src/win/ethread.c b/erts/lib_src/win/ethread.c index 14d0b6deff..fe5d4a327f 100644 --- a/erts/lib_src/win/ethread.c +++ b/erts/lib_src/win/ethread.c @@ -508,6 +508,19 @@ ethr_self(void) return *tid; } +/* getname and setname are not available on windows */ +int +ethr_getname(ethr_tid tid, char *buf, size_t len) +{ + return ENOSYS; +} + +void +ethr_setname(char *name) +{ + return; +} + int ethr_equal_tids(ethr_tid tid1, ethr_tid tid2) { |