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 #include #include #include #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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!