Roller Coaster is a Concurrency Programming course project.
This is a work from the Concurrent Programming course in which two solutions were implemented using different methods of synchronization. The methods used to solve the problem were implicit locks - with monitor implementation - and explicit locks.
A roller coaster is a popular attraction of amusement parks and modern theme parks. It consists of a steel structure forming a trail made up of elevations followed by falls and, sometimes, inversions. Most of the roller coasters have several cars in which passengers sit and are restrained (obviously for safety reasons), while some work with a single car and a larger number of passengers.
Suppose a roller coaster that has a single car with capacity for C passengers. Passengers, in a total of n (n > C), often wait to get into the car, which can only be allowed to enter the trail when it is full. After completing a ride, each passenger strolls through the amusement park before returning to the roller coaster to try to enter on another ride. For safety reasons, the car carries out only P tours per day and, once reached that number, it is turned off.
Design and implement a program that simulates the operation of a roller coaster meeting the following requirements:
During the execution of the program, the following actions must be performed for each entity:
For readability purposes, the program shall display on the standard output the execution of each of the operations performed by the passengers and the car. The total number of passengers n, the capacity of car C, and the maximum number of P-trips that can be performed per day should be provided as input to the program as command line arguments. Case C < n, the program should show an error message to the user and be immediately shut down.
We usually use an IDE (like NetBeans or Eclipse) to compile and build the program, but if you want to compile via terminal use the following commands.
Open the project folder:
cd RollerCoasterMonitor
Run the following commands:
./make.sh
make.sh
content
#!/bin/bash
cd src
# Compile
javac rollercoastermonitor/*.java rollercoastermonitor/rollercoaster/*.java
# Generate jar
jar cfm ../RollerCoasterMonitor.jar ../manifest.mf rollercoastermonitor/*.class rollercoastermonitor/rollercoaster/*.class
java -jar RollerCoasterMonitor.jar
Open the project folder:
cd RollerCoasterLock
Run the following commands:
./make.sh
make.sh
content
#!/bin/bash
cd src
# Compile
javac rollercoasterlock/*.java rollercoasterlock/rollercoaster/*.java
# Generate jar
jar cfm ../RollerCoasterLock.jar ../manifest.mf rollercoasterlock/*.class rollercoasterlock/rollercoaster/*.class
java -jar RollerCoasterLock.jar
Breno Viana | Patrícia Cruz |