Tuesday, 19 November 2013

FORK FAMILIARISATION

PROGRAM
     
#include<unistd .h=""> 
void main()
{
int pid;
pid= fork();
if(pid==0)
{
sleep(1);
printf(“ child 1 is running \n Child 1 ID : %d \t Parent ID : %d”, getpid(),getppid());
close(getpid());
}
else
{
pid= fork();
if(pid==0)
{
sleep(2);

printf(“ Child 2 is running \n Child 2 ID : %d \t Parent ID : %d”, getpid(),getppid());
close(getpid());
}

else
{
pid= fork();
if(pid==0)
{
sleep(3);
printf(“ Child 3 is running \n Child 3 ID : %d \t Parent ID : %d”, getpid(),getppid());
close(getpid());
}
else
{
sleep(3);
}
}
}

}
   

description and output will be published................

0 Comments:

Post a Comment

Facebook Twitter Delicious Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | coupon codes