Question: 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
