M362 2012 Exam Flashcards

1
Q

For each of the following system configurations, explain whether it is capable of being concurrent, parallel, both, or neither. Briefly justify each
answer.
(i) Three processors, one activity
(ii) One processor, three activities
(iii) Three processors, two activities
(iv) Three processors, six activities

A

i) three processors, one activity

Neither concurrent nor parallel as only one activity. The activity will run on one of processors while the other two remain idle. If the activity could be split into two or more subactivities then some concurrency and even parallelism would be possible.

ii) one processor, three activities

Concurrent but not parallel: the activities can share one processor in a pseudo-parallel fashion.

iii) three processors, two activities

parallel and therefore concurrent – each activity can progress simultaneously on one processor with one idle.

iv) three processors, six activities

A mixture of parallel and pseudo-parallel activity is possible here. Some processes must share one or more processors.

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

Give two benefits of a sequential system.

A

Programming more straightforward and easier to trace bugs.

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

Scheduling policies attempt to achieve various desirable system characteristics. Fairness is one such characteristic. Briefly explain two others.

A

Answer 1

robustness – ability to maintain desirable characteristics under varying system loads.

throughput – achieve maximum number of processes completed per unit of time

Answer 2

* Responsiveness
* High resource utilisation

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

Read the following scenario and answer the questions that follow.
A bank account, account1, has a balance of £0. Two concurrent processes, P1 and P2 both attempt to credit account1 with £5. After the processes have
completed these operations, account1 should have a balance of £10, but the balance is only £5.
(a) Explain how this lost update could have happened.

A

Answer 1

P1 reads account1 as having a balance of £0. This is stored in the register for P1. P1 is called to a halt. P2 completes the whole statement and credits account1 with £5. P1 is scheduled again and now completes the statement crediting account1 with £5. The write operation made by P2 is lost, because P1 overwrites it.

Answer 2

One process has modified the value in between the other process reading & modifying it. e.g. P1 reads balance, P2 reads balance, P2 sets balance to read value 0 + 5 = 5, P1 sets balance to read value 0 + 5 = 5. The first update has been lost.

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

Read the following scenario and answer the questions that follow.
A bank account, account1, has a balance of £0. Two concurrent processes, P1 and P2 both attempt to credit account1 with £5. After the processes have
completed these operations, account1 should have a balance of £10, but the balance is only £5.
(b) Briefly show how the lost update could have been avoided.

A

Answer 1

The problem could have been avoided if the statement as whole had been treated as an atomic action. It would be possible to avoid the lost update by dividing the source code of the program into critical and non-critical regions, and allowing execution of the critical region only by one process at a time (mutual exclusion). This is done by the use of entry protocols that prevent a process entering a critical region if another process is already there and an exit protocol which signals when the resource is available. P1 would execute the entry protocol and if no other process was in the critical region would proceed and credit account1 with £5. On leaving the critical region an exit protocol would be sent which would allow P2 to do likewise.

Answer 2

Neither process should have been allowed to interrupt the other - they should have made atomic transactions

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

The Java 1.5 concurrency utilities were designed to overcome certain limitations in Java’s built-in concurrency mechanism. State three of these limitations.

A

Answer 1

Three limitations are:

1) Java monitors have a single anonymous condition variable which makes it impossible to distinguish which threads are waiting for the same lock on different conditions.
2) A thread cannot state how long it is willing to block when waiting for a lock to become available, which can lead to a thread been blocked indefinitely if there is a deadlock.
3) The application cannot assume a runnable thread with highest Java priority will be the one scheduled to run next.

Answer 2

* Poor concurrency for collections
* Built in monitor has only a single anonymous condition
* Threads can’t state maximum length of time to block

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

Message-oriented middleware makes use of an intermediary for the communication between senders and receivers. Explain the role of this intermediary and how it affects this type of communication.

A

Answer 1

The sender deposits a message with the messaging system which acts as an intermediary. This frees up the sender to continue with other processing. If the receiver is not up and running or has no space in its buffer to receive another message, the messaging system will hold on to the message until the receiver is ready to receive it which makes it a reliable form of communication.

Answer 2

The messaging system sits between the senders and the receivers. It receives messages from senders and adds them to the queues of the appropriate receivers. When the receivers are able to be sent messages, it can send them messages from this queue.
It simplifies the modelled relationships from many to many, to many to one (a bit like a join table). It provides a single centralised location for messages to be coordinated - which is manageable and efficient. The message queue makes this reliable as messages can be held if the receiver is not ready. It might introduce a slight overhead in travel time.

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

