src/linux_parser.cpp
// TODO: Read and return the number of active jiffies for a PID
// REMOVE: [[maybe_unused]] once you define the function
Read and return the number of active jiffies for a PID
REMOVE: [[maybe_unused]] once you define the function
Read and return the number of active jiffies for a PID REMOVE : [[ maybe_unused ]] once you define the function
long LinuxParser::ActiveJiffies(int pid) 
{
  std::string line,col;
  long utime,stime,cutime,cstime;
  std::string starttime;
  std::ifstream fileStream(kProcDirectory + to_string(pid) + kStatFilename);
  if(fileStream.is_open())
  {
    getline(fileStream,line);
    std::stringstream linestream(line);
    for(int i=0; i<13; i++)
    {
      linestream >> col;
    }
    linestream >> utime >> stime >> cutime >> cstime;
    return utime + stime + cutime + cstime;
  }
  return 0;
}
long LinuxParser :: ActiveJiffies ( int pid ) { std :: string line , col ; long utime , stime , cutime , cstime ; std :: string starttime ; std :: ifstream fileStream ( kProcDirectory + to_string ( pid ) + kStatFilename ) ; if ( fileStream . is_open ( ) ) { getline ( fileStream , line ) ; std :: stringstream linestream ( line ) ; for ( int i = 0 ; i < 13 ; i ++ ) { linestream >> col ; } linestream >> utime >> stime >> cutime >> cstime ; return utime + stime + cutime + cstime ; } return 0 ; }
TODO: Read and return the number of active jiffies for a PID
REMOVE: [[maybe_unused]] once you define the function
TODO : Read and return the number of active jiffies for a PID REMOVE : [[ maybe_unused ]] once you define the function