1. Answer the following questions:
a) For what purpose are relocation tables needed? What information
is stored in the relocation table?
b) Consider the process states:
2. Compile the following recursive program into TTK-91 machine language.
static long Duo(int n) { if n < 1 then return 1 else return Duo(n-1)+n+1; }Write also a main program, that calls method Duo.
3. Write an assembly program which consists of a function MValue and a main program. The function MValue has two parameters. The first one is the address of the first word of an array and the second is the size of the array. The array has been stored in the static data part of the program. The function returns the mean value of the integers in the array. The main program reserves 100 words for the array, reads the size of the array ( < 100) and the elements and calculates the mean value of the elements with the help of the function and outputs it.
4. Explain in detail the tasks of the CPU and the operating system when the time slice for the running process terminates. Your explanation should answer at least to the following questions:
5. When an interrupt has been handled, it's possible that the process which was running before the interrupt is not continued, at least not immediately. Give examples of this kinds of situations. On the other hand, when is it sensible to continue running the same process?
6. Expand the semaphore example below to cover situations where there are three processes executing and none of them is allowed to proceed before the other two processes have arrived to a certain point.
Example of the synchronization of two processes: establishing a normal phone connection. process A: process B: ..... ... dial number wait for a call up(proceed-B) down(proceed-B) wait for the other to answer answer the phone down(proceed-A) up(proceed-A) talk, talk, talk talk, talk, talkThe problems of parallel processes and semaphores are discussed in Tanenbaum's book on page 436-445.