COHERENT manpages
This page displays the COHERENT manpage for idle [Device that returns system's idle time].
List of available manpages
Index
idle -- Device Device that returns system's idle time /dev/idle /dev/idle is the device from which you can read the system's idle time. It has major device 0, the same as /dev/null and /dev/cmos; and has minor number 11. This non-portable device node is used exclusively for tracking system load. Its driver recognizes the system calls open(), ioctl(), and close(), but not read() or write(). The only available ioctl() for /dev/idle writes a pair of longs to an address that you supply. The long at the lower address contains the number of system idle clock ticks (or, more precisely, the number of ticks at the end of which the system was idle) that have occurred since system startup. The long at the higher address contains the total number of clock ticks that have occurred since system startup. To estimate system load during a specific interval of time, perform the ioctl() for /dev/idle at the start and end of an interval. Example The following program prints system load over a five-second interval. To see a nonzero load percentage, run it concurrently with a CPU-intensive process. #include <sys/null.h> main() { long x[2]; /* tick values at start of interval */ long y[2]; /* tick values at end of interval */ long delta_idle, delta_lbolt; int fd; /* We need to open a device before we can ioctl it. */ fd = open("/dev/idle", 0); /* Get tick values at start of interval. */ ioctl(fd, NLIDLE, x); /* Sleep during the interval. */ sleep(5); /* Get tick values at end of interval. */ ioctl(fd, NLIDLE, y); /* Compute number of system idle ticks during the interval. */ delta_idle = y[0] - x[0]; /* Compute total number of clock ticks during the interval. */ delta_lbolt = y[1] - x[1]; /* System is loaded when it isn't idle, so system load factor * is 100% minus the percentage of system idle time. */ printf("system load = %ld%%\n", 100L - (100L * delta_idle)/delta_lbolt); close(fd); } See Also device drivers, ioctl(), null