Code/Loadbalancer_v2.c
int give_process_count()
{
  int count=0;                 //Keeps track of the number of running processes
  FILE *fp,*outputfile;
  char var[80];           
  //Executes the command and writes the contents into a file  "process_info.txt"                             
  fp = popen("ps -o pid,user,pcpu,psr axr", "r");     
  outputfile = fopen("process_info.txt", "w");
  while (fgets(var, sizeof(var), fp) != NULL) 
  {
        
    fprintf(outputfile,"%s",var);
    count++;
  }
  pclose(fp);                                         // Closes the pipe
  fclose(outputfile);
  return count;
}
/*
	Function Name : give_process_count()
	Purpose       : To find the number of currently running processes
	Input         : -
	Output        : number of currently running process
*/
Function Name : give_process_count()
Purpose       : To find the number of currently running processes
Input         :
Output        : number of currently running process
Function Name : give_process_count () Purpose : To find the number of currently running processes Input : Output : number of currently running process
int give_process_count()
{
  int count=0;                 
  FILE *fp,*outputfile;
  char var[80];           
  fp = popen("ps -o pid,user,pcpu,psr axr", "r");     
  outputfile = fopen("process_info.txt", "w");
  while (fgets(var, sizeof(var), fp) != NULL) 
  {
    fprintf(outputfile,"%s",var);
    count++;
  }
  pclose(fp);                                         
  fclose(outputfile);
  return count;
}
int give_process_count ( ) { int count = 0 ; FILE * fp , * outputfile ; char var [ 80 ] ; fp = popen ( " " , " " ) ; outputfile = fopen ( " " , " " ) ; while ( fgets ( var , sizeof ( var ) , fp ) != NULL ) { fprintf ( outputfile , " " , var ) ; count ++ ; } pclose ( fp ) ; fclose ( outputfile ) ; return count ; }
Function Name : give_process_count()
Purpose       : To find the number of currently running processes
Input         :
Output        : number of currently running process
Function Name : give_process_count () Purpose : To find the number of currently running processes Input : Output : number of currently running process
//Keeps track of the number of running processes //Executes the command and writes the contents into a file  "process_info.txt"                              // Closes the pipe