add text.. authored by René Nilsson's avatar René Nilsson
......@@ -44,6 +44,17 @@ The plan is to follow the instructions for Lesson 7 [1].
## SharedCar and Arbiter
### SharedCar
The *SharedCar* class contains a car command and a boolean indicating whether a command is present or not. The car command contains information about both motor powers and directions(Currently it does not support *float* commands).
The *SharedCar* have a serious flaw. If a behavior sends a command to the *SharedCar*, at the same time as the *Arbiter* read from it, a race condition is raised. To avoid this possible error, all functions in the *SharedCar* should be synchronous.
### Arbiter
The *Arbiter* contains a list of *SharedCars* and constantly check, in a prioritized manor, if the *SharedCars* have available commands.
This will ensure that the behaviors with the highest priority will drive the actual car, if it have any commands for it.
### Comparison to Fred Martin
The *Prioritizing Algorithm* by Fred Martin is written in C and implements the same functionality as the *SharedCar* and *Arbiter* classes. The differences is that in Fred Martins code, forward, backward and stop is controlled by the motor power. That is forward is a positive value, backward is a negative value and stop is zero. In the *SharedCar* the direction must be set explicitly.
In Fred Martins code, arrays are preallocated to be able to contain ten processes, whereas in the *Arbiter* an arbitrary number of processes can be added runtime.
......
......