#include <sys/types.h>What would be an eventual problem if you were to execute this program on your computer? Explain.
#include <unistd.h>
int main() {
for ( ; ; ) {
if (! fork()) { exit(0); }
sleep(1);
}
}
Exercise #2 (10 pts):
Consider this program. Assume that the PID
of the main process is 33. Each call to fork() in the code is commented
to state the PID of the newly created process.
a) For each running process at the time "one" is being printed out on the screen, other than process 33, give its PID, it's PPID, and the PIDs of its children, if any.
b) For each running process at the time "two" is being printed out on the screen, give its PID, it's PPID, and the PIDs of its children, if any.
For both questions assume that all system calls are successful (for brevity, the program does not check error codes.)
Exercise #3 (5 pts):
Consider this (incomplete) program.
Based on what we've said in the course, can you think of a reason
why this code may be very inefficient? Can you suggest a solution to
make it better? This solution would be in the OS, i.e.,
the implementation of the fork system call. (Nothing can really be done
about rewriting the user code.)