The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 4 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Design, write, and test a program which estimates the time required to fork a process. Â This should be the minimum time to return from the fork function in both the parent and child processes as tested by repeated forking child processes from a single parent process. This is the program I get so far right now, the question ask estimates the time, so can any one help to edit the code, and make it how to estimates the time to the fork process, and let the min time to return from the fork function. Thank you!
Â
#include <unistd.h>#include <sys/types.h>#include <errno.h>#include <stdio.h>#include <sys/wait.h>#include <stdlib.h>int global_variable;int main(){pid_t childprocess_pid;int status;int local_variable = 0;childprocess_pid = fork();if (childprocess_pid >= 0){if (childprocess_pid == 0){printf("\nChild!\n");local_variable++;global_variable++;printf("child PID = %d, parentpid = %d\n", getpid(), getppid());printf("\n Local_Variable ofchild is = %d, Global_Variable of child is = %d\n", local_variable,global_variable);}else{printf("\nParent!\n");printf("parent PID = %d, childpid = %d\n", getpid(), childprocess_pid);wait(&status);printf("\n Local_Variable ofparent is = %d, Global_Variable of parent is = %d\n", local_variable,global_variable);