This small program is for CPU scheduler testing. Note that the first number (the count) is of little use but I print it out still so the compiler won't do anything to the counting.
Compile with gcc -O2 -Wall -o use-cpu use-cpu.c
. This is supposed to run only on Linux systems, and you can use taskset
to pin it on specific CPU cores.
For related documentations, you can read manpages sched(7)
and cgroups(7)
.