README.md 1.48 KB

PILOOP

Linux/Unix command to calculate pi in a forever loop, thereby maxing out the CPU cores of the machine. You need to specify the number of concurrent threads, and optionally the priority of the process by specifying a nice value to add.

Syntax

piloop <n> <p>

Where
<n> The number of concurrent threads to run
<p> The priority of the process (added to the default nice value of 0)

On most systems root privileges are needed to change the process nice value.

Set number of threads to the same number as logical cpus in order to load all cpus on the machine.

Set the nice value to 20 to run the process with the lowest possible priority. This will effectly replace the idle process on the machine. If the number of threads is set to the number of logical cpus, the server will always use all cpus 100% but still perform as normal (since all other processes have higher priority). If this is run on a virtual machine, the hypervisor will think the server always needs all available cpu resources given to the machine, minimizing the risk of letting the hypervisor think that cpu resources can be shared.

Compile

Using GCC and pthreads:

gcc -pthread piloop.c -o piloop

Binary in Repository

The pre-compiled piloop file in the repository is compiled for

piloop: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, 
interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, 
BuildID[sha1]=5312cb7d4bc2fab8851badf5ef36ddd91ce2136a, not stripped