#include #include #include #include #include #include #include struct sched_param blank; void go_idle() { int result = sched_setscheduler(0, SCHED_IDLE, &blank); if (result != 0) printf("Failed to set idle priority.\n"); } void busyloop() { volatile int n, t; volatile int x = 1; for (t = 0; t < 4; t++) for (n = 0; n < 0x70000000; n++) x *= n; exit(0); } pid_t spawn() { pid_t pid = fork(); if (pid == 0) busyloop(); return pid; } int main(int argc, char *argv[]) { pid_t pid1, pid2; go_idle(); pid1 = spawn(); pid2 = spawn(); int status; waitpid(pid1, &status, 0); waitpid(pid2, &status, 0); return 0; }