Skip to main content

Module cpu

Module cpu 

Source
Expand description

CPU time spent by a process and everything it spawned, read from /proc.

A test binary running one long test prints nothing until that test ends, so silence alone cannot tell a stuck run from a busy one. The hang the watchdog exists for sat idle on a socket; a run burning CPU is making progress.

Structsยง

Stat ๐Ÿ”’

Constantsยง

TICKS_PER_SECOND
/proc reports CPU time in USER_HZ ticks, fixed at 100 by the kernel ABI.

Functionsยง

group_members
Live members of the process group pgid, the leader included.
parse ๐Ÿ”’
A /proc/<pid>/stat line. The command name sits in parentheses and may itself hold spaces and parentheses, so fields are counted after the last ).
read_stats ๐Ÿ”’
tree_ticks
User plus system ticks of root and all its live descendants, each with the ticks of its reaped children rolled up, so a finished process does not make the total fall.