M362 2010 Exam Flashcards

1
Q

Briefly state three reasons why concurrent and distributed systems are important.

A

Real world systems, such as the Earth’s climate, business or governmental systems are both concurrent and distributed. Most of the systems we may wish to model with a computer are concurrent and distributed.

Concurrent and distributed systems can be involved in ensuring the efficient use or sharing of resources such as hardware, software, data or communication links.

Concurrent and distributed systems enable improvement in the service to users, for example: distribution can make systems accessible from a wider range of locations; concurrency can enable computer systems to respond more quickly to users.

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

Briefly state the main difference between a process and a thread and hence explain the advantages that threads have over processes.

A

Threads are a unit of dispatching but not of resource management while processes are both. Threads share an address space (memory) through which they can communicate cheaply relative to processes.

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

State whether the Java Virtual Machine (JVM) runs as a thread or a process.

A

JVM is a process.

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

Briefly explain the facilities built into the core Java language to support:
(a) Mutual exclusion.

A

Java has built in method synchronization to ensure only one process at a time can access a shared resource. The Java language uses the keyword synchronized in the header of the method, or around the section of code which is to be executed under mutual exclusion. A thread executing a synchronised area of code must hold the lock for the object concerned. If a thread comes to a point where it wants to execute a synchronized area of code but the lock is held by another thread it is blocked.

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

Briefly explain the facilities built into the core Java language to support:
(b) Condition synchronisation.

A

Condition synchronisation in Java is implemented using the wait-notify mechanism which uses the wait, notify, and notifyAll methods within synchronised methods. In this mechanism a condition must hold true before the thread can proceed. A thread invoking the wait method will give up hold of the lock for that object, and enter the WAITING state. Notification by another thread, which hopefully makes the condition true, can allow the waiting thread to proceed. An object’s lock is released when it leaves the area of synchronised code.

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

What does the term thread safe mean when applied to a Java class?

A

If a class is said to be thread-safe its instances behave under concurrent method calls as if they were called sequentially.

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

Explain why the class MyWrapper in Figure 1 is thread safe.

A

The value of the instance variable number is set when an object is created but afterwards there is no means to alter it (no setter method only getter) and so the data is immutable and the class is thread safe.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
Explain why the class MyPointer in Figure 2 is not thread safe as it stands, and say how it could be changed to make it thread safe (you may describe
in words what needs to be done, or, if you prefer, give the modified code).
A

The method MyPointer is not thread safe. It is possible for a thread to inspect an instance with the getPosition method while other threads modify it with the method moveBy.

public class MyPointer

{

private int position = 0;

public synchronized void moveBy(int number)

{

position = position + number;

}

public synchronized int getPosition()

{

return position;

}

}

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

Suppose two-phase locking (2PL) is in use and transactions T and U perform the operations shown in Table 1.

Unfortunately both transactions have violated the rules of 2PL. Say where in the table the errors occur and explain how the rules have been broken.

A

Before an object is first used by a transaction it must be locked. At step 9 transaction T has used object A without locking it first.

A transaction cannot make use of an object which is locked by another transaction. At Step 8 transaction U locks object C which is currently locked by transaction T.

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

2PL is one form of pessimistic concurrency control. It is also possible to have optimistic concurrency control. Briefly describe the conditions under
which the optimistic approach might be more suitable, and one possible advantage of using it.

A

Optimistic concurrency control is more suitable where conflicts are rare, and can be dealt with after the event. The advantage to using it is that it is cheapest to employ.

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

A Java client can make use of distributed objects using Remote Method Invocation (RMI). It is also possible for Java clients to access Enterprise Java
Beans (EJBs) and invoke methods on those. Describe three significant ways in which these two ways of using remote objects resemble one another.

A

Both bind the server object to a symbolic name in a registry.

Java clients and RMI both look up remote objects to obtain a reference to the server object.

Both use the reference to make a remote method call.

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

What are session beans and what purpose do they serve?

A

Session beans are a type of EJB that handles an interactive session between a client and the application server. They access and modify entities, shielding data from clients.

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

Name the two types of session beans and explain the main difference between the two types.

A

The two types of session bean are:

1) stateful session bean
2) stateless session bean

The main difference between the two is that in stateless session beans the state is discarded after each method call while stateful session beans retain information across multiple method calls.

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

Both servlets and JavaServer Pages (JSP) are mechanisms used to generate web pages. Explain when one would use JSP and when one would
use servlets.

A

Servlets are useful for more complex processing, where the static content of the response is very limited or is delegated to another component.

JSP is suited to constructing dynamic web pages in situations where the output is predominantly static HTML or XML.

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

Give two reasons for using JSP Expression Language or Tag Libraries in JSP pages in preference to Java scriptlets and expressions.

A

It helps separate processing (Java code in servlets) from presentation (JSP pages using tags and EL). This may help maintenance in complex applications.

It allows web designers not familiar with Java to produce and maintain JSP pages.

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

Write the following table in your answer book and complete the last three rows, indicating ‘yes’ or ‘no’ for each of the client technologies. (You may abbreviate the text.)

A

Wasn’t sure if standard java should have ‘No’ for both directly interacts columns.

17
Q

In a recent incident, an organisation suffered an attack on its infrastructure in which session cookies containing information that could be used to authenticate a user to the system were captured and reused by the attackers to enter an existing session.
Briefly explain three security measures (in Java EE or otherwise) that might help to prevent such an attack from happening.
No code is required.

A

Answer 1

The Information stored could be stored in an encrypted state to prevent use by attackers. (Not sure if that would help stop hackers entering an existing session but it might make it harder for an attacker to guess how to use the info).

The authentication data could be configured so authentication data can only be used once. (Nonce Values).

The communication between client and server could be encrypted using HTTPS to prevent sniffing the communication and obtaining the cookie information.

Answer 2

I gave: nonce values, message digest authentication of the client, and the count found in IPv6 headers.

Answer 3

Encrypt the cookies.

Delete old cookies.

Only use HTTPS if sending cookies over internet.