Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q4- Write the program in the next page, complete it with the header files. Save it as lab 12q4.c a. Include the source file in

image text in transcribed

Q4- Write the program in the next page, complete it with the header files. Save it as "lab 12q4.c" a. Include the source file in your lab report and show the commands used in the lab report and their run. Open another terminal and show the memory map of the program. Draw in a table the segment names shown in the output, each with its size, start and end address Show the variable addresses with their contents after the indicated lines in a table. b. c. d. Check the output and answer the following questions: At linel: Why x1, x2, x3 have different addresses values that are not in the same range as x4..x8. i. ii. Show in a table for each variable, its address and size, its segment name, starting iii. iv. v. vi. vii. viii. ix. address, and size Why x5 pointer has value in line2 different from linel? Why x7 pointer has its value in line3? Why x8 has same value as x5 in line 4? Why x5 has a new value in line5? Why x7, x8 still have the same values in line5? Why x6 pointer has its value in line3 not in the same range as the contents x5.. x8? Why x9 is the same at lines 2 and above, but not the same as its later values? int xl-1; int x2; const int x3=3; int main() int x4 4 int +x5, x6, +x7, x8, x9; x9-sbrk (0); x5-malloc(sizeof (int)) "X5=50 x6 =mmap(0, sizeo f (int) //Linel PROT-READ | PROT-WRITE, MAP. SHARED I MAP. ANON, , 1, 0) x6-60 x9-sbrk (0); x7-malloc(sizeof (int)) *x7-70; x9-sbrk (0) free (x5); x8-malloc(sizeof (int)); *x8-80; x9-sbrk (0); x5-malloc(sizeof (int)) 1x5=90 free (x5); munmap (x6, sizeof (int)) free (x7) free (x8); x9-sbrk (0) sleep (10); return 0 //Line2 //Line3 //Line4 //Line5 Q4- Write the program in the next page, complete it with the header files. Save it as "lab 12q4.c" a. Include the source file in your lab report and show the commands used in the lab report and their run. Open another terminal and show the memory map of the program. Draw in a table the segment names shown in the output, each with its size, start and end address Show the variable addresses with their contents after the indicated lines in a table. b. c. d. Check the output and answer the following questions: At linel: Why x1, x2, x3 have different addresses values that are not in the same range as x4..x8. i. ii. Show in a table for each variable, its address and size, its segment name, starting iii. iv. v. vi. vii. viii. ix. address, and size Why x5 pointer has value in line2 different from linel? Why x7 pointer has its value in line3? Why x8 has same value as x5 in line 4? Why x5 has a new value in line5? Why x7, x8 still have the same values in line5? Why x6 pointer has its value in line3 not in the same range as the contents x5.. x8? Why x9 is the same at lines 2 and above, but not the same as its later values? int xl-1; int x2; const int x3=3; int main() int x4 4 int +x5, x6, +x7, x8, x9; x9-sbrk (0); x5-malloc(sizeof (int)) "X5=50 x6 =mmap(0, sizeo f (int) //Linel PROT-READ | PROT-WRITE, MAP. SHARED I MAP. ANON, , 1, 0) x6-60 x9-sbrk (0); x7-malloc(sizeof (int)) *x7-70; x9-sbrk (0) free (x5); x8-malloc(sizeof (int)); *x8-80; x9-sbrk (0); x5-malloc(sizeof (int)) 1x5=90 free (x5); munmap (x6, sizeof (int)) free (x7) free (x8); x9-sbrk (0) sleep (10); return 0 //Line2 //Line3 //Line4 //Line5

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Horse Betting The Road To Absolute Horse Racing 2

Authors: NAKAGAWA,YUKIO

1st Edition

B0CFZN219G, 979-8856410593

More Books

Students also viewed these Databases questions