Syncing processes

Syncing Processes – When running two or more processes, synchronization is important. Two versions of synchronization is available here.
 /* proc_syncV1 */  
 // header files  
 #include<unistd.h>  
 #include<stdio.h>  
 //main func  
 int main(int argc, char *argv[])  
 {  
      int i=0, pid,cpid,dip;  
      printf("ready to fork\n");  
      pid=fork()  
      if(pid==0)  
      {  
           printf("1st child process id is %d\n",getpid());  
               printf("first child terminating from memory\n");  
      }  
      else  
      {  
           dip=fork();  
           if(dip==0)  
           {  
                printf("2nd child process id is %d\n",getpid());  
                printf("seoncd child is terminating from memory\n");  
           }  
           else  
           {  
                cpid=wait(0);  
                printf("child with pid %d died\n",cpid);  
                cpid=wait(0);  
                printf("child wiht pid %d fied\n",cpid);  
                printf("i am parent %d \n",getpid());  
           }  
      }  
 }  

Comments

Popular posts from this blog

Generating 16k ROM using Xilinx IP COREGEN and simulating it in modelsim

Setting up atalanta ATPG to work on Linux

Sparse matrix - 3 tuple representation