Question: Unix and MTX support the system calls fork ( ) , exec ( ) and wait ( ) , each returns - 1 if the

Unix and MTX support the system calls fork (), exec() and wait (), each returns -1 if the syscall fails. Assume that a.out is the binary executable of the following program:
```
main (int argc, char *argv[]) i
if (fork ()==0)
A: exec("a.out again");
else
B: wait(bargc);
}
```
a) Starting from a process, e.g. P2.
i. After fork (), which process executes the statement A and what does it do?[5]
ii. Which process executes the statement B and what does it do?
b) Analyse the run-time behaviour of this program. If you think it would cause MTX to crash, think again, carefully.
Question 3[20 Marks]
a) If a pipe has no more readers, a writer considers this as a BROKEN PIPE error and aborts. On the other hand, if a pipe has no more writers, it is not a BROKEN_PIPE to a reader. Explain why this is the case?
b) A bi-directional pipe is a pipe that supports \(\mathrm{R}/\mathrm{W}\) in both directions. If a process creates a pipe but does not close the R/W ends of the pipe, can such a pipe be bi-directional? Explain your answer.
c) Assume a free memory linked list containing the holes in memory is used to keep track of the available memory areas. Each list clement contains the beginning address and the size of a hole in memory. A syscall function knfree (beginAddress, size) is used to release the memory area back to the free memory list after a process terminates or changes image size.
What possible cases may arise when releasing memory with kmfree and how can they be addressed?
Question 4[20 Marks]
Conceptually, the heap area of an execution image is in between the Data and Stack areas. This is because we would like to keep the stack at the high end of the virtual address space. In practice, the heap area can be located after the stack area, as shown below.
In this case, brk ()/ sbrk () would extend the heap area towards the right. Assume that the maximal heap size is 16 KB .
a) Show how to set the initial stack pointer of an image.
b) When the heap is expanded by brk()/ sbrk (), is it necessary to adjust the stack frame pointers in the new image? Justify your answer.
c) Design and write down an algorithm for this kind of brk()/ sbrk().
Unix and MTX support the system calls fork ( ) ,

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!