SPECIMEN EXAM Flashcards

1
Q

Q1 For each of the following system configurations, explain whether it is capable of being concurrent, parallel, both, or neither. Briefly justify each answer.

(a) One processor, two activities
(b) Four processors, two activities
(c) Three processors, five activities
(d) Two processors, one activity
(5 marks)

A

(a)
One processor, two activities – concurrent but not parallel. Two activities can share one processor by taking turns to use the processor in pseudoparallel
fashion.
(b)
Four processors, two activities – parallel (and therefore concurrent) because two activities can run simultaneously on two of the processors, with two processors idle.
(c)
Three processors, five activities – concurrency is possible by sharing the processors among all the activities. Some parallelism is possible because there are multiple processors but not all activities can be active at once.
(d)
Two processors, one activity – neither concurrent nor parallel because one activity by definition can only be doing one thing at a time.
[An alternative answer is that parallelism or concurrency are possible if the
activity can be broken down into two or more co-operating sub-activities.]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Q2 Explain the need for a processor to run in at least two modes, including a supervisor mode.
(5 marks)

A

A processor must mediate between concurrently running processes to prevent errors.
To achieve this, a processor must be able to run in at least two modes, one of which is used for privileged instructions called the supervisor mode.
Privileged instructions include those involved in performing input and output, as well as those controlling entry and exit from supervisor mode.
Control can be exercised over how privileged instructions are executed, and user processes can be prevented from causing certain kinds of system failures or arbitrarily executing sensitive code, because the processor can only perform these instructions when it is in the right mode. This allows policies to be enforced.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
Q3  Explain how the following mechanisms are related: 
• entry protocols 
• exit protocols 
• semaphores
(5 marks)
A

When several concurrently executing processes share data, the shared data needs to be protected so that only one process at a time can have access to it. A semaphore is a mechanism designed to protect shared data, through its operations ‘wait’ and ‘signal’ which function like an entry and an exit protocol respectively.
Protection can be achieved by requiring that a process executes the entry protocol before using the shared data. If another process is already using the shared data, then the entry protocol will make the new process wait. Once a process has finished using the shared data it should execute the exit protocol. This will then alert waiting processes that they can try to execute the entry protocol again. Or if no processes are waiting, allow the next new process that wishes to execute the entry protocol.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Q4 (a) Give a definition of the term “virtual machine”. (b) Name two components of the Java Virtual Machine and state what they do. (5 marks)

A

(a)
A virtual machine is an abstract computing device that is implemented in software. A virtual machine defines a certain set of instructions and how code and data are organised in the machine’s memory.
(b)
The JVM includes a bytecode verifier that checks whether the bytecode about to be executed has not been tampered with. The JVM also includes a class loader, which loads classes at runtime into the JVM’s memory.
Other components are the bytecode interpreter, garbage collector and JIT
compiler.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Q5 Explain the following statement: “Java’s RMI is a form of communication that follows the distributed object paradigm”. (5 marks)

A

The distributed object paradigm extends the object-oriented paradigm to a distributed setting, so that local and remote objects are treated in the same way and have the same capabilities.
RMI is effectively extending the way that objects invoke methods on other objects to a distributed setting, and hence belongs to the distributed objects paradigm. RMI works by adding an additional layer that deals with the lower level details of the communication, such as data marshalling and sockets. To use RMI requires the existence of a registry so that objects can look up where other objects are located, in order to invoke methods on them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Q6 The execution of three transactions T1 ,T2 and T3 involving three objects A, B and C is interleaved as shown below:

step T1 T2 T3

1 A.read1()
2 A.read2()
3 B.read2()
4 B.read3()
5 C.write1()
6 B.write2()
7 A.write1()
8 B.write3()

(a)
Explain what is meant by ‘conflicting operations’.
(b)
List the conflicting operations in Schedule 1, indicating the order of transaction execution (you may use the step numbers to indicate which operations conflict).
(c)
Show the precedence graph for Schedule 1 and explain whether it is serializable.
(5 marks)

