Explain why, on a busy system, key press echoes might be delayed when a high-priority user interacts
Question:
Explain why, on a busy system, key press echoes might be delayed when a high-priority user interacts with a low-priority application. Propose a solution, describing how each of the above system calls should be changed, and any additional state required. Describe limitations that might apply.
system call chroot have (or the GNU/Linux command-line tool of the same name)? [2 marks] (ii) What kinds of resource canam P use chroot? [4 marks] (iii) Why would a developer or user of a program want to do this? Give a concrete example. [4 marks] (iv) Name two other kinds of resource on a Unix system for which access is not affected by chroot. [2 marks] (b) User jane types the following three commands into her Linux shell: $ id uid=1002(jane) gid=1002(jane) groups=20(dialout),513(staff) $ ls -l ptool -rwsr-xr-x 1 (i) State the various user and group identities associated with the started ptool process, by copying and completing the following table: real effective saved user ID group ID supplementary groups [4 marks] (ii) Which values is the ptool process permitted to provide in the seteuid about users and computers in an LDAP object tree. It controls access to such objects using an extension of the access-control list mechanism also used for Windows NTFS files. What additional field does Active Directory ACEs use compared to NTFS ACEs and what is its purpose? [2 marks]
) Assume a 32-bit architecture with hardware support for paging, in the form of a translation lookaside buffertation. Assume that the TLB is shared rather than flushed on process switching and that the operating system designers are supporting "soft" segments. (i) In addition to page number and page base, what fields would you expect to find in each TLB register? How would each of these be used? [4 marks] (ii) What fields would you expect to find in a process page table? How would each of these fields be used? [6 marks] (b) (i) Outline the function of a timing device. [2 marks] (ii) Why are timers essential in multiprogramming operating systems? [2 marks] (iii) Explain the operation of a multi-level feedback queue in process scheduling. [6 mar
The Java class below defines a queue data structure with a fixed capacity. public class F boolean enqueue(int x) false; mData[mTail]=x; mTail++; return true; } public int dequeue() { if (mTail==mHead) return -1; int v=mData[mHead]; mHead++; return v; } } (a) Explain the risks posed by the lack of access modifiers specified on the state. Which access modifier is appropriate for these entities? [3 marks] (b) Discuss the choice to signal enqueue and dequeue errors using return values of false and -1, respectively. Suggest a better alternative and modify enqueue and dequeue to use it. [5 marks] (c) Explain how an enqueue operation on a FixedCapacityQueue object could fail with an error even when there are fewer items in the queue than the assigned capacity of the object. Show how to fix this. [3 marks] (d) Rewrite the class to use Java's Generics so that it can be used to represent queues of arbitrary objects (Integers, Strings, etc). Use the java.util.ArrayList class instead of int[] for the type of mData. [4 marks] (e) Explain why it was necessary to replace the int[] type of mData in part (d), and why ArrayList does not suffer from the same issue. [5 marks]
(a) Explain the risks posed by the lack of access modifiers specified on the state. Which access modifier is appropriate for these entities? [3 marks] (b) Discuss the choice to signal enqueue and dequeue errors using return values of false and -1, respectively. Suggest a better alternative and modify enqueue and dequeue to use it. [5 marks] (c) Explain how an enqueue operation on a FixedCapacityQueue object could fail with an error even when there are fewer items in the queue than the assigned capacity of the object. Show how to fix this. [3 marks] (d) Rewrite the class to use Java's Generics so that it can be used to represent queues of arbitrary objects (Integers, Strings, etc). Use the java.util.ArrayList class instead of int[] for the type of mData. [4 marks] (e) Explain why it was necessary to replace the int[] type of mData in part (d), and why ArrayList does not suffer from the same issue. [5 marks]
Give a brief summary of the main syntactic constructs found in the programming language Smalltalk. Other languages often have the conditional constructs if-then-else and while. Show how these two constructs can be defined in Smalltalk. [8 marks] Illustrate the use of Smalltalk by showing how you would define a method to compute the factorial of an integer. [8 marks] Although Smalltalk was originally designed to be an interpretive language, modern implementations are dramatically more efficient. Briefly outline what techniques might have been used to make this improvement.
(a) Brieflfly explain the difffferences between combinational and sequential logic.
[2 marks]
(b) With the aid of appropriate diagrams, brieflfly explain the operation of Moore
and Mealy fifinite state machines and highlight their difffferences. [6 marks]
(c) The state sequence for a binary counter is as follows:
The counter is to be implemented using four synchronously clocked D-type
flflip-flflops.
(i) Draw a state table for the counter, showing the required D inputs.
[4 marks]
(ii) Find expressions for the D inputs, making use of unused states if
appropriate. [6 marks]
(iii) What problem could occur when the counter circuit is powered-up? Give
two possible general methods for overcoming the problem. [2 marks]
2CST.2008.2.3
2 Digital Electronics
(a) With the aid of relevant diagrams, show the effffect on the output of a
combinational logic circuit of a:
(i) static hazard;
(ii) dynamic hazard. [3 marks]
(b) Simplify the following expressions using Boolean algebra:
(i) X = (A + B + A . B).(A + B). A . B
(ii) Y = (A + B + A . B). C
[4 marks]
(c) Given:
F = A . B . C . D + A . C + B . C . D + B . C + A . C . D + A . B . C . D
(i) Show using a Karnaugh map that F can be simplifified to
F1 = A . B + A . B + A . C + B . C . D
[2 marks]
(ii) Show that there are a total of four possible expressions for F. [3 marks]
(iii) Show how F1 can be implemented using NAND gates and draw the circuit
diagram. Assume that complemented input variables are available.
[2 marks]
(iv) Show how the static 1 hazard in F1 can be eliminated using a Karnaugh
map-based approach. [2 marks]
(v) Now implement F1 assuming that only 2-input NAND gates are available.
[4 marks]
3 (TURN OVER)CST.2008.2.4
SECTION B
3 Discrete Mathematics
Let X and Y be sets. You are reminded that a relation from X to Y is a subset of
the product X Y .
(a) Explain what it means for a relation f from X to Y to be a function, an
injection and a surjection from X to Y . [4 marks]
(b) A bijection from X to Y is defifined to be a function from X to Y which is
both an injection and a surjection. Prove that a function f from X to Y is a
bijection iffff it has an inverse function g, i.e. g is a function from Y to X such
that g f = idX and f g = idY .
[Remember to prove both the "if" and "only if" parts of the assertion.]
[12 marks]
(c) Describe, without proof, a bijection from P(X Y ) to (X P(Y )) and its
inverse. [4 marks]
4CST.2008.2.5
4 Discrete Mathematics
Let I be a non-empty subset of the natural numbers N = {1, 2, 3, }.
The set S is defifined to be least subset of N such that
I S, and
if m, n S and m < n, then (n m) S.
Defifine h to be the least member of S. This question guides you through to a proof
that h coincides with the highest common factor of I, written hcf (I), and defifined
to be the natural number with the properties that
hcf (I) divides n for every element n I, and
if k is a natural number which divides n for every n I, then k
divides hcf (I).
[Throughout this question you may assume elementary facts about division.]
(a) The set S may also be described as the least subset of N closed under certain
rules. Describe the rules. Write down a principle of rule induction appropriate
for the set S. [4 marks]
(b) Show by rule induction that hcf (I) divides n for every n S. [3 marks]
(c) Let n S. Establish that
if p.h < n then (n p.h) S
for all non-negative integers p. [5 marks]
(d) Show that h divides n for every n S. [Hint: suppose otherwise and derive a
contradiction.] [5 marks]
(e) Explain very brieflfly why the results of parts (b) and (d) imply that h = hcf (I).
[3 marks]
5 (TURN OVER)CST.2008.2.6
SECTION C
5 Probability
(a) Suppose that X is a random variable whose value r is distributed Geometric(p).
Write down the expression for the probability P(X = r). [3 marks]
(b) By using a suitable generating function or otherwise, show that the expectation
E(X) = (1 p)/p. [5 marks]
The University Computing Service defifine a serious power outage as a power cut that
lasts for longer than their Uninterruptable Power Supply equipment can maintain
power. During the course of an academical year the number of serious power outages
is a random variable whose value is distributed Geometric(2/5). Accordingly, the
probability of having no serious power outages during the course of a year is 2/5.
(c) The University is investigating a compensation scheme which would make no
payment over the year if the number of serious power outages were zero or
one but which would pay the Computing Service 1000 for every such outage
(including the fifirst) if the total number of serious power outages in a year were
two or more. Determine the expected annual sum that the Computing Service
would receive. [8 marks]
(d) To what value would the parameter of the Geometric Distribution have to be
changed (from 2/5) for the expected annual sum to be 750? [4 marks]
6 Probability
(a) Give a brief account of the Trinomial Distribution and include in your
explanation an expression that is equivalent to n
!
r!(n
r)! prqnr for the Binomial
Distribution. [5 marks]
(b) An indicator light can be in one of three states: OFF, FLASHING and ON, with
probabilities 1/2, 2/5 and 1/10 respectively. A test panel has fifive such lights
whose states are mutually independent.
(i) What is the probability that all fifive lights are OFF? [3 marks]
(ii) What is the probability that three lights are OFF, one light is FLASHING
and one light is ON? [3 marks]
(iii) What is the probability that three or more lights are OFF and at most one
is ON? [9 marks]
All results must be expressed as fractions.
6CST.2008.2.7
SECTION D
7 Software Design
Software systems often incorporate structural representations of the application
domain in which they operate. For example, a vehicle control system should be
aware of the fact that the car has precisely four wheels. This kind of information
must be captured, encoded and tested at each stage of the software design process.
Using the number of wheels in a car as a simple example, describe relevant design
activities and products at each of the following phases of a software project:
(a) inception; [4 marks]
(b) elaboration; [4 marks]
(c) construction; [4 marks]
(d) transition; [4 marks]
(e) system operation. [4 marks]
8 Regular Languages and Finite Automata
(a) Explain what is a context-free grammar and the language it generates.
[4 marks]
(b) What does it mean for a context-free grammar to be regular? Given any
deterministic fifinite automaton M, describe a regular context-free grammar
that generates the language of strings accepted by M. [4 marks]
(c) Construct a non-deterministic fifinite automaton with -transitions whose
language of accepted strings is equal to the language over the alphabet {a, b, c}
generated by the context-free grammar with non-terminals q0 and q1, whose
start symbol is q0 and whose productions are q0 abq1, q1 , q1 q0 and
q1 abc. [4 marks]
(d) Is every language generated by a context-free grammar equal to the
set of strings accepted by some non-deterministic fifinite automaton with
-transitions? Justify your answer. (Any standard results about regular
languages you use should be carefully stated, but need not be proved.)
[8 marks]
7 (TURN OVER)CST.2008.2.8
9 Professional Practice and Ethics
(a) The British Computer Society Code of Conduct has four sections. What kind
of professional conduct does each section cover, and how does each of these
kinds of conduct benefifit the profession and its members? [8 marks]
(b) True or False questions:
(i) A User can provide occasional use of the University computer system for
a friend who is a temporary visitor.
(ii) Circumstances that mitigate minor infractions of the rules promulgated
by the Information Technology Syndicate include, among other things,
inebriation.
(iii) Appropriate use of the Cambridge University Data Network (CUDN)
means bona fifide academic activity plus a low level for private purposes.
(iv) Small amounts of commercial activity are acceptable as long as the User
is acting in a private capacity.
[4 marks]
(c) The IT industry is increasingly aware of its own environmental impact.
Describe at least one environmental problem to which the industry contributes
and how, as an IT professional, you can help to solve this problem. [4 marks]
(d) "Social engineering is a greater threat to computer security than computer
cracking software." What is social engineering and what measures can be
taken to guard against it? [2 marks]
(e) What is copyleft and how is it used to protect free, open-source, software?
(a) Brieflfly explain the difffferences between combinational and sequential logic.
[2 marks]
(b) With the aid of appropriate diagrams, brieflfly explain the operation of Moore
and Mealy fifinite state machines and highlight their difffferences. [6 marks]
(c) The state sequence for a binary counter is as follows:
The counter is to be implemented using four synchronously clocked D-type
flflip-flflops.
(i) Draw a state table for the counter, showing the required D inputs.
[4 marks]
(ii) Find expressions for the D inputs, making use of unused states if
appropriate. [6 marks]
(iii) What problem could occur when the counter circuit is powered-up? Give
two possible general methods for overcoming the problem. [2 marks]
2CST.2008.2.3
2 Digital Electronics
(a) With the aid of relevant diagrams, show the effffect on the output of a
combinational logic circuit of a:
(i) static hazard;
(ii) dynamic hazard. [3 marks]
(b) Simplify the following expressions using Boolean algebra:
(i) X = (A + B + A . B).(A + B). A . B
(ii) Y = (A + B + A . B). C
[4 marks]
(c) Given:
F = A . B . C . D + A . C + B . C . D + B . C + A . C . D + A . B . C . D
(i) Show using a Karnaugh map that F can be simplifified to
F1 = A . B + A . B + A . C + B . C . D
[2 marks]
(ii) Show that there are a total of four possible expressions for F. [3 marks]
(iii) Show how F1 can be implemented using NAND gates and draw the circuit
diagram. Assume that complemented input variables are available.
[2 marks]
(iv) Show how the static 1 hazard in F1 can be eliminated using a Karnaugh
map-based approach. [2 marks]
(v) Now implement F1 assuming that only 2-input NAND gates are available.
[4 marks]
3 (TURN OVER)CST.2008.2.4
SECTION B
3 Discrete Mathematics
Let X and Y be sets. You are reminded that a relation from X to Y is a subset of
the product X Y .
(a) Explain what it means for a relation f from X to Y to be a function, an
injection and a surjection from X to Y . [4 marks]
(b) A bijection from X to Y is defifined to be a function from X to Y which is
both an injection and a surjection. Prove that a function f from X to Y is a
bijection iffff it has an inverse function g, i.e. g is a function from Y to X such
that g f = idX and f g = idY .
[Remember to prove both the "if" and "only if" parts of the assertion.]
[12 marks]
(c) Describe, without proof, a bijection from P(X Y ) to (X P(Y )) and its
inverse. [4 marks]
4CST.2008.2.5
4 Discrete Mathematics
Let I be a non-empty subset of the natural numbers N = {1, 2, 3, }.
The set S is defifined to be least subset of N such that
I S, and
if m, n S and m < n, then (n m) S.
Defifine h to be the least member of S. This question guides you through to a proof
that h coincides with the highest common factor of I, written hcf (I), and defifined
to be the natural number with the properties that
hcf (I) divides n for every element n I, and
if k is a natural number which divides n for every n I, then k
divides hcf (I).
[Throughout this question you may assume elementary facts about division.]
(a) The set S may also be described as the least subset of N closed under certain
rules. Describe the rules. Write down a principle of rule induction appropriate
for the set S. [4 marks]
(b) Show by rule induction that hcf (I) divides n for every n S. [3 marks]
(c) Let n S. Establish that
if p.h < n then (n p.h) S
for all non-negative integers p. [5 marks]
(d) Show that h divides n for every n S. [Hint: suppose otherwise and derive a
contradiction.] [5 marks]
(e) Explain very brieflfly why the results of parts (b) and (d) imply that h = hcf (I).
[3 marks]
5 (TURN OVER)CST.2008.2.6
SECTION C
5 Probability
(a) Suppose that X is a random variable whose value r is distributed Geometric(p).
Write down the expression for the probability P(X = r). [3 marks]
(b) By using a suitable generating function or otherwise, show that the expectation
E(X) = (1 p)/p. [5 marks]
The University Computing Service defifine a serious power outage as a power cut that
lasts for longer than their Uninterruptable Power Supply equipment can maintain
power. During the course of an academical year the number of serious power outages
is a random variable whose value is distributed Geometric(2/5). Accordingly, the
probability of having no serious power outages during the course of a year is 2/5.
(c) The University is investigating a compensation scheme which would make no
payment over the year if the number of serious power outages were zero or
one but which would pay the Computing Service 1000 for every such outage
(including the fifirst) if the total number of serious power outages in a year were
two or more. Determine the expected annual sum that the Computing Service
would receive. [8 marks]
(d) To what value would the parameter of the Geometric Distribution have to be
changed (from 2/5) for the expected annual sum to be 750? [4 marks]
6 Probability
(a) Give a brief account of the Trinomial Distribution and include in your
explanation an expression that is equivalent to n
!
r!(n
r)! prqnr for the Binomial
Distribution. [5 marks]
(b) An indicator light can be in one of three states: OFF, FLASHING and ON, with
probabilities 1/2, 2/5 and 1/10 respectively. A test panel has fifive such lights
whose states are mutually independent.
(i) What is the probability that all fifive lights are OFF? [3 marks]
(ii) What is the probability that three lights are OFF, one light is FLASHING
and one light is ON? [3 marks]
(iii) What is the probability that three or more lights are OFF and at most one
is ON? [9 marks]
All results must be expressed as fractions.
6CST.2008.2.7
SECTION D
7 Software Design
Software systems often incorporate structural representations of the application
domain in which they operate. For example, a vehicle control system should be
aware of the fact that the car has precisely four wheels. This kind of information
must be captured, encoded and tested at each stage of the software design process.
Using the number of wheels in a car as a simple example, describe relevant design
activities and products at each of the following phases of a software project:
(a) inception; [4 marks]
(b) elaboration; [4 marks]
(c) construction; [4 marks]
(d) transition; [4 marks]
(e) system operation. [4 marks]
8 Regular Languages and Finite Automata
(a) Explain what is a context-free grammar and the language it generates.
[4 marks]
(b) What does it mean for a context-free grammar to be regular? Given any
deterministic fifinite automaton M, describe a regular context-free grammar
that generates the language of strings accepted by M. [4 marks]
(c) Construct a non-deterministic fifinite automaton with -transitions whose
language of accepted strings is equal to the language over the alphabet {a, b, c}
generated by the context-free grammar with non-terminals q0 and q1, whose
start symbol is q0 and whose productions are q0 abq1, q1 , q1 q0 and
q1 abc. [4 marks]
(d) Is every language generated by a context-free grammar equal to the
set of strings accepted by some non-deterministic fifinite automaton with
-transitions? Justify your answer. (Any standard results about regular
languages you use should be carefully stated, but need not be proved.)
[8 marks]
7 (TURN OVER)CST.2008.2.8
9 Professional Practice and Ethics
(a) The British Computer Society Code of Conduct has four sections. What kind
of professional conduct does each section cover, and how does each of these
kinds of conduct benefifit the profession and its members? [8 marks]
(b) True or False questions:
(i) A User can provide occasional use of the University computer system for
a friend who is a temporary visitor.
(ii) Circumstances that mitigate minor infractions of the rules promulgated
by the Information Technology Syndicate include, among other things,
inebriation.
(iii) Appropriate use of the Cambridge University Data Network (CUDN)
means bona fifide academic activity plus a low level for private purposes.
(iv) Small amounts of commercial activity are acceptable as long as the User
is acting in a private capacity.
[4 marks]
(c) The IT industry is increasingly aware of its own environmental impact.
Describe at least one environmental problem to which the industry contributes
and how, as an IT professional, you can help to solve this problem. [4 marks]
(d) "Social engineering is a greater threat to computer security than computer
cracking software." What is social engineering and what measures can be
taken to guard against it? [2 marks]
(e) What is copyleft and how is it used to protect free, open-source, software?
(a) Write brief notes on polymorphism in ML, using lists and standard list functions
such as @ (append) and map. [4 marks]
(b) Explain the meaning of the following declaration and describe the corresponding
data structure, including the role of polymorphism.
datatype 'a se = Void | Unit of 'a | Join of 'a se * 'a se;
[4 marks]
(c) Show that ML lists can be represented using this datatype by writing the
functions encode_list of type 'a list -> 'a se and decode_list of type
'a se -> 'a list, such that decode_list (encode_list xs) = xs for every
list xs. [3 marks]
(d) Consider the following function declaration:
fun cute p Void = false
| cute p (Unit x) = p x
| cute p (Join(u,v)) = cute p u orelse cute p v;
What does this function do, and what is its type? [4 marks]
(e) Consider the following expression:
fn p => cute (cute p)
What does it mean, and what is its type? Justify your answer carefully.
2
Foundations of Computer Science
(a) Write brief notes on the queue data structure and how it can be implemented
effiffifficiently in ML. In a precise sense, what is the cost of the main queue
operations? (It is not required to present ML code.) [6 marks]
(b) Run-length encoding is a way of compressing a list in which certain elements
are repeated many times in a row. For example, a list of the form [a, a, a, b, a, a]
is encoded as [(3, a),(1, b),(2, a)]. Write a polymorphic function rl_encode to
perform this encoding. What is the type of rl_encode? [6 marks]
(c) The simple task of testing whether two lists are equal can be generalised to allow
a certain number of errors. We consider three forms of error:
element mismatch, as in [1,2,3] versus [1,9,3] or [1,2,3] versus [0,2,3]
left deletion, as in [1,3] versus [1,2,3] or [1,2] versus [1,2,3]
right deletion, as in [1,2,3] versus [1,3] or [1,2,3] versus [1,2]
Write a function genEquals n xs ys that returns true if the two list