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) { 
  vector<string> data;
  string line, value;
  long utime, stime, cutime, cstime, total_time;
  std::ifstream stream(kProcDirectory + std::to_string(pid) + kStatFilename); 
  if (stream.is_open()) { 
    std::getline(stream, line); 
    std::istringstream linestream(line); 
    while (linestream >> value) { 
			data.push_back(value); 
        }
    }
  utime = std::stol(data[13]);
  stime = std::stol(data[14]);
  cutime = std::stol(data[15]);
  cstime = std::stol(data[16]);
  total_time = (utime + stime + cutime + cstime); 
  return total_time;
}
long LinuxParser :: ActiveJiffies ( int pid ) { vector < string > data ; string line , value ; long utime , stime , cutime , cstime , total_time ; std :: ifstream stream ( kProcDirectory + std :: to_string ( pid ) + kStatFilename ) ; if ( stream . is_open ( ) ) { std :: getline ( stream , line ) ; std :: istringstream linestream ( line ) ; while ( linestream >> value ) { data . push_back ( value ) ; } } utime = std :: stol ( data [ 13 ] ) ; stime = std :: stol ( data [ 14 ] ) ; cutime = std :: stol ( data [ 15 ] ) ; cstime = std :: stol ( data [ 16 ] ) ; total_time = ( utime + stime + cutime + cstime ) ; return total_time ; }
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
//Create a steam for reading Process data //Open file //Read line //convert line to line stream //read word by word in the line till finished //Add each word to vector to use later to access each data seperatly  //in CLK ticks