Linux Thread programming Basics - COFPROG

Linux Thread programming Basics

Write a c program, create a global variable and try to increment its value for child & parent

#include<stdio.h>
#include<unistd.h>
 

 int i; 

int main() 
{  
  int ret; 
  printf("global variable before fork:%d \n",i);
  ret = fork(); 
   
 if(ret0) 
   { i++; 
     printf("Parent Process! and incremented global variable:%d \n",i); 
   } 

 return 0; 
}

Previous
Next Post »

BOOK OF THE DAY