COMP1040 AE1SYS Exam 2018 12 12

The University of Nottingham Ningbo, China
School of Computer Science
A Level 1 Module, Autumn Semester 2018-2019 Systems and Architecture (COMP1040)
Time Allowed: TWO Hours
Candidates may complete the front cover of their answer book and sign their desk card but must NOT write anything else until the start of the examination period is announced
Answer ALL questions
No calculators are permitted in this examination
Dictionaries are not allowed with one exception. Those whose first language is not English may use a standard translation dictionary to translate between that language and English provided that neither language is the subject of this examination. Subject-specific
translation dictionaries are not permitted.
No electronic devices capable of storing and retrieving text, including electronic dictionaries, may be used.
DO NOT turn examination paper over until instructed to do so
ADDITIONAL MATERIAL: MIPS Reference Card INFORMATION FOR INVIGILATORS:
Collect both the exam papers and the answer booklets at the end of the exam.
COMP1040-E1 1 Turn Over

COMP1040-E1
Question 1 (25)
(a) Convert the following decimal numbers to binary in 8-bit two’s complement representa- tion:
a = 111 b = 20 c = −40 (6)
(b) Using the values in the question above, calculate the following sums using signed 8-bit
two’s complement format:
a+b b+c a−c
In which cases do we get an overflow? (4)
(c) Convert the following 8-bit two’s complement integers into decimal.
a = 111111112 b = 010111112 c = 100000002 (4)
(d) Work out the decimal value of the following single-precision floating point numbers.
1011.011012 (4)
(e) Convert the following decimal number to the IEEE 754 single-precision floating point
forms in binary format.
a = 23.25 (7)
COMP1040-E1 2
程序代写 CS代考 加微信: cstutorcs
COMP1040-E1
Question 2 (25)
(a) Describe the procedure calling conventions for MIPS. Specifically:
(i) What is the instruction used to invoke a callee, and what is the instruction for returning to the caller? (2)
(ii) How are arguments passed and results returned? (2)
(iii) Which of the user registers need to be preserved by the caller and callee respec- tively? (2)
(b) Translate the following C statement to MIPS. Assume that the variables f, g, h are assigned to registers $s0, $s1, $s2 respectively and could be considered 32-bit integers as declared in a C program. (6)
(c) Implement the following C code in MIPS, assuming that the variables i, x, y are stored
in $t0, $s0, $s1 respectively.
for ( i = 0; i < x; i++) y = y + i; } y = y * 2; (d) The following code fragment processes two arrays and produces an important value in register $v0. Assume that each array consists of 2500 words indexed 0 through 2499, that the base addresses of the arrays are stored in $a0 and $a1, respectively, and their sizes (2500) are stored in $a2 and $a3, respectively. Add comments to the code and describe in one sentence what this code does. Specifically, what will be returned in $v0? sll $a2, $a2, 2 sll $a3, $a3, 2 add $v0, $zero, $zero add $t0, $zero, $zero outer: add $t4, $a0, $t0 lw $t4, 0($t4) add $t1, $zero, $zero COMP1040-E1 3 浙大学霸代写 加微信 cstutorcs inner: add $t3, $a1, $t1 lw $t3, 0($t3) bne $t3, $t4, skip addi $v0, $v0, 1 skip: addi $t1, $t1, 4 bne $t1, $a3, inner addi $t0, $t0, 4 bne $t0, $a2, outer COMP1040-E1 4 COMP1040-E1 Computer Science Tutoring
COMP1040-E1
Question 3 (25)
(a) Consider a client-server system with the following performance assumptions:
Latency per packet (local or remote, incurred on both send and receive)
4 milliseconds
Connection setup time (TCP only) Data transfer rate
Maximum Transfer Unit (MTU) Server request processing time
6 milliseconds
8 megabits per second 1000 bytes
2 milliseconds
The client sends a 100 byte request message to the server, which produces a response containing 2000 bytes. Estimate the total time to complete the request in each of the following cases:
(i) Using connectionless communication; (4)
(ii) Using connection-oriented communication; (2)
(iii) The server process is in the same machine as the client, and no connection set-up is needed. For this part, estimate the interprocess data transfer rate on the machine at 16 megabits/second, and latency per message at 3 milliseconds. (4)
The calculations must be written down as well.
(b) As we discussed in our lectures, call-by-copy/restore is an important parameter passing mechanism in remote procedure calling. Now, consider a procedure increm with two integer parameters x and y, which adds one to each of its parameters. Assume that i is an integer variable, and increm is called with the same variable i twice, as in:
increm(i, i)
If i is initially 10, what value will it have afterward if:
(i) call-by-reference is used? (2) (ii) copy/restore is used? (2)
(c) In our module, we discussed socket programming in C. The subject of this question is client-server socket programming under the TCP protocol. Draw a diagram which clearly depicts the various steps taken by both the server, and the client, in establishing a connection under TCP protocol, and subsequent communications. You need to write down the name of the function called at each step. (11)
COMP1040-E1 5 Turn Over

COMP1040-E1
Question 4 (25)
(a) Of the transport layer protocols, we discussed User Datagram Protocol (UDP) and Transmission Control Protocol (TCP):
(i) Write down one feature provided by UDP which is not provided by Internet Pro- tocol (IP). (2)
(ii) Write down two guarantees provided by TCP which are not provided by UDP. (4)
(i) All communication over TCP is encrypted. (1)
(ii) TCP can be implemented over datagram packet delivery. (1)
(iii) UDP can be implemented over virtual circuit packet delivery. (1)
(iv) Wireless networking is based on broadcasting. (1)
(c) A client makes remote procedure calls to a server, and the timing for various operations are as follows:
• The client takes 5 milliseconds to compute the arguments for each request.
• The server takes 7 milliseconds to process each request.
• The local operating system processing time for each send or receive operation is 0.4 milliseconds.
• The network time to transmit each request or reply message is 6 milliseconds.
• Marshalling or unmarshalling takes 0.5 milliseconds per message.
Calculate the time taken by the client to generate and return from two requests:
(i) if it is single-threaded; (6) (ii) if it has two threads that can make requests concurrently on a single processor. (9)
You may ignore the context-switching times.
You should write down your computations clearly.
COMP1040-E1 6 END