我使用这个 c/c++ 代码来安排 2 个处理器并行运行 2 个不同的程序。请问如何确认 2 个处理器并行运行 2 个程序?
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <iostream>
#include <sched.h>
#include <stdio.h>
#include <cstdlib>
int main(int argc, char *argv[])
{
cpu_set_t mask;
CPU_ZERO(&mask);
int pid;
pid=fork();
if (pid == 0) { /* second child */
CPU_SET(0, &mask);
sched_setaffinity(0, sizeof(mask), &mask);
system("/home/ifeanyi/Process/PID/Debug/PID");
}
else if (pid > 0) { // Parent ends
CPU_SET(1, &mask);
sched_setaffinity(getpid(), sizeof(mask), &mask);
cout << getpid() << endl;
system("/home/ifeanyi/Process/checkpointing/Debug/checkpointing"); // Last leaf
}
cout << endl;
}