Deadlock detection-multitasking-remote method invocation


Question 1:

A) List one advantage and one disadvantage of using:

i) Sequential systems.
ii) Concurrent systems.

B) What is the difference between cooperative multitasking and preemptive multitasking?

C) Briefly explain the meaning of each of the following:

i) Condition synchronization.
ii) All-or-nothing atomicity of a transaction.
iii) Remote Method Invocation (RMI).

D) What is the difference between the following Enterprise Java Beans: entity beans, session beans, and message-driven beans.

E) Explain how cookies can be used to maintain an HTTP session. Draw an illustration to support your answer.

Question 2:

Consider the processes in the table below. You are required to apply the following scheduling policies on these processes and find f, q, and n. Also, illustrate the time lines of the processes by adding them to the figure following the table (the blue arrows at the bottom of the figure represent the arrival time of the processes).

a)  First-In, First-Out (FIFO)
b)  Shortest Job First (SJF)

1657_normalized turnaround.jpg

Question 3:

A) Consider the class below which models a counter object that has two methods to increment or decrement its only instance variable, counter. 

a) You are required to apply the wait-notify mechanism in order to make the class thread-safe. Of course the methods need to be synchronized first. Assume that the value of the counter should be kept between 0 and 10.

b) Repeat (a) using a different technique which allows multiple condition variables for different locks, and uses the Java.util.concurrent.locks package. Assume that you have two conditions: notFull and notEmpty.

public class Counter {
    private int counter = 0;
    public void increment() {
        try {
            counter++;
        } catch(Exception e){ 
        } finally {          
        }
    }
    public void decrement() {
        try {
            counter--;
        } catch(Exception e){            
        } finally {
        }
    }
}


B) Consider the MyClient class below. When the main method is executed, the user is asked to enter his/her name and location. This data is sent to a server located at the “localhost” (i.e. on the same computer). Copy this code to a new project in NetBeans IDE and run it.

a) Does the code run properly? Justify your answer.

b) Develop a server class, Server_toScreen, to the following specifications:

•  The server should first display a message “Waiting for next client connection…”. (use System.out.println statement here).
•  The server should listen for incoming connections at port 5555.
•  The server should read data sent to it using an instance of BufferedReader class.
•  The server should display the data sent to it on the screen. Use JOptionPane class for this part.
•  The server should keep repeating (a) to (d) in order to receive data from other clients.

In your solution document, you will need to run the project and include screenshots of the results, before and after writing the server class. The screenshots should include evidences that the code was run on your own machine.

import java.io.*;
import java.net.*;
import javax.swing.JOptionPane;
 
public class MyClient {
    Socket socket;
    PrintWriter out;
    public void run() throws IOException{
        String s;
        socket = new Socket("localhost", 5555);
        out = new PrintWriter(socket.getOutputStream());
s = JOptionPane.showInputDialog("What is your name?");
        out.println(s);
        s = JOptionPane.showInputDialog("Where are you now?");
        out.println(s);
        out.close();
        socket.close();
    }
    public static void main(String[] args) throws IOException {
        new MyClient().run();
    }
}

C) In this question, you will re-write the server class in question (B). However, in this time the server is required to save the received data in a database instead of displaying them on the screen. This database should be located at the same computer as the server (i.e. localhost). The name of the database is clientsData, and the data will be saved in a table named CLIENTS which has two text fields: name and location. Name your server class Server_toDB.

D) Assume we have an entity bean, ClientsEntity, which models a database table, clients, with two fields: name and location. This entity bean has getter methods for all its instance variables. In this question, you need to do the following:

a) Develop a session bean that utilizes the above entity bean in order to retrieve the names of the clients stored in the database. The session bean is stateless, and it will be accessed remotely. In your solution document, you need to provide the following:

• The code for the remote interface implemented by the session bean. The interface should include one abstract method, void getNames().

• The code for the session bean which includes implementation of the getNames() method. This method should query the clients table for all its records. Then it should create one string by concatenating all names stored in the name field of the clients table. This string should finally be returned by the method.

Question 4:

Using the AOU’s eLibrary facility and the internet, locate the paper indicated below and answer the following in your own words:

a) According to the paper, what is the problem with the current deadlock detection approaches?

b) What is name of the approach presented in the paper? List its advantages.

Request for Solution File

Ask an Expert for Answer!!
Operating System: Deadlock detection-multitasking-remote method invocation
Reference No:- TGS0719

Expected delivery within 24 Hours