Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CMPSC311 - Introduction to Systems Programming Midterm Exam 2

Friday November 4, 2013 – Section 2 - 3:35pm–4:25pm

Please  read the  instructions  and questions  carefully.  You will be graded for clarity and correctness.  You have 50 minutes to complete this exam, so focus on those questions whose subject matter you know well. This is a closed book exam.  Write legibly and check your answers before handing it in.

Short Answer - some will be one or two words – no more than 1 sentence.  (40/100 points)

1.  (5pts) Describe the difference between a MAP SHARED and MAP PRIVATE memory mapping.

2.  (5pts) Where is $HOME?

3.  (5pts) What parameter type does the gdb  x command take?

4.  (5pts) What program statement do you use to check if something is always true (and stop the program if it is not)?

5.  (5pts) What is non-blocking I/O?

6.  (5pts) In one C statement, copy 10 bytes from char  *src to char  *dest

7.  (5pts) What is the difference between brk() and sbrk()

8.  (5pts) What does the "w+"  fopen mode mean?

9.  (5pts) Bonus: What command do you use in gdb to get help?

Long Answer - no more than 4 sentences (20/100 points)

9.  (10pts) Name and describe the four ways to advance a program after reaching a breakpoint in gdb.

10.  (10pts) What is page table and what is in it?

Programming/Word Problems - take your time and answer clearly and completely.  (40/100 points)

11.  (10pts) Convert the decimal number 1719 to hexadecimal and show your work.

12.  (10pts) Write a function ireverse which takes a 32-bit unsigned integer and performs a byte-wise reversal. That is the most significant byte should be placed in the least significant byte, the second most in the second least, etc.

13.  (10pts) Write a function to dynamically allocate a string of length len, fill each printable character with the letter A, and return it. len is passed in as a parameter.

14.  (10pts) Write a function writeFile that takes an array of 10 integers as a parameter and writes each one per line as ASCII text to a le output.dat” .