pid_t eat_cpu(int (test_function)(void))
{ union pipe read_pipe, write_pipe; int rc;
pid_t pid;
FAIL_IF(bind_to_cpu(BIND_CPU_ANY) < 0);
if (pipe(read_pipe.fds) == -1) return -1;
if (pipe(write_pipe.fds) == -1) return -1;
pid = fork(); if (pid == 0) exit(eat_cpu_child(write_pipe, read_pipe));
if (sync_with_child(read_pipe, write_pipe)) {
rc = -1; goto out;
}
printf("main test running as pid %d\n", getpid());
rc = test_function();
out:
kill(pid, SIGKILL);
return rc;
}
struct addr_range libc, vdso;
int parse_proc_maps(void)
{ unsignedlong start, end; char execute, name[128];
FILE *f; int rc;
f = fopen("/proc/self/maps", "r"); if (!f) {
perror("fopen"); return -1;
}
do { /* This skips line with no executable which is what we want */
rc = fscanf(f, "%lx-%lx %*c%*c%c%*c %*x %*d:%*d %*d %127s\n",
&start, &end, &execute, name); if (rc <= 0) break;
if (execute != 'x') continue;
if (strstr(name, "libc")) {
libc.first = start;
libc.last = end - 1;
} elseif (strstr(name, "[vdso]")) {
vdso.first = start;
vdso.last = end - 1;
}
} while(1);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.