![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| 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-10-2008 12:22 AM |
| display in a child process a command called in the parent one | remid1985 | High Level Programming | 7 | 01-19-2007 06:40 PM |
| Parent/Child Processes | yoi2hot4ya | Shell Programming and Scripting | 2 | 05-31-2006 02:27 PM |
| Parent/Child Scripting logic Question | jigarlakhani | Shell Programming and Scripting | 3 | 12-01-2005 12:35 AM |
| Implementing 2 pipes between a parent and child process | bwgoudey | High Level Programming | 2 | 09-25-2005 12:14 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | 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");
}
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|