View previous topic :: View next topic |
Author |
Message |
silvered n00b
Joined: 05 Aug 2012 Posts: 11
|
Posted: Tue Aug 07, 2012 11:12 pm Post subject: dudar del fork |
|
|
al momento de correr me sale que el fork no esta referenciado
alguien lo puede correguir???
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <time.h>
#define N 10000
int process( int n )
{ pid_t pid;
pid = fork();
printf("%d.-proceso %d (hijo) <- %d (padre) \n", n, pid, getpid());
if (pid==0) printf("[%d, proceso hijo, %d]", n, pid);
if (pid!=-1)printf(" [%d, proceso padre %d] \n", n, getpid() );
if (n<N)
{
return process( n+1 );
}
else {
return N;
}
}
int main( void )
{ time_t ti, tf;
int Dt;
time(&ti);
process(1);
time(&tf);
Dt= difftime(tf,ti);
printf("Tiempo %0.2f\n",(float)Dt );
printf("Finalizado!!!\n");
return 0;
} |
|
Back to top |
|
|
edgar_uriel84 Guru
Joined: 21 Dec 2008 Posts: 485 Location: Tultitlan, México
|
Posted: Wed Aug 08, 2012 4:21 am Post subject: |
|
|
Si comentas que debe hacer el programa es posible que consigas ayuda. _________________ Algún día habrá una persona mejor que yo, pero esa persona no eres tú ni ese momento es ahora. |
|
Back to top |
|
|
afb n00b
Joined: 13 Oct 2007 Posts: 66
|
Posted: Wed Aug 08, 2012 10:21 pm Post subject: |
|
|
He ejecutado tu programa y funciona sin problemas.
Saludos |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|