A
(a)
Operations are conflicting if the order in which they are carried out affects the result.
(b)
The conflicting operations:
2 and 7,   T2
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Q7 What are the three main categories of components in the MVC approach and what are their roles? Illustrate your answer with an example for each category.
(5 marks)

A

MVC defines three categories of components: model, view, and controller.
The model is the abstraction of all the domain data in the system. It is the bank account in a banking application, or a shopping cart in an e-commerce system.
The view is the visualisation of the model. In a web application, the view consists of the HTML pages and the components that create the HTML pages sent to web browsers, the WAP pages sent to mobile devices, or the user interface components sent to a dedicated client.
The controller is the set of components that manage the communications between model and view.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Q8 Explain the difference between pull technology and push technology when dealing with clients in a web application. State one approach to implementing push technology.
(5 marks)

A

Pull technology is the normal client-server approach where the client receives information or updates only in response to a request that it sends to the server.
With push technology, the server can notify its clients of any significant changes without the clients having to explicitly make a request each time.
This normally requires clients to register with the server in some way, or to subscribe to a service to indicate an interest in updates. The server may update each client individually or may use some more efficient approach such as multicasting where one message is sent to many clients.
Possible approaches to push technology include (only 1 name required, no details required)
• multipart/x-mixed-replace;
• UDP;
• multicast UDP;
• TCP;
• messaging services (such as JMS).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Q9 For each of the following cryptographic services give an example of a scenario in which you might want to make use of it, with a brief explanation of why the service is an appropriate one for that scenario.
• signature
• certificate
(5 marks)

A
  1. Signature
    Scenario: the recipient wants to check the sender’s identity.
    The sender self-authenticates.
    This could be used in communications where little is at stake, or where the recipient trusts the sender to self-authenticate, because there is no third-party checking the sender’s identity.
  2. Certificate
    Scenario: the recipient wants to check the sender’s identity and requires third-party checking of the identity.
    This might be used in more important communications, for example, where confidential information might be disclosed and it is important to fully authenticate the sender.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Q10 Describe the main function of the ORB in CORBA.

5 marks

A

The main functions of the ORB in CORBA are:
• implementing an object request broker service;
• locating objects able to meet a software request, that is, finding objects able to provide a service to another object;
• preparing an object to receive a software request;
• communicating data between two objects taking part in a software interaction.

The question can also be answered in terms of support for transparencies:
• location transparency – the location of an object is transparent to an object requesting a service;
• implementation transparency – the implementation language of an object is hidden, and the platform is not specified;
• object activation state transparency – the client is not concerned with whether or not a server is actually running or a server object has been activated;
• communication mechanism transparency – the protocol used by ORBs to communicate with each other is transparent to an object requesting a service.
(5 marks)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Q11a Consider the following Java class Account to represent a bank account, with data field balance, and two operations debit and credit which can update the balance.

public class Account 
{
  protected int balance; 
  public Account (int balance)
  { this.balance = balance; }

public void debit (int a)
{ balance = balance - a; }

public void credit (int a)
{ balance = balance + a; }
}

Consider a scenario which creates an Account object myAcc with a balance of 10 and two threads T1 and T2, whereby
T1 calls myAcc.debit(15) and
T2 calls myAcc.credit(20).

(a)
(i) Give a definition of a thread-safe class.
(ii) Show, using the example scenario, how class Account violates the definition.
(iii) What is the general problem of which the scenario is an example?
(5 marks)

A

(a)
(i)
A class is considered thread-safe if its instances behave under concurrent method calls as if they were called sequentially. In other words, it is not possible for a multithreaded application to observe an instance of that class in an inconsistent state, i.e. a state that could not be observed by a single-threaded application.
(ii)
For the example scenario, a sequential execution of
myAcc.credit(20);
myAcc.debit(15);
will lead to a balance of 15, but with two concurrent threads it could lead to a balance of 30. Consider that T2 is interrupted after computing the sum balance + 20. At that point T1 executes the call to debit, leaving a balance of −5. Now T2 resumes execution and assigns 30 to balance.
(iii)
This is an example of the lost update problem.
(5 marks)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
Q11b  
public class Account 
{
  protected int balance; 
  public Account (int balance)
  { this.balance = balance; }

public void debit (int a)
{ balance = balance - a; }

public void credit (int a)
{ balance = balance + a; }
}

