1. Homepage
  2. Programming
  3. COMP 10183 Parallel Processing - Assignment 2: Adventure racing teams

COMP 10183 Parallel Processing - Assignment 2: Adventure racing teams

Engage in a Conversation
Mohawk CollegeCOMP 10183COMP10183Parallel ProcessingJavaThreads

COMP 10183 Assignment 2

Fall 2023 Prepared by: Karen Laurin & Dave Gilbert CourseNana.COM

Overview

In this assignment you will be demonstrating your knowledge of creating and maintaining threads and using mutual exclusion techniques taught in class to protect critical sections of code to prevent data races. CourseNana.COM

Assignment #2 i s a more complex teams based race. In Assignment #1 you just need ed to track how long it takes 20 racers to cross the g orge. In this assignment, the racers are divid ed up into 5 teams of 4 racers eac h, and they must cross the gorge in both direction. CourseNana.COM

The Problem

You will be simulating adventure racing teams moving across a gorge on a ropes course. Each adventure team consists of four members, who must all cross the gorge, the team may then claim the ropes course medallion and then all four team members must cross the gorge back to continue on in the race. CourseNana.COM

The gorge consists of three rope crossing points. There is no way to pass another racer on the rope and each rope can only support one racer for safe ty, so a racer may only enter a rope if it is empty . CourseNana.COM

You do not need to worry about starvation for this a ssignment. If an adventure racing team or single racer has to wait some time for their turn on the rope that is ok, this is a race, no need to try and implement fairness or sharing . CourseNana.COM

For this assignment you sho uld not assign racers to ropes in advanc e. Because racers must go in both directions, and the race will be won by the team that finishes first, pre -assigning racers to ropes would create a major disadvantage. CourseNana.COM

The Design

The design for this simulation should follow the basic UML class diagram given below. You may add any variables or methods you feel are necessary to solve the problem. Notice t hat this design includes 5 AdventureTeams. You wi ll need a total of 25 threads, a thread for each racer, and a thread for each racing team. The racing team can make de cisions about which rope to select. CourseNana.COM

For all threads to see the three RopeCrossing objects, you may declare these three o bjects as static in your main thread (the RaceSimulation class). CourseNana.COM

Concurrency and Performance

In the main method, 20 racers will arrive at the beginning of execution. Each rac ing team needs time to set up their gear, which can randomly take between 200 and 400 milliseconds . Once a team is ready, racers can begin crossing. Each racer must individually select a rope to cross . No racer may make a return crossing until all their team mates have crossed . CourseNana.COM

The racer will take between 400 and 600 milliseconds to cross the gorge on the rope, which will be det ermined randomly . CourseNana.COM

5 racing teams concurrently set up their equipment: Average time = 300 ms CourseNana.COM

20 racers use 3 ropes to cross the gorge. Average time = 20 * 500 ms / 3 = 3.3 seconds. CourseNana.COM

20 racers use 3 ropes to re-cross the gorge. Average time = 20 * 500 ms / 3 = 3.3 seconds. CourseNana.COM

Total race time should be at least (2 * 3.3s + .3s) = 6.9 secs, usually it will be a little longer . CourseNana.COM

The JVM may not award the rope’s lock to the racer’s in a FIFO (first -in-first-out) manner. This is correct behaviour and does not need to be changed or managed. It is luck of the draw if the racer is able to grab the rope when available for their direct ion. CourseNana.COM

You will need a way to track when all four members have crossed the gorge and the team can claim their medallion . Consider using a simple atomic integer counter owned by the team. CourseNana.COM

To obtain full marks, communication between the threads should be using wait – notify, not busy waiting . The use of timed sleep in the code is only to represent the racer doing something (setting up or crossing the rope). Solutio ns that rely on busy waiting will receive a penalty. CourseNana.COM

Once all four team members have made it across, the team may claim their medallion and begin to cross back. Make sure the team members do not start crossing back until all members have crossed in the first direction. Each racer must individually select a rope to cross and it will take the racer a random amount of time. Their second crossing time may be different from their first . CourseNana.COM

Once the team has completed the round trip crossing, they should print their success to the terminal and then all threads corrrespoding to the team and it’s racers may terminate. As ea ch racer completes the round trip, you many terminate that individual thread for that racer. CourseNana.COM

Your program should track and display the following, in order to demonstrate correct performance: CourseNana.COM

• Time it takes each team to set up it’s gear • Each time a team me mber successfully crosses the gorge • The time si nce the simulation started that each team finishes at o You should maintain a global start time, so each team can compute their end time • The total number of racers to cross on each rope • The total execution time , this will the same as the time of the losing team. CourseNana.COM

For the output, make sure to clearly identify the Team and which Team Member . This can be done using integers (like done below) or you can name the Teams and Members using Strings. CourseNana.COM

Sample Output

The following output confirms correct simulation details in several ways. Total time is a little bit over 6.9 seconds. Team 3 is the loser, their cro ss time = total simulation time. The sum of the number of racers to cross the ropes adds up to 40, i.e. 20 racers in each direction. The number of racer s is well bala nced, i.e. about the same # use each rope. CourseNana.COM

