Conversation
The watchdog woke every 10 msec, and on every pass asked for each watch whether a debugger is attached, which on Linux opens and reads /proc/self/status. With the pcap interface's state machines running, that was about 100 opens and reads of that file a second, and as many wakeups, to enforce timeouts of 500 msec and more. Check the watches every 100 msec, look for a debugger at most once a second, and wait on a condition variable so that shutting down doesn't have to wait out the interval. The terminate flag is now only read and written under the lock. Without DEBUG or COMPILE_AVDECC_ASSERT defined, a missed watch doesn't assert and is only reported to observers, so with none registered there is nothing to check: the thread then waits until an observer registers or the watchdog terminates. registerObserver wakes the thread without taking the lock, so that an observer can still register from within a notification, and the idle thread looks again every 10 seconds in case it missed that wakeup. Once an observer is registered, checking resumes, debugger check included, so a process stopped in a debugger still doesn't read as a deadlock. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012i5Dd3gCyYqp4X7vxhSmxh
lhoward
force-pushed
the
lhoward/watchdog-polling
branch
from
September 14, 2026 20:46
0aea502 to
cafe6a4
Compare
This was referenced Sep 14, 2026
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



The watchdog thread woke every 10 msec, and on every pass called
utils::isDebuggerPresent()for every registered watch, which on Linux opens and reads/proc/self/status. With a pcap protocol interface and its state machines running, that was about 100 reads of that file a second, and as many wakeups, to enforce timeouts of 500 msec or more._shouldTerminateis only read and written under the lock.DEBUGnorCOMPILE_AVDECC_ASSERTis defined, a missed watch is only reported to observers, so with none registered the thread doesn't check at all. It waits until an observer registers or the watchdog is destroyed.registerObserverwakes it without taking the lock, so that an observer can still register from within a notification, and the idle thread looks again every 10 seconds in case it missed that wakeup. With an observer registered, checking resumes, debugger check included.checkWatchesandcheckWatchto reduce the nesting of the thread's loop, and the destructor usesstd::scoped_lock.On an embedded Linux (aarch64) device, in a release build, the watchdog thread went from about 90 context switches a second, and 100 reads of
/proc/self/status, to fewer than 0.2 switches and no reads.This overlaps #203 in
src/watchDog.cppandCHANGELOG-avdecc.md, so whichever is merged second needs a small rebase.Testing: builds on
dev, and together with the thread name and state machine changes in #203 and #205, the unit tests give the same results asdevwithout them: 289 of 292 pass.INTEGRATION_EndStation.DestroyWhileMessageInflight_pcapandINTEGRATION_ProtocolInterfacePCap_F.VuDelegatefail either way, as they need pcap access to a real interface.🤖 Generated with Claude Code
https://claude.ai/code/session_012i5Dd3gCyYqp4X7vxhSmxh