public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug librt/28799] New: [Feature request] Enhanced timer_create()/timer_delete(), for MS Windows parity
@ 2022-01-20 15:32 ulatekh at yahoo dot com
  2022-01-20 16:51 ` [Bug librt/28799] " fweimer at redhat dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: ulatekh at yahoo dot com @ 2022-01-20 15:32 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28799

            Bug ID: 28799
           Summary: [Feature request] Enhanced
                    timer_create()/timer_delete(), for MS Windows parity
           Product: glibc
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: librt
          Assignee: unassigned at sourceware dot org
          Reporter: ulatekh at yahoo dot com
  Target Milestone: ---

I’m in the middle of porting a very large legacy code base from MS Windows to
Linux.
One outpoint I've run into is in timer_delete(); there's no way to determine
when no more callbacks are forthcoming.
This makes it impossible to clean up safely after deleting a timer, especially
if the value passed in struct sigevent's sigev_value.sival_ptr is dynamically
allocated, e.g. a C++ object.
The MS Windows API call DeleteTimerQueueTimer(), and even the ancient
timeSetEvent(), allow for notification that there will be no forthcoming timer
callbacks.
It pains me to see Linux not having an answer to anything MS Windows can do,
and the fix is easy (though it'll require an updated API, like
timer_create2()/timer_delete2() or something, if one chooses to follow ffmpeg's
convention when APIs are updated.)

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug librt/28799] [Feature request] Enhanced timer_create()/timer_delete(), for MS Windows parity
  2022-01-20 15:32 [Bug librt/28799] New: [Feature request] Enhanced timer_create()/timer_delete(), for MS Windows parity ulatekh at yahoo dot com
@ 2022-01-20 16:51 ` fweimer at redhat dot com
  2022-01-21  8:37 ` fweimer at redhat dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: fweimer at redhat dot com @ 2022-01-20 16:51 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28799

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fweimer at redhat dot com

--- Comment #1 from Florian Weimer <fweimer at redhat dot com> ---
I think it's already possible to disarm the timer using timer_settime (with a
zero time argument) before calling timer_delete. This ensures that no further
callbacks are forthcoming after timer_settime has returned.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug librt/28799] [Feature request] Enhanced timer_create()/timer_delete(), for MS Windows parity
  2022-01-20 15:32 [Bug librt/28799] New: [Feature request] Enhanced timer_create()/timer_delete(), for MS Windows parity ulatekh at yahoo dot com
  2022-01-20 16:51 ` [Bug librt/28799] " fweimer at redhat dot com
@ 2022-01-21  8:37 ` fweimer at redhat dot com
  2022-01-21 17:14 ` ulatekh at yahoo dot com
  2022-03-01 13:16 ` fweimer at redhat dot com
  3 siblings, 0 replies; 5+ messages in thread
From: fweimer at redhat dot com @ 2022-01-21  8:37 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28799

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-01-21
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |WAITING

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug librt/28799] [Feature request] Enhanced timer_create()/timer_delete(), for MS Windows parity
  2022-01-20 15:32 [Bug librt/28799] New: [Feature request] Enhanced timer_create()/timer_delete(), for MS Windows parity ulatekh at yahoo dot com
  2022-01-20 16:51 ` [Bug librt/28799] " fweimer at redhat dot com
  2022-01-21  8:37 ` fweimer at redhat dot com
@ 2022-01-21 17:14 ` ulatekh at yahoo dot com
  2022-03-01 13:16 ` fweimer at redhat dot com
  3 siblings, 0 replies; 5+ messages in thread
From: ulatekh at yahoo dot com @ 2022-01-21 17:14 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28799

--- Comment #2 from Steven Boswell II <ulatekh at yahoo dot com> ---
Although my limited testing shows that, indeed, this allows the timer to get
shut down cleanly, it reveals another problem.

Apparently, in the Linux implementation, a new thread is created (and quickly
destroyed) for every invocation of a callback-based timer, accompanied by a
flood of "New Thread" and "Thread exited" messages in my gdb window. (The timer
in question is invoked 40 times per second.)

My reading of glibc's sysdeps/unix/sysv/linux/timer_routines.c concurs;
timer_helper_thread() repeatedly invokes pthread_create() on
timer_sigev_thread(), which runs the timer callback once and then exits.

So thanks for your help, but I'm just going to go back to my hand-rolled
thread-based timer implementation, which creates a thread per timer, not a
thread per timer-invocation.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug librt/28799] [Feature request] Enhanced timer_create()/timer_delete(), for MS Windows parity
  2022-01-20 15:32 [Bug librt/28799] New: [Feature request] Enhanced timer_create()/timer_delete(), for MS Windows parity ulatekh at yahoo dot com
                   ` (2 preceding siblings ...)
  2022-01-21 17:14 ` ulatekh at yahoo dot com
@ 2022-03-01 13:16 ` fweimer at redhat dot com
  3 siblings, 0 replies; 5+ messages in thread
From: fweimer at redhat dot com @ 2022-03-01 13:16 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28799

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |WORKSFORME
             Status|WAITING                     |RESOLVED

--- Comment #3 from Florian Weimer <fweimer at redhat dot com> ---
(In reply to Steven Boswell II from comment #2)
> Although my limited testing shows that, indeed, this allows the timer to get
> shut down cleanly, it reveals another problem.
> 
> Apparently, in the Linux implementation, a new thread is created (and
> quickly destroyed) for every invocation of a callback-based timer,
> accompanied by a flood of "New Thread" and "Thread exited" messages in my
> gdb window. (The timer in question is invoked 40 times per second.)

Thanks for the feedback. I think this is the expected behavior. It's obviously
not great for high-frequency timers, but it's the simplest way to avoid
unexpected blocking of unrelated timer events.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-03-01 13:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-20 15:32 [Bug librt/28799] New: [Feature request] Enhanced timer_create()/timer_delete(), for MS Windows parity ulatekh at yahoo dot com
2022-01-20 16:51 ` [Bug librt/28799] " fweimer at redhat dot com
2022-01-21  8:37 ` fweimer at redhat dot com
2022-01-21 17:14 ` ulatekh at yahoo dot com
2022-03-01 13:16 ` fweimer at redhat dot com

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).