What are entity classes in Java EE and what purpose do they serve?

A

Answer 1

Entity classes hold data. They allow Java programs to interact with relational databases.

Answer 2

Entity class in Java EE are objects which map to database entities. They help translate an object into a suitable format for a database.

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

How do entity classes and entities map to a relational database?

A

Answer 1

An entity class corresponds to a table, each instance of it to a record in the table, and each column to an instance variable.

The mapping is through annotations:

1) the class is annotated with @Entity to state it is an entity class
2) @Table(name = string) to provide the table corresponding to the class
3) @Id is the instance variable corresponding to the primary key
4) @JoinColumn(name = string) is the foreign key
5) @Column(name = string) is used if the column name differs from instance variable

Answer 2

class = table
object = row
variables = column
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

The following table, which has four missing entries, describes the three steps that take place when using Remote Method Invocation (RMI)
Complete the table by providing missing text for each labelled cell.

A

Answer 1

A Bind

B Client object and Registry

C Client object and Remote object

D The client object uses the reference to make a remote method call.

Answer 2

A Binding
B Registry, Client object
C Client object, proxy object, remote object
D Client object invokes a method of the proxy object which forwards its parameters for a method call to the remote object

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

What are the advantages and disadvantages of servlets compared to applets in providing dynamic content for web pages?

A

Answer 1

Advantages:

Servlets more scalable and additional servers can be used to run more servlets if there is heavy demand on the system.

Servlets are stored and run in a controlled environment on the server, and so can use full power of the Java language and its libraries, and access other servers and invoke other programs. Un-trusted applets on the other hand suffer severe restrictions.

Servlets can be a larger code as they do not need to be downloaded from a server before running as with applets.

Disadvantages:

Servlets are less responsive and can suffer network delays compared to applets which run on the client machine.

Answer 2

Servlets versus Applets

* Network Traffic Calls *
Servlets cause more network traffic calls.
Applets only need to be downloaded once, then can apply dynamic effects without further traffic.

* Location of processing *
Servlets process on server which can use limited resources.
Applets process on client, which distributes processing better.

* Responsiveness *
Servlets incur a lag due to network.
Applets processed locally so are more responsive.

* Security Restrictions *
Servlets are in a secure environment, so can use all Java.
Applets cannot use all Java (by default), such as file access.

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

Briefly explain the meaning of the term logical time.

A

Answer 1

Logical time is a system of recording time values so as to ensure that the order of events is consistent with causality. The logical time of sending a message over a network should occur at a time earlier than the logical time of the arrival of the message. Logical time is not normally related to the actual time.

Answer 2

Logical time is not real time. It is an agreement between distributed components of a system that a time variable shall be incremented periodically, and corrected forwards when needed. Its initial value need not be the real time nor need it ever match real time - it could just be an integer.

(After a tutorial today I realise I missed some good keywords from this: “causality” “synchronisation”.)

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

Suppose hosts A, B and C currently have logical times of 1009, 1008, and 1012 respectively. A sends a message to B which then forwards it to C.
Explain what logical times A, B and C will record immediately afterwards, briefly showing your working.

A

Answer 1 (see pic)

Host A sends a message including the timestamp 1009. Host B, the receiving host, compares the message timestamp of 1009 with its own of 1008 and finds it necessary to increment its own logical time to 1010 to ensure the arrival time is later than the sending time. Host B sends the message including timestamp of 1010 to Host C. Host C compares the message timestamp of 1010 with its own of 1012. Host C’s logical time is already greater than the sender’s time-stamp so it is not necessary to adjust its logical time.

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

Give two differences between Remote Method Invocation (RMI) and web services.

A

Answer 1

Web services do not provide a registry to store information about services and a means to discover information about these services.

Web services do not assume that both parties are implemented in Java as in RMI.

Answer 2

* Web services are provided via a http address. RMI has a set registry it consults to find a remote object it can use.
* RMI is a method for invoking remote code transparently, as if it was running locally. Web services are quite apparently not local, and so not location transparent.

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

Explain the role of WSDL in implementing a web service.

A

Answer 1

WSDL is a XML markup describing operations provided by a web service component. It is a way of separating the implementation of a component from its description. It describes the location of a service (host or port), the protocol to be used, the message used, the types of argument and the return types.

Answer 2

Web Services Description Language allows a common way of describing what services are available from a server for a client to use.
A web service that has been described with WSDL can be registered with a UDDI server, which can then be queried by a client to find the web service.

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