Write a class BlockingAccount which is a thread safe version of Account, and in which, additionally, the debit operation blocks until balance is greater than or equal to the amount to be debited. Note: You must use Java’s built-in mechanisms, NOT the Java 1.5 concurrency utilities. (5 marks)

A
public class BlockingAccount
{
   protected int balance;
   public BlockingAccount (int balance) 
   { this.balance = balance; } 

public synchronized void debit (int a)
{
while (balance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Q11c Explain two limitations of the built-in mechanisms used in the previous question (BlockingAccount used …) and how they were addressed by the concurrency utilities introduced by Java 1.5. (5 marks)

A

Java’s built-in monitors are limited in the sense that they have a single implicit condition variable per lock and there is no possibility of retracting lock acquisition attempts.

The concurrency utilities introduced the Lock and Condition interfaces.
Lock has a tryLock method that doesn’t block if the lock is not available.
Condition allows the developer to associate multiple explicit conditions to each lock.
Note: The exact names of interfaces and methods do not have to be fully correct as long as the explanation is clear.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Q11d Explain and compare the thread safety levels of classes Account (ie no sync) and BlockingAccount (ie with sync’d methods).

Discuss why there is a need to identify various thread safety levels and what their existence implies for developers.
(5 marks)

A

Account is thread-compatible because it does not use internal synchronisation and hence requires every method call to be externally synchronised.

BlockingAccount is thread-safe because no external synchronisation is necessary for calling its methods.

Identification of the various thread safety levels is necessary because there are different ways for making classes behave correctly in a concurrent setting (e.g. by making the data immutable or by various degrees of internal and external synchronisation). This means that class developers have to document precisely the class’s safety level and which (sequences of) methods, if any, require external synchronisation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Q11e Describe a schedule for the example scenario, but using BlockingAccount instead of Account, indicating for each thread the states it goes through in the Java Thread state model.
Note: Assume the two threads are NOT in the NEW state. For full marks provide a schedule that uses three different states.
(5 marks)

A

We assume both threads are in the RUNNABLE state.
One of them is scheduled for execution, let’s assume it is T1. It acquires the lock on the account, and starts evaluating the while condition.
At this moment, T2 is scheduled for execution, it tries to obtain the lock, but since it is held by T1, T2 becomes BLOCKED.
Now T1 resumes execution, enters the while loop (because it is attempting to debit 15 from an account holding only 10) and calls wait. This releases the lock and T1 gets into the WAITING state.
T2 is now able to get the lock, becomes RUNNABLE and executes the credit operation, which notifies T1.
T1 thus returns to the RUNNABLE state and completes the debit operation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Q12a Using a diagram or otherwise, name the standard tiers of a Java EE application and indicate the type of components associated with each tier.
(4 marks)

A

Client Tier Browser, applet, application client
Web Tier Servlet, JSP, JavaBean
Business Tier EJB, Entity class
Database / EIS Tier DBMS

17
Q

Q12b
[ Scenario: Website to provide tourist info about a country.
First page - select a region, indicate activity prefs.
Next page - map of region, shows locations that match prefs. Select accom prefs and dates. Select location.
Further page: - show all accom that matches the prefs, allow to book the accom online. ]

Explain the role in Java EE applications of
• stateful EJB session beans
• stateless EJB session beans
• transactions

Discuss how each of these might be used in implementing the web application outlined in the scenario above.
(8 marks)

A

EJB session beans are objects that contain the application logic, providing business services to clients.

Stateful EJBs
In a stateful bean, the state (i.e. the value of the bean’s instance variables) is kept across multiple calls to the bean’s methods. A classic example is a shopping cart in an online shop. The shopping cart has to keep its state (i.e. the products it contains) across multiple interactions with the client, who might add and remove products from the cart.
In the given scenario, stateful EJB session beans could be used to keep track of the user’s preferences for location, activities, accommodation and so on during the session

Stateless EJBs
In a stateless bean, the state is discarded after each method call, i.e. a session with a stateless bean only lasts for the duration of a single method call. This makes stateless beans ideal to provide one-off services that are performed always in the same way, independently of the actual client invoking it. For example, a database query can be seen as a complete session by itself, and it isn’t necessary to keep a record of which client executed which query. Therefore a single stateless bean can provide multiple methods, each one implementing an independent query.
In the given scenario, stateless EJB session beans could be used for example in retrieving the list of accommodation for a particular location.

Transactions
A transaction is a sequence of operations which we want to be performed atomically, that is to be performed in its entirety, or not performed at all.
The classic example of a transaction is a transfer of funds from one account to another in a bank application. This requires a sequence of operations including debiting one account and crediting the other. It is important that either all the operations take place, or that none of the operations takes place.
In the given scenario, transactions will be necessary when booking accommodation to ensure that any booking operations (including payment) complete fully or are not carried out at all.

18
Q

Q12c Explain how HTTP servlets deal with the following issues:
• Handling concurrent requests from multiple clients;
• Avoiding problems with concurrent access to shared data.
(6 marks)

A

• Handling concurrent requests from multiple clients:

For the standard situation of a multi-threaded servlet, the Web container will create and run a separate thread for the service method that is invoked in response to each request. The helper methods such as doGet or doPost which will be invoked by the service method must be written to take account of this.

• Avoiding problems with concurrent access to shared data:

Any data stored in variables declared locally to servlet methods is threadsafe, because each thread has its own copy of local variable data.
By contrast, instance variables or static variables are not thread-safe as they are shared between any threads being run concurrently by the servlet. Code that updates instance data or static data, must use synchronization, so that at most one thread at a time can be carrying out an update.

A very good answer would also include some discussion along the following lines:
It is possible to synchronize the whole service method or its helper methods such as doGet and doPost. While this will protect the shared data, it will usually have an adverse effect on system performance, as it effectively means that HTTP requests can only be processed sequentially by a given instance of the servlet. It is best to synchronize as little of the servlet code as possible, to maximise performance. So, for example, it may be best just to synchronize the potentially unsafe blocks of code.

19
Q

Q12d Issues from part (c)
[ie. concurrent requests from multiple clients; and
problems with concurrent access to shared data.]

Explain whether and how these issues might arise in the given scenario.

[ Scenario: Website to provide tourist info about a country.
First page - select a region, indicate activity prefs.
Next page - map of region, shows locations that match prefs. Select accom prefs and dates. Select location.
Further page: - show all accom that matches the prefs, allow to book the accom online. ]
(4 marks)

A

There may be many users simultaneously using the tourist information site, each searching for different regions, activities and so on – each user request will require a separate service thread for the servlet (or JSP) that responds to the user request.

Much of the data will belong to a particular request and so will be local to a servlet method and not vulnerable to multi-threading interference.

Data that must persist throughout a session across several requests must be stored either in a JavaBean associated with a session object or perhaps in a database. This could apply to the preferences for each user as it is important that users do not accidentally update each others preferences. If stored in a session object then synchronization is not usually needed since each user only has one request active at a time – if this cannot be guaranteed then code that updates the session object should be synchronized.

It is unlikely that instance data or static data will be used, although one possible application would be in keeping track of the number of users online at any given time – updating any such counter variable should be a synchronized operation.

20
Q

Q12e List and discuss three additional issues to consider if we wanted to provide access to the tourist information system from mobile devices such as phones or PDAs. (3 marks)

A

Three possible issues that arise are:

Limited resources on phones/PDAs - because of the smaller screen space and other resources, the web tier and client tier would need to allow for different formatting of the interface – for example as a WAP interface rather than a standard web browser, or perhaps an application client or applet interface

Communication bandwidth may be limited or more unreliable than with fixed network connections – as above this may require a different interface (less complex maps for example) and emphasises the need for transactions etc to cope with intermittent communications failure.

Security issues - interception of mobile communications is, in principle, easier than for fixed lines. For most transactions on this site security would probably not be a major issue, but when booking accommodation the payment process must be secure.

21
Q

Q13a
(i) What is meant by a heterogeneous system?

(ii) Why are heterogeneous systems of particular interest in distributed computing?
(4 marks)

A

(i)
A heterogeneous system is one implemented using more than one kind of computer, operating system, software or communication protocol.

(ii) Heterogeneous systems are of particular interest in distributed computing because distributed computing in a wide context inevitably involves heterogeneity, due to the variety of systems in existence.

[Alternative answers include
• Legacy systems may exist or systems may have been developed by different parties at different locations and times, leading to heterogeneity.
• We cannot ignore heterogeneity if we hope to achieve interoperability or reusability of systems in a distributed context.
• It may be worth getting heterogeneous systems to talk to one another, for such reasons as using a legacy database, or widening access to distributed users.]

22
Q

Q13b
(i) Give a definition of middleware.

(ii) Explain what is meant by homogeneous and heterogeneous middleware, and give an example of each.
(iii) Heterogeneous middleware is more flexible than homogeneous middleware, but has higher overheads. Give two examples of such overheads.

(iv) Would you consider XML to be a form of middleware? Explain.
(8 marks)

A

(i) Middleware may be defined as any software that provides an intervening layer between two communicating systems, providing the ability to make communication between the systems transparent.
OR software that masks the heterogeneity of an underlying system

(ii) Homogeneous middleware is middleware in which all parties are assumed to be implemented in the same language and running on the same platform.
Heterogeneous middleware is middleware in which no assumptions are made about a shared language or a common platform.
Examples:
• homogeneous: Java RMI
• heterogeneous: CORBA

(iii) Overheads:
• additional communication overheads, due to their flexibility and the requirement to translate between heterogeneous representations
• heterogeneous middleware requires the use of an IDL representing features of multiple languages, as opposed to a common interface language (such as Java interface descriptions on both sides).

(iv) No, because XML is not a layer; it is just a way of representing a communication.

23
Q

Q13c
(i) Name two security services that are commonly employed in the database tier of the n-tier model and explain how they are put to use in this context.

(ii) State one advantage of using each service you discussed in this context.
(6 marks)

A

(i) Possible services include the following (only two were asked for)
• Confidentiality, used to obscure stored information, e.g., encrypted passwords or records.
• Integrity, used to check contents of stored files. This could be used on serialized data, e.g., to ensure that it was not altered while on a disk, or it could be used to check the integrity of a database file.
• Authentication, used to check whether a user or caller is allowed to access a file or record.
• Auditing, used to keep track of actions carried out by users or traffic on a system.

(ii) Advantages (only two were asked for but they must relate to the two services identified in (i) above)
• Confidentiality – security of records is enhanced;
• Integrity – increased robustness / security;
• Authentication – reduced risk of unauthorised access / modification etc.;
• Auditing – increased non-repudiation, i.e. increased ability to determine who is responsible for actions or issues.

24
Q

Q13d
(i) Explain the difference between a block cipher and a stream cipher.

(ii) Which of these ciphers would you typically use in wireless communication? Explain why.
(7 marks)

A

(i) A block cipher is one that operates on chunks of data at a time, called blocks, whereas a stream cipher operates on a stream of data, typically a bit or a byte at a time. (This leads to differences in the way these ciphers are implemented, but the main distinction to make is the one above.)

(ii) You would be most likely to use a stream cipher for wireless communication, because
• Stream ciphers are computationally cheaper. This is particularly useful in this context, since computing resources and bandwidth are typically more limited
• Communications in wireless communications are of unpredictable length and so are likely to suffer from a frequent requirement for padding or truncating if a block cipher is used (this again relates to computational requirements / efficiency).