Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java You will be creating two classes: Node and Head. The Head will setup the ServerSocket and the Nodes will call the Head. I want

Java

You will be creating two classes: Node and Head. The Head will setup the ServerSocket and the Nodes will call the Head.

I want this done in two phases. Phase one is to have all the Nodes connect to the Head, but not to issue any work to the Nodes until all of them have connected. The Head won't know where the Nodes are connecting from, but it will know exactly how many Nodes it is expecting. The Nodes, of course, need to know the location/port of the Head.

Once all the Nodes have connected, the Head should then divide up the work and tell each of the Node what it is to do. The Nodes should receive this information, do the work, and send back a result. The Head will keep the socket open with each Node until it receives the result back.

Again, just like the last few labs, we will be doing prime finding as the work. A range of 1000 - 1000000 works well for this lab.

Note that once all the Nodes have connected, you then need to tell all the Nodes to do work. You can start out doing this one at a time in serial. That is, tell the first one to do some range, then wait for its result. Then tell the next one to do some range, then wait for its result. Etc. However, eventually you will want to do this in parallel. Thus, you Head will need to have Threads running to handle the passing out of work. Don't forget about potential race conditions. You can make a method in Java synchronized and only one thread will be able to run it at a time. This is a similar concept to C++ mutex locks.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Identify the SYSTEM OF INTEREST (SOI).

Answered: 1 week ago

Question

Compare the different types of employee separation actions.

Answered: 1 week ago

Question

Assess alternative dispute resolution methods.

Answered: 1 week ago

Question

Distinguish between intrinsic and extrinsic rewards.

Answered: 1 week ago