You can renice a running process
to give it more or less priority (the so-called "nice value"). Note
that the UNIX priority scale is somewhat counter-intuitive: negative
values mean a process is favored over concurrent processes, i.e., it
has "more" priority.
You can thus try to "slow down" your process given its PID through:
# lower priority of a process
renice +1 "PID"
Every time you run this, the process "nice value" is raised by 1; you
can use integer values other than
+1 of course.
The command nice allows you to
start a process with a +10 nice value adjustment (change this with
-n). For example:
# start a CPU-intensive task with low priority
However, the "nice value" only affects how much the scheduler favors
running a particular process over others in the system: if your
computer is basically idling, raising the "nice value" of one single
process will not stop that process from taking 100% CPU. I quote
from the getpriority(2) manpage:
(Emphasis added by me.)
The degree to which their relative nice value affects the scheduling
of processes varies across Unix systems, and, on Linux, across
kernel versions. Starting with kernel 2.6.23, Linux adopted an
algorithm that causes relative differences in nice values to have a
much stronger effect. This causes very low nice values (+19) to
truly provide little CPU to a process whenever there is any other
_higher priority load on the system._
The reason for this resides in the way processes are run on a
UNIX-like kernel: every time the kernel decides to run a process, that
process has full control of a CPU core for a certain (fixed and short)
span of time. The "nice value" can influence how often the kernel
scheduler is willing to give a time slot to a process, but you cannot
change the fact that, once scheduled, a process runs undisturbed for a
fixed amount of time.
Therefore, short of slowing down your CPU there is no way to make a
process run slower if there are no other processes in the system that
can contend for CPU access.