Expand description
Whether a thread of this process is at work, and the clock that says when it has been quiet for a window.
What:
Whether one thread of this process is at work, judged with the signs the push meter reads for a child process, and the
clock that says when the thread has shown none of them for a window.
Why:
The Markdown linter runs on a thread of this process and the gateway call of the standards review blocks one, so neither
has a child process whose tree push_progress.rs could sample. Linux keeps the same counters for each thread under
/proc/self/task/<tid>/: the bytes it read and wrote (io), and its processor ticks and state (stat). The thread being
judged is never the thread that reads these files, so the reading does not count as the thread’s work.
Where /proc/self/task/<tid>/io or stat cannot be read nothing is measured and the thread is never judged quiet.
In TS you’d write (pseudocode):
const clock = new ThreadClock(tid, windowMs); while (!done) { if (clock.quiet()) abandon(); await sleep(SAMPLE_MS); }Structs§
- Thread
Clock - What:
The clock of one thread: it looks at the thread’s signs at the sampling interval and says when none has shown for a window.
Why:
The waiting thread asks every few milliseconds; the counters are read only every
SAMPLE_INTERVAL, as for a child process. - Thread
Signs - What:
What one thread had done when it was last looked at, and the look that says whether it did more since.
Why:
Bytes and ticks only grow, so a change since the last look is a sign of work; a thread in a state able to run or waiting
for the disk is at work now. The connected sockets of the process count too, when asked: an HTTP client moves its bytes
with
sendandrecv, which the thread’srcharandwchardo not see.
Functions§
- current_
thread_ id - What:
The kernel’s number for the calling thread, which names its files under
/proc/self/task/. Why:stddoes not expose it; the system call takes no arguments and cannot fail. - measured_
quiet - What:
Run
jobon this thread while another thread measures how quiet this thread gets, and keep the longest gap in the ledger. Why: A call that ends itself (the gateway call ends on its transport’s own idle timeouts) still needs its quiet gap recorded. Nothing here ends the job.