For all the questions below, the term CPU utilization means the percent of time the CPU is busy, over a long period of time. For all the questions below, assume that we are only considering a single core CPU.
Consider the following program (read the comments to understand some details). What is the CPU utilization of the following program when it is run?
$\_\_\_\_$ Round up your answer to the closest integer in $[0,100]$. Assume that the function useCPU() uses the CPU for $100$ ms on the machine on which the program is executing.
#include<iostream>
#include<cstdlib>
#include<unistd.h>
#include<sys/time.h>
using namespace std;
void useCPU () {
int i;
double z;
for (i = 0; i < 1200000; i++)
z = (double) rand ()/ (double)rand();
}
int main () {
while (1) {
struct timeval start, end;
useCPU(); //uses CPU for 100 ms
usleep (400000); // sleeps for 400 ms (400000 microseconds)
}
}