Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Implement the pseudo code in java and C + + program, explain how the semaphores works in the program Pseudocode: class Teams: team _ name
Implement the pseudo code in java and C program, explain how the semaphores works in the program
Pseudocode:
class Teams:
teamname
teammembers
score shared variable
binarysemaphore
def submitsolutionteamname, solutionfile, score:
Critical Section
waitbinarysemaphore Ensure only one team member submits at a time
sendfiletosubmissionstationsolutionfile
signalbinarysemaphore
class SubmissionStation:
solutionfiles
countingsemaphore initialized to the maximum number of concurrent submissions
def receivesolutionsolutionfile:
Critical Section
waitcountingsemaphore Limit concurrent submissions
storesolutionsolutionfile
signalcountingsemaphore
def providesolutionstojudges:
for solutionfile in solutionfiles:
sendfiletojudgesolutionfile
class Judges:
countingsemaphore initialized to the number of judges
def evaluatesolutionsolutionfile:
Critical Section
waitcountingsemaphore Limit concurrent evaluations
if solutioncorrectsolutionfile:
scorekeeper.updatescoresolutionfile.teamname
signalcountingsemaphore
class Scorekeeper:
teamscores
countingsemaphore initialized to the maximum number of concurrent updates
def updatescoreteamname, points:
Critical Section
waitcountingsemaphore Protect score updates
teamscoresteamname points
signalcountingsemaphore
def getscoreteamname:
return teamscoresteamname
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started