CS ECE 354 Machine Programming and Organization Summer 2022 SOLUTION Midterm Exam Thursday July 14th 2022 Weight 15 CLOSED BOOK ONE 8 5 x11 SHEET OF NOTES TWO SIDED ALLOWED NAME DO NOT OPEN EXAM UNTIL TOLD TO DO SO Read over the entire exam before beginning WRITE YOUR NAME ON EACH SHEET You will turn in your cheat sheet with your exam so please make sure your name is written on it Upon announcement of the end of the exam stop writing on the exam paper immediately Pass the exam to the head of the tables to be picked up by the proctor the TAs and me The instructor will announce when to leave the room Failure to follow instructions may result in forfeiture of your exam and will be handled according to the UW Academic Misconduct policy After the midterm please do not discuss exam questions with other students until we go over them in class Name Section 1 Multiple Choice 30 points Please fill in the provided Scantron answer sheet for your answers to this section We will not be looking at any marking you make in this section of the exam Question 1 1 point When using gdb to debug a program you can use the step and next commands to advance the current state of the debugger If one of these commands is entered a line of output is printed Which of the following is true about that line A gdb shows the line of code that was just executed B gdb shows the line of code that is about to be executed C gdb shows all the contents of all the registers D None of the above Question 2 1 point In a typical Von Neumann architecture for a computer system source code executables and general files are stored on which the following when the program in not being run A The processor B Main memory DRAM C The bus interconnects D Storage DISK SSD Hard Flash E None of the above Question 3 1 point Every I O device including disks keyboards displays and even networks is modeled as a Question 4 1 point In a 64 bit byte addressable machine how many memory locations are used to store an int A Page B Register C File D Cache E None of the above A 1 B 2 C 4 D 8 E None of the above Name Question 5 1 point In a 64 bit word addressable machine how many memory locations are used to store an int Question 6 1 point Which register holds a pointer to the top of the run time stack Question 7 1 point The is the segment of the virtual address space that holds the assembly instructions to run a program Select the option to fill in the blank A 1 B 2 C 4 D 8 E None of the above A rbp B rsp C rsi D rdi rdx E A OS reserved B Code C Text D Stack heap E None of the above Question 8 1 point int i 8 for int i 0 i 3 i printf d i What is the output that is produced by the above snippet of code assume all necessary libraries have been included A 3 B 4 C 8 D 24 E None of the above Name Question 9 1 point What is the major insight of Amdhal s Law A To speed up an entire application we must improve the speed of a very large fraction of the application B The speed and capability of transistor technologies can be expected to double every two years C As transistors get smaller their power density remains constant D None of these Question 10 1 point Is the following statement true A define line defines a symbolic constant to be a particular string of characters A True B False Question 11 1 point Consider the following line of code run on a 64 bit machine short arr 10 If arr 3 0x7FFFFFFFFFFFFF28 what is the address of arr sizeof arr Question 12 1 point The is the program that reads commands entered to stdin and forwards program output to stdout Select the option to fill in the blank A 0x7FFFFFFFFFFFFF10 B 0x7FFFFFFFFFFFFF20 C 0x7FFFFFFFFFFFFF30 D 0x7FFFFFFFFFFFFF40 E 0x7FFFFFFFFFFFFF50 A Mouse B Keyboard C Shell D Terminal E Memory allocator A Code B Text C Stack D Heap E None of the above Question 13 1 point Where are the local variables of a function stored Name Question 14 1 point Based on how we have discussed padding and alignment in class when an int is declared inside a struct padding may be inserted to ensure that the address of the int falls on a byte boundary Select the smallest value of padding that avoids performance degradation to fill in the blank Question 15 1 point How many different numbers can you represent using exactly 9 bits Question 16 1 point At some point in the implementation of function A function B is called At a later line of code in function A function C is called The starting address of C s stack frame is located A Above A s stack frame at a lower starting address B At the same starting address of A s stack frame C Above B s stack frame at a lower starting address D At the same starting address of B s stack frame E Both A D Question 17 1 point Select the operator with the highest precedence A 1 B 2 C 4 D 8 E 16 A 9 B 128 C 256 D 512 E 1024 A B C D E Name Question 18 1 point Consider the following line of code What is comp A A function returning a void pointer B A pointer to a void returning function C A variable of type void D None of the above Question 19 1 point Consider the following line of code What is comp A A function returning a void pointer B A pointer to a void returning function C A variable of type void D None of the above void comp void comp Question 20 1 point Consider the following definition for a node on a 64 bit machine struct node s struct node s left struct node s right double data 2 Using the padding and alignment rules discussed in class what would sizeof struct node s return A 16 B 24 C 32 D 48 E None of the above Name Question 21 1 point Consider the following definition for a node on a 64 bit machine union node u struct union node u left union node u right internal double data 2 Using the padding and alignment rules discussed in class what would sizeof union node u return A 16 B 24 C 32 D 48 E None of the above Name Please refer to the following program output for questions 22 to 30 You may make the following assumptions When storing metadata this implementation of malloc uses the LSB to denote if a block is allocated 1 or free 0 are present Addresses …
View Full Document
Unlocking...