Team 2 currently setting up gear for 233 ms Team 4 currently setting up gear for 291 ms Team 0 currently setting up gear for 297 ms Team 3 currently setting up gear for 270 ms Team 1 currently setting up gear for 318 ms Team 2, Member 3 crossed Forward on Rope #0 in 407 ms Team 2, Member 4 crossed Forward on Rope #1 in 527 ms Team 2, Member 1 crossed Forward on Rope #2 in 533 ms Team 0, Member 3 crossed Forward on Rope #0 in 443 ms Team 4, Member 4 crossed Forward on Rope #2 in 407 ms Team 3, Member 1 crossed Forward on Rope #1 in 432 ms Team 4, Member 2 crossed Forward on Rope #0 in 506 ms Team 3, Member 4 crossed Forward on Rope #1 in 459 ms Team 1, Member 2 crossed Forward on Rope #2 in 558 ms Team 0, Member 4 crossed Forward on Rope #0 in 507 ms Team 1, Member 4 crossed Forward on Rope #1 in 451 ms Team 2, Member 2 crossed Forward on Rope #2 in 507 ms Team 2 successfully obtained medallion Team 3, Member 3 crossed Forward on Rope #0 in 404 ms Team 0, Member 2 crossed Forward on Rope #1 in 513 ms Team 4, Membe r 1 crossed Forward on Rope #2 in 423 ms Team 0, Member 1 crossed Forward on Rope #0 in 405 ms Team 0 successfully obtained medallion Team 4, Member 3 crossed Forward on Rope #1 in 472 ms Team 4 successfully obtained medallion Team 2, Member 3 crossed B ack on Rope #2 in 471 ms Team 2, Member 4 crossed Back on Rope #0 in 553 ms Team 2, Member 1 crossed Back on Rope #2 in 472 ms Team 0, Member 2 crossed Back on Rope #1 in 561 ms Team 4, Member 2 crossed Back on Rope #2 in 423 ms Team 0, Member 3 cross ed Back on Rope #0 in 595 ms Team 1, Member 1 crossed Forward on Rope #1 in 561 ms Team 0, Member 1 crossed Back on Rope #2 in 591 ms Team 4, Member 1 crossed Back on Rope #0 in 587 ms Team 3, Member 2 crossed Forward on Rope #1 in 457 ms Team 3 successfully obtained medallion Team 2, Member 2 crossed Back on Rope #2 in 428 ms Team 2 completed crossing, total time since race started = 5.077 secs Team 4, Member 3 crossed Back on Rope # 0 in 506 ms Team 1, Member 3 crossed Forward on Rope #1 in 587 ms Team 1 successfully obtained medallion Team 0, Member 4 crossed Back on Rope #2 in 537 ms Team 0 completed crossing, total time since race started = 5.618 secs Team 4, Member 4 crossed Ba ck on Rope #0 in 587 ms Team 4 completed crossing, total time since race started = 5.77 secs Team 3, Member 2 crossed Back on Rope #1 in 587 ms Team 3, Member 4 crossed Back on Rope #2 in 506 ms Team 1, Member 4 crossed Back on Rope #0 in 541 ms Team 1, Member 2 crossed Back on Rope #1 in 494 ms Team 1, Member 1 crossed Back on Rope #2 in 436 ms Team 1, Member 3 crossed Back on Rope #0 in 455 ms Team 1 completed crossing, total time since race started = 6.771 secs Team 3, Member 1 crossed Back on Rop e #1 in 447 ms Team 3, Member 3 crossed Back on Rope #2 in 463 ms Team 3 completed crossing, total time since race started = 7.03 secs CourseNana.COM

The number of racers to cross Rope #0 was: 13 The number of racers to cross Rope #1 was: 13 The number of racers to cros s Rope #2 was: 14 CourseNana.COM

Total Simulation time = 7.034 seconds CourseNana.COM

Submission

You will submit your java code in a zip folder to the su bmission folder on MyCanvas. There is no need to zip up the entire project, you just need to include all of the .java files in the zip folder . CourseNana.COM

Grading

You will be evaluated on the following: • Code Formatting and Documentation – 20% o Code is readable o Javadoc and commenting are complete ▪ No need to generate Javadoc in html files • Code Execution and Performance – 40% o Submission correctly solves the above problem ▪ Output very similar to samp le ▪ Appropriate delays are mea sured o timing and performance are good ▪ close to 6.9 seconds run time ▪ well ba lanced use of ropes • Code Structure – 40% o Code uses the correct programming concepts to solve the problem ▪ follows the UML design specification ▪ should use wait() / notify() and locks() , where appropriate ▪ penalty for using busy waiting ▪ penalty for accessing global variables without proper synchronization . CourseNana.COM

Get in Touch with Our Experts

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
Mohawk College代写,COMP 10183代写,COMP10183代写,Parallel Processing代写,Java代写,Threads代写,Mohawk College代编,COMP 10183代编,COMP10183代编,Parallel Processing代编,Java代编,Threads代编,Mohawk College代考,COMP 10183代考,COMP10183代考,Parallel Processing代考,Java代考,Threads代考,Mohawk Collegehelp,COMP 10183help,COMP10183help,Parallel Processinghelp,Javahelp,Threadshelp,Mohawk College作业代写,COMP 10183作业代写,COMP10183作业代写,Parallel Processing作业代写,Java作业代写,Threads作业代写,Mohawk College编程代写,COMP 10183编程代写,COMP10183编程代写,Parallel Processing编程代写,Java编程代写,Threads编程代写,Mohawk Collegeprogramming help,COMP 10183programming help,COMP10183programming help,Parallel Processingprogramming help,Javaprogramming help,Threadsprogramming help,Mohawk Collegeassignment help,COMP 10183assignment help,COMP10183assignment help,Parallel Processingassignment help,Javaassignment help,Threadsassignment help,Mohawk Collegesolution,COMP 10183solution,COMP10183solution,Parallel Processingsolution,Javasolution,Threadssolution,