Skip to content
The Signal Belfry

/static/campanario/en/sino/sigvtalrm/

Menu

SIG-018 · Clocks

SIGVTALRM

The alarm clock that only counts the time the process spent on the CPU.

SIGALRM's bookkeeping sibling: the virtual clock only ticks while the process runs in user mode. Waiting on I/O, sleeping, losing the CPU to someone else — none of it counts. It is working time, not wall time.

Old runtimes used this tick to slice time among green threads; today it is a museum piece with the occasional use: capping the CPU consumption of a stretch of code without depending on the clock of the world outside.

$ ./cruncher --limite-cpu 5s
Virtual timer expired
(five seconds of CPU, not of wall clock)
The clock that ignores the waiting.