I ran a C program with an infinite while loop in a terminal and observed one of the CPU cores shot to 100% usage. When I turn it into a background process using Ctrl+z, the CPU usage suddenly dipped to < 10%. Using htop
, I found that the process was using 0% of the CPU. What has happened to the process?
The program
int main()
{
int i;
while( 1 )
{ }
return 0;
}
Since there is no I/O involved in the program, I made small changes to the program to see if the I/O wait increased the usage, but got the same results (0% usage).
int main()
{
int i;
while( i+1 ) // wait to retrieve i
{
i = 1;
}
return 0;
}
What has happened to the process ? Is it running?