I am trying to take the affinity mask and make a comma separated string from it using CPU_ISSET(). Then, I need to add the string "taskset -c" in front of it and executable behind it in order to create a Linux command.
When I add the cpu numbers to the array and print it, the output is not correct.
I need the array to eventually output as a string in order to run the Linux command.
int main() {
cpu_set_t mask;
int temp[FILENAME_MAX]
for(int i = 0; i < CPU_SETSIZE; i++)
{
if(CPU_ISSET(i, &mask))
{
temp[i] = i;
}
}
for(int i: temp)
os << i;
string str(os.str());
cout << str;
return 0;
}
output is a ton of zeros and then random numbers.