![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Can a child process return a specific value to a parent process ? | Ametis1970 | High Level Programming | 8 | 04-09-2008 08:22 PM |
| display in a child process a command called in the parent one | remid1985 | High Level Programming | 7 | 01-19-2007 02:40 PM |
| Parent/Child Processes | yoi2hot4ya | Shell Programming and Scripting | 2 | 05-31-2006 10:27 AM |
| Parent/Child Scripting logic Question | jigarlakhani | Shell Programming and Scripting | 3 | 11-30-2005 08:35 PM |
| Implementing 2 pipes between a parent and child process | bwgoudey | High Level Programming | 2 | 09-24-2005 08:14 PM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi everybody,
I'm trying to understand how a parent and child processes interact. This function( below) basically measures the fork time from the perspective of the parent only. what i would like to know is how to measure the time from the perspective of parent and child (ie: inserting the GETTIME(endt) inside the child). Any help would be appreciated. HTML Code:
void run_tests(int nt)
{
struct timeval begt;
struct timeval endt;
double secs;
int i;
pid_t pid;
int waitid;
int status;
double max_secs = 0.000000;
double min_secs = 0.000000;
double average = 0.000000;
double sum = 0.000000;
for(i=0; i<nt; i++)
{
GETTIME(begt); // gettimeofday()
if((pid = fork()) < 0)
{
perror("fork() failed!\n");
_exit(1);
}
if( pid == 0)
{
_exit(0);
}
waitid = wait(&status);
GETTIME(endt); // gettimeofday()
secs = TOTALSECS(begt,endt);
max_secs = max(secs,max_secs);
min_secs = min(secs,min_secs);
sum += secs;
printf("%2d: secs = %.6f\n", i,secs);
} /* end of FOR loop */
average = sum / (i + 1);
printf("min: %.6f\n", min_secs);
printf("max: %.6f\n", max_secs);
printf("sum: %.6f\n", sum);
printf("average: %.6f\n", average);
printf("waitid: %d \n", waitid);
printf(" \n");
}
|
|||
| Google UNIX.COM |
| Forum Sponsor | ||
|
|