public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "adhemerval.zanella at linaro dot org" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug libc/30558] SIGEV_THREAD is badly implemented Date: Thu, 15 Jun 2023 21:04:20 +0000 [thread overview] Message-ID: <bug-30558-131-sRbT1HT9M2@http.sourceware.org/bugzilla/> (raw) In-Reply-To: <bug-30558-131@http.sourceware.org/bugzilla/> https://sourceware.org/bugzilla/show_bug.cgi?id=30558 Adhemerval Zanella <adhemerval.zanella at linaro dot org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |adhemerval.zanella at linaro dot o | |rg --- Comment #1 from Adhemerval Zanella <adhemerval.zanella at linaro dot org> --- FreeBSD also implements SIGEV_THREAD in the same ways as glibc: with a detached helper thread that spawns thread when kernel signal when thee time has expired (check https://github.com/freebsd/freebsd-src/blob/main/lib/librt/sigev_thread.c). You can check with FreeBSD own tools: -- $ cat <<EOF >>timer.c #include <time.h> #include <signal.h> #include <unistd.h> static void handler(union sigval sv) { } int main(void) { timer_t timerid; timer_create (CLOCK_REALTIME, &(struct sigevent) { .sigev_notify = SIGEV_THREAD, .sigev_notify_function = handler, }, &timerid); timer_settime (timerid, 0, &(struct itimerspec) { { 0, 150000000 }, { 0, 300000000 } }, NULL); sleep (1); timer_delete(timerid); return 0; } EOF $ cc -Wall timer.c -o timer -lrt -lpthread $ truss ./sigevthread 2>&1 | grep 'thread' rtprio_thread(RTP_LOOKUP,100647,0x7fffffffda38) = 0 (0x0) <new thread 101341> <new thread 101342> <new thread 101343> <thread 101343 exited> <new thread 101344> <thread 101344 exited> <new thread 101345> <thread 101345 exited> <new thread 101346> <thread 101346 exited> <new thread 101347> <thread 101347 exited> <new thread 101348> <thread 101348 exited> <thread 101342 exited> <thread 101341 exited> -- One possibility is to remove the background thread, create the thread prior to timer_create, and move the sigwaitinfo loop logic to the thread itself. It would require changing how timer_delete works, it needs now to signal the thread instead to issue the syscall itself. Btw this is how musl has implemented it. I am not sure which is the best option, but it might worth experimenting to remove the helper thread. It would allow removing the __timer_active_sigev_thread list and simplify the code, but I am not sure about the performance implications. -- You are receiving this mail because: You are on the CC list for the bug.
next prev parent reply other threads:[~2023-06-15 21:04 UTC|newest] Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-06-15 19:36 [Bug libc/30558] New: " stsp at users dot sourceforge.net 2023-06-15 21:04 ` adhemerval.zanella at linaro dot org [this message] 2023-06-16 2:23 ` [Bug libc/30558] " stsp at users dot sourceforge.net 2023-06-16 6:44 ` stsp at users dot sourceforge.net 2023-06-16 7:29 ` stsp at users dot sourceforge.net 2023-06-16 7:51 ` stsp at users dot sourceforge.net 2023-06-16 11:44 ` stsp at users dot sourceforge.net 2023-06-19 17:41 ` adhemerval.zanella at linaro dot org 2023-06-19 18:54 ` stsp at users dot sourceforge.net 2023-06-19 19:33 ` adhemerval.zanella at linaro dot org 2023-06-19 19:48 ` stsp at users dot sourceforge.net 2023-06-19 20:14 ` adhemerval.zanella at linaro dot org 2023-06-19 20:26 ` stsp at users dot sourceforge.net 2023-06-19 21:15 ` adhemerval.zanella at linaro dot org 2023-06-19 21:21 ` adhemerval.zanella at linaro dot org 2023-06-19 21:58 ` stsp at users dot sourceforge.net 2023-06-19 22:51 ` adhemerval.zanella at linaro dot org 2023-06-20 4:14 ` stsp at users dot sourceforge.net 2023-06-20 12:21 ` adhemerval.zanella at linaro dot org 2023-06-20 12:49 ` stsp at users dot sourceforge.net 2023-06-20 13:01 ` adhemerval.zanella at linaro dot org 2023-06-20 13:13 ` stsp at users dot sourceforge.net 2023-06-21 3:19 ` stsp at users dot sourceforge.net 2023-06-21 14:32 ` adhemerval.zanella at linaro dot org 2023-06-21 14:41 ` stsp at users dot sourceforge.net 2023-06-21 14:43 ` adhemerval.zanella at linaro dot org 2023-06-21 14:52 ` stsp at users dot sourceforge.net 2023-06-21 15:07 ` adhemerval.zanella at linaro dot org 2023-06-22 2:57 ` bugdal at aerifal dot cx 2023-06-22 5:23 ` stsp at users dot sourceforge.net 2023-06-23 18:34 ` adhemerval.zanella at linaro dot org 2023-06-24 17:03 ` crrodriguez at opensuse dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-30558-131-sRbT1HT9M2@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).