首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
COMP 10183代写、代做Java编程语言
项目预算:
开发周期:
发布时间:
要求地区:
COMP 10183 Assignment 2
Fall 2023
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.
Assignment #2 is a more complex teams based race. In Assignment #1 you just needed to track
how long it takes 20 racers to cross the gorge. In this assignment, the racers are divided up into
5 teams of 4 racers each, and they must cross the gorge in both direction.
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.
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 safety, so a racer may only enter a rope if it is
empty.
You do not need to worry about starvation for this assignment. 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.
For this assignment you should not assign racers to ropes in advance. 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.
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 that this design
includes 5 AdventureTeams. You will need a total of 25 threads, a thread for each racer, and a
thread for each racing team. The racing team can make decisions about which rope to select.
For all threads to see the three RopeCrossing objects, you may declare these three objects as
static in your main thread (the RaceSimulation class).
Concurrency and Performance
In the main method, 20 racers will arrive at the beginning of execution. Each racing 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.
The racer will take between 400 and 600 milliseconds to cross the gorge on the rope, which will
be determined randomly.
5 racing teams concurrently set up their equipment: Average time = 300 ms
20 racers use 3 ropes to cross the gorge. Average time = 20 * 500 ms / 3 = 3.3 seconds.
20 racers use 3 ropes to re-cross the gorge. Average time = 20 * 500 ms / 3 = 3.3 seconds.
Total race time should be at least (2 * 3.3s + .3s) = 6.9 secs, usually it will be a little longer.
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 direction.
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.
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). Solutions that rely on busy waiting will receive a penalty.
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.
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 each
racer completes the round trip, you many terminate that individual thread for that racer.
Your program should track and display the following, in order to demonstrate correct
performance:
• Time it takes each team to set up it’s gear
• Each time a team member successfully crosses the gorge
• The time since 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.
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.
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 cross 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 racers is well balanced, i.e. about the same # use each rope.
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, Member 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 Back 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 crossed 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 Back 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 Rope #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
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 cross Rope #2 was: 14
Total Simulation time = 7.034 seconds
Submission
You will submit your java code in a zip folder to the submission 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.
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 sample
▪ Appropriate delays are measured
o timing and performance are good
▪ close to 6.9 seconds run time
▪ well balanced 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.
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
cis432代做、代写python/java程...
2024-05-04
eeen3007j代写、c++程序设计代...
2024-05-04
代写data程序、代做c/c++, jav...
2024-05-04
comp2006代做、代写c++程序语言
2024-05-04
comp26020代做、java/c++设计编...
2024-05-04
csci251 advanced programming...
2024-05-03
cs 6290: high-performance co...
2024-05-03
assignment 2: executing and ...
2024-05-03
ecse427/comp310 programmin...
2024-05-03
cs 452 (fall 22): operating...
2024-05-03
comp9414 23t2 assignment 2 ...
2024-05-03
dpst1091 23t1 assignment 2 ...
2024-05-03
program代做、代写python设计编...
2024-05-03
热点标签
finm8007
comp2006
comp26020
comp1721
eeen3007j
cis432
csci251
comp5125m
com398sust
32022
mth6158
comp328
finn41615
2024
mec302
mgmt3004
mgt7158
com160
as.640.440
econ3016
finm7405
econ7021
fin600
infs4205/7205
mktg2510-
f27sb
csse2310/csse7231
rv32i
eecs 113
comp1117b
cs 412
comp 315
econ7300
comp2017
ecs 116
fit5046
com6511
comp30024
acs341
econ1020
isys3014
acc408
comp1047
csc 256
cs 6347
finm7008
comp34212
csmde21
estr2520
comp285/comp220
mds5130/iba6205
finc6010
is3s665
busi2194
125.785
iom209
msin0041
econ339
cmt218
mast10007
comp5349
ecx2953/ecx5953
bios706
comp3310
mth6150
comp30027
comp20005
eec286
busi2211
bff2401
fnce90046
visu2001
mang6554
finc6001
125785
data423-24s1
engi 1331
fint2100
(520|600).666
can202
cs 61b
mast20029
info20003
stat512
econ3208
cmpsc311
engg1340
ecmt1010
fit5216
basc0003
ee3121
acct2002
comp5313
busi2131
ise529
elec372/472
csit940/csit440
cenv6141
comp3027/comp3927
ftec5580
comp1433
msci223
mark203
en3098
eden1000
ece6483
econ4410
mats16302
cs 6476
com6521
comp222
comp3211
comp10002
csc1002
chc6186
cs 161
comp27112
comp282
swen20003
comm1190
elec9764
acfi3308
acct7101
fin6035
comp2048
geog0163
comp2013
coen 146
dts101tc
sehh2042
comp30023
comp4880/8880
cs 455
07
stat0045.
fil-30023
celen085
psyc40005
math40082
are271
comp9311
ee5311
imse2113
comp 2322
acct2102
fnd109
int102
is3s664
is6153
data4000
accfin5034
fit5212
cs536-s24
fit5225
ecos3006
mes202tc
finc5001
stat3061
csc171
cs1b
7ssmm712
bu.450.760
cs170
comp3411
swen90004
cpt206
comp5313/comp4313—large
bl5611
kxo206
comp532
elec207
kxo151
cs 2820
cpt108
math2319
dts204tc
qm222
comp2511
ccs599
infs1001
mat2355
eeee4123
25721
ifn647
pols0010
hpm 573
qbus6860
comp9417
csci 1100
stat0023
cse340
comp2003j
cs 2550
cs360
fin 3080
ierg 4080
cs6238
cit 594
finm7406
hw6
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!