next hack: timeouttop

i had a ‘future work’ item in my last post. i couldn’t resist doing it so now it’s done.

timeouttop is a program that when coupled with the kernel patch from my last entry will show a top-like display of which processes are being most frequently woken by timeouts.

notes: it works by keeping track of the state of the counters from up to 60 seconds ago and comparing it with the current state. if a process isn’t in both of the lists then it is not shown. this means that if a new process (just started) wasn’t running 60 seconds ago then it won’t show in the list until it has run for the full 60. this could be considered a bug.

the progrram also assumes a terminal width of 80 and a length of however long it needs to show all of the processes with non-zero timeouts in the sample period. the terminal is assumed to support vt100-like codes for clearing the screen.

good enough for now :)