Question
What is a function calling convention and how does it impact the design of the RISC-V instruction set architecture (ISA)? [4 marks] (d) Consider the
What is a function calling convention and how does it impact the design of the RISC-V instruction set architecture (ISA)? [4 marks] (d) Consider the following C function that computes the greatest common divisor, and the assembler produced by the compiler. The assembler has been split into segments. Describe what function each segment performs
(a) Explain the terms Work Conservation and max-min fairness, in the context of packet switching. [8 marks] (b) Outline the operation of two work-conserving queueing schemes that provide max-min fairness, and two (simpler) ones that do not. [8 marks] (c) Give at least two main implementation costs associated with implementations of fairness in packet switched routers. [4 marks] 3 Security (a) Describe the Bell-LaPadula security policy. [6 marks] (b) Describe the Chinese Wall security policy. [6 marks] (c) To what extent is the Chinese Wall policy an extension of Bell-LaPadula? [6 marks] (d) Are either of these policies relevant to digital rights management? [2 marks] 2 CST.2003.7.3 4 Advanced Graphics (a) We want to find the first intersection point between an arbitrary ray and a sphere of arbitrary radius at an arbitrary position in space. (i) List and define all of the parameters required to specify the geometry of the ray and the sphere. [2 marks] (ii) Give an algorithm which returns the desired intersection point (if it exists) and the appropriate normal vector at the intersection point. [5 marks] (b) Describe a method which converts an arbitrary sphere to a triangle mesh at a desired resolution. The desired resolution is specified as a desired number of triangles, D. Your method should produce a number of triangles, N, which is within an order of magnitude of D: D/10 < N < 10D. [4 marks] (c) The Catmull-Clark bivariate subdivision scheme is a bivariate generalisation of the univariate 1 8 [1, 4, 6, 4, 1] subdivision scheme. It creates new vertices as blends of old vertices in the following ways: 16 64 16 64 16 64 16 64 4 64 24 64 4 64 4 64 24 64 4 64 6 64 36 64 6 64 1 64 6 64 1 64 1 64 6 64 1 64 Face Edge Vertex (i) Provide similar diagrams for the bivariate generalisation of the univariate four-point interpolating subdivision scheme 1 16 [1, 0, 9, 16, 9, 0, 1]. [5 marks] (ii) Explain what problems arise around extraordinary vertices (vertices of valency other than four) for this bivariate interpolating scheme and suggest a possible way of handling the creation of new edge vertices when the old vertex at one end of the edge has a valency other than four. [4 marks] 3 [TURN OVER CST.2003.7.4 5 Computer Systems Modelling Let N(t) denote the number of events in the time interval [0, t] for a (homogeneous) Poisson process of rate , ( > 0). (a) State the necessary properties on N(t) that define a (homogeneous) Poisson process of rate . [4 marks] (b) By dividing the interval [0, t] into equal length sub-intervals show that N(t) is a Poisson random variable with mean t. [4 marks] (c) Let X1 denote the time of the first event and for n > 1 let Xn denote the elapsed time between the (n 1)th and the nth events of the Poisson process. Determine the distribution of X1 and the joint distribution of X1 and X2. [4 marks] (d) Let Sn = Pn i=1 Xi denote the time of the nth event. Derive the probability density function of the random variable Sn(t). [4 marks] (e) Give an algorithm to generate the first T time units of a (homogeneous) Poisson process of rate . [4 marks] 6 Specification and Verification I (a) Explain the difference between a variant and an invariant. Briefly describe what they are used for. [4 marks] (b) State and justify the verification conditions for the total correctness of WHILE commands.
(b) Define a predicate JK such that JK(j,k,q) models the behaviour of a JK flipflop. Describe and justify the logical type of JK. (c) Write down a formal specification of a device COUNT such that the output at time t is t mod 4. (d) Design an implementation of COUNT using JK flip-flops, describe how it works and draw a diagram of your design. (e) How you would prove that your design meets its specification?
Consider alternative algorithms for sorting an array of n items. (a) The BST-sort algorithm looks at each element of the array in turn, starting at position 0, and inserts it into a BST (pass 1). Having processed all elements, it repeatedly extracts the minimum from the BST, refilling the array from position 0 onwards (pass 2). (i) Derive, with justification, the computational complexity of each of the two passes of BST-sort. (ii) Describe a way of asymptotically speeding up pass 2 without changing the data structure, yielding enhanced BST-sort, and give the new computational complexity of pass 2 and of the overall algorithm. (iii) Compare enhanced BST-sort against heapsort, mergesort and quicksort with respect to asymptotic worst-case time and space complexity, saying when (if ever) it would be preferable to any of them. (b) The enhanced 2-3-4-sort algorithm is obtained by replacing the BST with a 2-3-4 tree in enhanced BST-sort. (i) Perform pass 1 of enhanced 2-3-4 sort on the array {6,9,3,1,4,3,6,7,5,0,2}, redrawing the tree at each insertion. [Hint: Remember to split 4-nodes on the way down when inserting, and to put keys in the left child and > in the right.] (ii) How much space will enhanced 2-3-4-sort require to sort an array of n items, if each item is m bits long? Give exact upper and lower bounds in terms of n and m rather than an asymptotic estimate. [3 marks] (iii) Repeat question (a)(i) for enhanced 2-3-4-sort. [2 marks] (iv) Repeat question (a)(iii) for enhanced 2-3-4-sort.
(a) State carefully, without proof, the soundness and adequacy results for PCF. (You need not describe the syntax, operational and denotational semantics of PCF in any detail.) [3 marks] (b) Define the logical relation you would use in proving adequacy for PCF. State carefully without proof the "fundamental theorem" for the logical relation. [5 marks] (c) Define contextual equivalence for PCF. [2 marks] (d) Explain carefully the difficulties in obtaining a fully abstract denotational semantics for PCF. [7 marks] (e) Describe how PCF syntax and operational semantics can be extended to obtain full abstraction
A program which decrypts files under the Swap Encryption Scheme by swapping pairs of characters is given below. Some code has been omitted and you do not need to understand the operation of the algorithm. 1 class Swapper extends Reader { 2 private final PushbackReader pushBack; 3 Swapper(PushbackReader p) { pushBack = p; } 4 5 @Override 6 public int read(char[] cbuf, int off, int len) { 7 int r = wrap.read(cbuf, off, len); 8 if (r % 2 == 1) { pushBack.unread(cbuf, off + --r, 1); } 9 for (int i = 0; i < r; i += 2) { swap(cbuf, i, i + 1); } 10 return r; 11 } 12 } 13 14 class Decryptor { 15 static List
(a) A travel agency is surveying their customer satisfaction by randomly polling 300 of their customers. From experience, 80% of their customers are typically happy with their service. Let H be the number of happy customers in the current poll. (i) Randomly polling 300 different customers, specify a suitable distribution for H, including its parameters, expected value and variance. [1 mark] (ii) State a suitable approximation of H and specify its distribution including its parameters, and compute the expected value and variance. [2 marks] (iii) Using the approximation from Part (a)(ii), what is the probability that more than 220 and fewer that 260 customers are happy in the current poll? [4 marks] (iv) Now, let X be the proportion of customers that are happy in the current poll. Following your approximation from Part (a)(ii), give the distribution for X, including its parameters, expected value and variance.
(a) Define what it means for two states in a transition system to be bisimilar. [2 marks] (b) Hennessy-Milner logic has assertions A ::= ^ iI Ai | A | hiA , where I is a set, possibly empty, indexing a collection of assertions Ai , and ranges over a set of actions Act. Define the semantics of the logic within a transition system with actions in Act. (c) Show that if two states in the transition system are bisimilar, then they satisfy the same assertions of the logic. [6 marks] (d) Show that if two states in the transition system satisfy exactly the same assertions of the logic, then they are bisimilar.
) Without describing the details of either, outline the relationship between the Java methods System.out.printf() and String.format(). [2 marks] The ISO representation for the time of day is hh:mm:ss where (for the purposes of this question) hh is a two-digit integer in the range 00 to 23 and each of mm and ss is a two-digit integer in the range 00 to 59. The following Java test program exercises a proposed class Time which enables a time to be represented in ISO format and allows one time to be added to another: public class TimeProg { public static void main(String[] args) { Time t1 = new Time(15,10,5); t1.add(5,10,15); t1.add(10,20); t1.add(5); System.out.printf("%s%n", t1); // outputs 20:30:45 Time t2 = new Time(60,70,80); System.out.printf("%s%n", t2); // outputs 13:11:20 t1.add(t2); System.out.printf("%s%n", t1); // outputs 09:42:05 Time t3 = new Time(); System.out.printf("%s%n", t3); // outputs 00:00:00 } } It may be assumed that only positive arguments are used but note that outof-range values for minutes and seconds are treated sensibly (thus 80 seconds results in 1 being added to the number of minutes). An out-of-range value for hours is held modulo 24. (c) Outline suitable specifications for the two versions of the constructor Time() and the four versions of the add() method. [6 marks] (d) Write a class Time that would work with the test program above.
Write a program to open a text file for writing, and then write user input to the file via a prompt until the user enters an exit keyword.
write ptogram to print square of numbers from 1 to 10 using library functions.
write a program to find the largest of 3 numbers
Provide a full C implementation of the store routine, explaining how the lookup function and changes to values under a given key would work, if this is not obvious from your code. Code efficiency is not important. Hint: You can directly access the non-volatile store using a construct such as ((char)NV_START) [offset).
[10 marks]
(b) The following text almost constitutes both a C++ and Jave program: class Foo( public: int x, y
clasa Teat ( private: void f1(Foo p) (p.x= 1; } private void 12 (Foo &q) (q.y = 2; //[Java]: ignore public: void teat() { Fodp://(Java): replace with: Foo p = new Foo();" Pix - p-y- 99; P - 9:
Foo q-p:
12(q); print("HERE");
};
(6) Explain the storage structure accessible from variables x and y when control reaches print("HERE") following a call to teat (). both in the Java and the C++ interpretations.
[3 marks]
(0) For the C++ interpretation, show how adjustments only to the definition of clana Foo can cause (useful) debngging-style output to be produced at
Programming in C and C++
(a) A key/value store holds pairs of strings in a non-volatile memory (NVA). The NVM is mapped as a memory region between two hardcoded virtual addresses, NV START and NV END. This memory is all set to zero as manufactured and can be freely read, but any write operations result in a logical ORing of the new data with the old data at the addressed location. Bits can never be cleared. Strings representing keys and values will be fewer than 250 characters long. Eventually the memory will fill up, but sufficient is available for the intended application.
The API provides the following two operations: int store(char key, char value) // returns non-zero on error, and char lookup (char key) // returns NULL if not found.
Provide a full C implementation of the store routine, explaining how the lookup function and changes to values under a given key would work, if this is not obvious from your code. Code efficiency is not important. Hint: You can directly access the non-volatile store using a construct such as ((char)NV_START) [offset).
[10 marks]
(b) The following text almost constitutes both a C++ and Jave program: class Foo( public: int x, y
clasa Teat ( private: void f1(Foo p) (p.x= 1; } private void 12 (Foo &q) (q.y = 2; //[Java]: ignore public: void teat() { Fodp://(Java): replace with: Foo p = new Foo();" Pix - p-y- 99; P - 9:
Foo q-p:
12(q); print("HERE");
};
(6) Explain the storage structure accessible from variables x and y when control reaches print("HERE") following a call to teat (). both in the Java and the C++ interpretations.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started