Question: Using gettimeofday(), determine how long it takes to start a new process with fork(). Insure that you make at least one thousand measurements before declaring
Using gettimeofday(), determine how long it takes to start a new process with fork(). Insure that you make at least one thousand measurements before declaring the required time.
I have this so far but I am not sure if I am doing it right. Please correct mine or write one by yourself.
#include
int main() { struct timeval start, end; for(int i=0;i<1000;i++) // loop will run n times (n=1000) { gettimeofday(&start,0); fork(); gettimeofday(&end,0); printf("time: %lu ",end.tv_usec - start.tv_usec); } return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
