Page 1 of 1

Question 3 (25 Marks) a) The address space of typical UNIX processes is composed of different segments, including Text,

Posted: Mon Mar 21, 2022 4:45 pm
by answerhappygod
Question 3 25 Marks A The Address Space Of Typical Unix Processes Is Composed Of Different Segments Including Text 1
Question 3 25 Marks A The Address Space Of Typical Unix Processes Is Composed Of Different Segments Including Text 1 (52.08 KiB) Viewed 47 times
Question 3 (25 Marks) a) The address space of typical UNIX processes is composed of different segments, including Text, Data, Heap and Stack. Draw a diagram to show how they are stored in the main memory. (4 Marks) Also, indicate which segment(s) will be expanded with directions at runtime. (2 Marks) b) Given a Program Segment, draw a diagram to show how the variables are stored in the main memory. (10 Marks) static int i = 4; int main(...) { int a[16]; int *ptr; int size = 200; ptr = (int *)malloc(size*4);

c) Write down the output of the following program segment. (9 Marks) int main(int argc, char *argv[]) { pid_t pidi, pid2, pid3; == pidi fork(); if (pidi 0) { pid2 - fork(); if (pid2 == 0) { pid3 fork(); == if (pid3 ) { printf("Process 1\n"); } else { wait(NULL); printf("Process 2\n"); printf("Process 2 Done!\n"); } } else { wait(NULL); printf("Process 3\n"); printf("Process 3 Done!\n"); } } wait(NULL); printf("Bye!\n"); return; } // main