```

1) Consider the following algorithm to compute a product in a distributed
system:

int product = 1;
...
pchild = fork();
if (pchild == 0) {
/* childprocess code */
product *= computeFirstNumber();
} else {
/* parent code */
product *= computeSecondNumber();
}
...

Where the two functions
int computeFirstNumber(),
int computeSecondNumber()
do some longrunning computation (e.g. compute primes with 100 digits).

Where's the obvious problem in this code? What OS techniques from the code
do you need to fix it?

2) Assume that in our shell assignment, the programmer wanted to print the
shell prompt after a background process is finished. A solution would be

pchild = fork();
if (pchild == 0) {
/* child process */
...
/* execute program */
execv(path,A);

/* print prompt */
printf("myShell:>>");
}

This solution doesn't work. What's the reason for this? Give a brief
explanation of the semantics of the exec command. Discribe a possible
solution on a high level - WITHOUT coding it. (You don't know the
necessary C commands!).

3) This problem is about scheduling.
a) Define the following terms
* arrival time
* burst time
* turnaround time
* waiting time
b) Consider n processes p1, ... pn with burst times t1, t2, ..., tn.
What is the schedule sequence with maximum waiting time?
Assume that you only know the sum of the burst times
T = t1 + t2 + ... + tn.
Can you give an upper bound on the waiting time of a process for any
process? What about the average waiting time?
b) Consider the following processes p1, ... pn all of which take the
same burst time t. (They arrive in order p1, ... pn).
What's the FCFS average waiting time? (need some computation)
What's the FCFS average turnaround time? (almost obvious)
c) True or false (give a one sentence explanation):
* wait time is less than response time + burst time
* response time is less than turnaround time
* burst time is less than turnaround time
* the time it takes to finish _all_ processes is exactly
sum over all wait times +
sum over all burst times

Also questions from the book:
5.3-5.5, 5.10
6.1-6.8

```