[SOLVED] CS241 Assignment #2 -JavaSynchronization

30.00 $

Category: Tags: , , ,
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon Assignment-2-dkngwm.zip (70.4 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
Rate this product

Problemdescription:

  • It s required to simulate a limited number of devices connected to a router’s Wi-Fi using Java threading and semaphore. Routers can design to limit the number of open connections. For example, a router may wish to have only N connections at any point in time. As soon as N connections are made, the router will not accept other incoming connection until an existing connection is released. In this project, I explained how semaphores can be used by a router to limit the number of concurrent connections.

Consider the followingrules:

 

  • TheWi-Fi numberofconnecteddevices is initially
  • Ifaclientisloggedin(printamessagethataclienthasloggedin)andifitcanbeserved(meansthat it can reach the internet), thentheclient shouldperform thefollowingactivities:
    1. Connect
    2. Perform online activity
    3. Logout

Note:these actionswillberepresentedbyprintedmessages,suchthatthereisarandomwaitingtimebetweentheprintedmessageswhenaclientconnects,dosomeonlineactivities andloggedout.

  • Ifaclientarrivesandallconnectionsareoccupied,itmustwaituntiloneofthecurrentlyavailableclientsfinisheshis service andleave.
  • Afteraclientfinisheshisservice,heleaveandoneofthewaitingclients(ifexist)willconnect to the

 

ProblemDesign

 

You program must contain thefollowing classes:

 

  1. Router Class: that contains a list of connection and methods to occupya connectionandrelease a
  2. SemaphoreClass:asgiven the synchronization
  3. DeviceClass:representdifferentdevices(threads)thatcanbeconnectedtotherouter;eachdevicehasitsownname(i.e.C1)andtype(i.e.mobile,pc,tablet…)anditmayperform threeactivities: connect,perform onlineactivityanddisconnect/logout.
  4. Network Class: this classcontains themain method in which theuseris asked fortwoinputs:
    • N: maxnumberof connections a routercan accept
    • TC: total numberof devices that wishes to connect).
    • TC lines that contain: name ofeachdevice,andits

 

ProgramOutput:

 

You will print the output logs inafile, whichsimulatesthe executionorder ofthedevicesthreads and the printedmessagesofeachdevice.

Example:

Sample Input:

 

Sample output:(Note:output depends on theorder oftheexecutions of thethreads)

 

1 file · 70.4 KB

  • Assignment-2-dkngwm.zip 70.4 KB