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) { 
    string filepath = kProcDirectory + "/" + std::to_string(pid) + kStatFilename;
    std::ifstream file = GetStream(filepath);
    long process_jiffies;
    string line;
    std::getline(file, line);
    std::istringstream buf(line);
    std::istream_iterator<string> beg(buf), end;
    std::vector<string> values(beg, end);
    process_jiffies = stol(values[13]) + stol(values[14]) + stol(values[15]) 
                        + stol(values[16]);
    file.close();
    return process_jiffies;
}
long LinuxParser :: ActiveJiffies ( int pid ) { string filepath = kProcDirectory + " " + std :: to_string ( pid ) + kStatFilename ; std :: ifstream file = GetStream ( filepath ) ; long process_jiffies ; string line ; std :: getline ( file , line ) ; std :: istringstream buf ( line ) ; std :: istream_iterator < string > beg ( buf ) , end ; std :: vector < string > values ( beg , end ) ; process_jiffies = stol ( values [ 13 ] ) + stol ( values [ 14 ] ) + stol ( values [ 15 ] ) + stol ( values [ 16 ] ) ; file . close ( ) ; return process_jiffies ; }
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