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
Question 3 (25 Marks) a) The address space of typical UNIX processes is composed of different segments, including Text,
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am