Hi folks. I am currently studying Computer Science and one of the modules I am taking at the moment is Concurrent & Distributed Systems. My first assignment involves using await statements and semaphores for a train track using Eclipse. I have wrote out code but it has many errors. The link below shows the assignment question and below that is the code I have written so far. Can anyone assist me in completing this assignment? I would be very grateful
https://docs.google.com/viewer?a=v&q...yDbwCEKc0Z8IcA
Code
Global Invariant: (NumberOfTrainsInAnySection <= 1) AND (TotalTrainsOnTrack <= 8) Process main { /* Declare and initialize global variables */ Const Number_Of_Trains = 10; Int NumberOnTrack =0; /* sections on the traintrack */ string sections[0..10] = {[.....], [.....], [.....], [.....], [.....], [.....], [.....], [.....],[.....], [.....], [.....], [.....], }; //* Set the train moving for (count= 1 to NUMBER_OF_TRAINS){ int entry= {0...0}; int exit = { 0...11 }; TrainProcess (entry, exit); } /* end for * } /* end main process // Train Process process TrainProcess (int s, int t) { /* Wait if track is too crowded <await (numberOnTrack<=8) numberOnTrack++; > /* wait for section 1 to be clear from the right side <await ( (section[1]==[.....]) section[1]=[+entry+-->+exit];> /* move forward to exit position (which is 10s) */ int currentPosition = 0*s; int nextPosition = 0*s+1; do { <await (sections[nextPosition]==[.....]) sections[nextPosition]=sections[currentPosition]; sections[currentPosition]=[.....]; > currentPosition = nextPosition; nextPosition = (nextPosition+1) SECTIONS 8; } while (currentPosition <> 2*t) /* move off the track*/ < slots[currentPosition]=[.....]; numberOnTrack--> } /* end TrainProcess