Starting from:

$25

CPEN333 -  Software Systems Engineering - Lab 6 - Solved

This lab uses counting semaphores to demonstrate more complex synchronisation problems. It is an example of a question that came up in the 2018 final exam paper, although students were only asked to describe how the semaphores should be used, not write the program. For this lab you will write the whole program as a simulation.

 

Note this lab requires you to make a short video with your cell phone to demonstrate Lab 6, complete with a voice over commentary. The video quality does not need to be super high and we are not grading its quality but it has to be viewable and clear for the TA to understand what is happening. The video file should not be super large either. The video can either be submitted to Canvas along with the source code file, or uploaded to a web site and a link to it submitted to Canvas.

 

Problem

Past Exam Question: Suppose you are writing a program to simulate a ‘pit-stop’ in a motor race. A ‘pit stop’ involves a driver bringing their car into the ‘pit’ to carry out routine maintenance on the car such as a change of tires and refuelling.  18 technicians are involved in each pit stop:- 

·         2 “Jacking” technicians – the 1st to raise (and lower) the front of the car and a 2nd to do the same at the rear. This will allow the 4 wheels to be removed/refitted at each end of the car. 

·         1 “Refuelling” technician to refuel the car. 

·         To minimize time in the pit, at each of the 4 wheels of the car there are 3 Wheel technicians (i.e. 12 in total) whose duties are described below:-

Ø  1 “Wheel Nut” technician responsible for taking off (and eventually putting back) the single wheel “nut” that holds a wheel onto the car. 

Ø  1 “Wheel Removal” technician who will remove the current wheel (complete with old tire) when the nut has been removed.

Ø  1 “Wheel Refitting” technician who holds and puts on the new wheel (with new tire)

·         In addition there is 

1.       One “Visor” technician who quickly wipes the visor of the drivers helmet (to remove dirt and dead fly’s etc.) 

2.       One “debris” technician who quickly checks the air intakes of the car and removes any obvious debris (e.g. leaves) that might lead to overheating of the engine during the race



·         A final 18th ‘Supervisor” technician who manages the pit stop by coordinating with the driver and the other 16 technicians.

 

Operation

During a race, a driver can decide to make a pit stop if for example, they are low on fuel or their tires need changing. Assume all drivers share the same pit lane and technicians.

Each time they complete a lap of the circuit, a driver can check a red/green pit entry light positioned at the entrance of the pit lane. 

If that light is green and the driver would like to take advantage of a pit stop, the driver can pull their car off the race track and enter the pit lane. Otherwise if the light is red, the driver must continue racing as it means that either the pit lane is occupied or the technicians are not ready for a pit stop. 

The pit entry light is controlled by the Supervisor Technician above. The operation of the pit stop is described below

·         The Supervisor technician will turn the pit entry light to green ONLY when all 17 pit technicians indicate that they are ready to carry out a pit-stop and the pit-lane is empty.

·         Once a driver enters the pit, the supervisor turns the pit entry light to red to prevent other cars entering the pit at the same time.

·         When the driver has brought the car to a complete stop, the refuelling/visor and debris technicians can task. At the same time the 2 jacking technicians can raise the car.

·         Once the front of the car has been raised 6 technicians replace the 2 wheels at the front

·         Once the rear of the car has been raised, 6 other technicians replace the 2 wheels at the rear.

Note: Wheel technicians at each corner have to coordinate with their 2 other team members to ensure that the following sequence of events is observed 1) the wheel nut is removed 2) the old wheel is removed, 3) the new wheel is replaced and 4) the wheel nut is put back on.

·         When both wheel nut technicians at the front indicate that both front wheels have been replaced, the front jacking technician can lower the front of the car.

·         When both wheel nut technicians at the rear indicate that both rear wheels have been replaced, the rear jacking technician can lower the rear of the car.

·         The supervisor technician waits until the car has been refuelled, the driver visor has been cleaned and that any debris has been removed from the car and that both front and back of the car have been lowered before turning on a “pit exit light” to indicate that the driver may leave the pit.

·         The driver will not attempt to leave the pit until the “pit exit light” is turned on

·         Once the car has left the pit the supervisor technician turns off the “pit exit light”

·         All technicians then prepare for the next pit stop and indicate their readiness to the supervisor technician who will then open the pit lane for the next driver.

·         This process continues for the duration of the race with drivers deciding when to perform their pit stop.

Here’s a video showing a real Formula 1 pit stop for Ferrari (skip to 32 seconds in). It shows the jack technicians front and rear as well as the 3 technicians at each corner of the wheel. You can hear the air-guns buzzing as the wheel nut come off/on https://www.youtube.com/watch?v=aHSUp7msCIE. The only thing they don’t do in this video is refuel the car and clean the visor/debris, but we are adding that to our simulation.

Assume the driver, and the technicians are all represented by active objects. Think about how would you design their code using Semaphores as your ONLY means of synchronization, so that we are able to simulate this pit-stop and fulfil the above requirements?  

Your task for this lab is to write a simulation of a motor race involving at least 10 cars and 20 laps. You can program parameters into each driver during “construction” e.g. the lap numbers they choose to come into the pits (assume they will come into the pits at least twice during a race, e.g. laps 8 and 15 – you choose – mix it up a little so it is different for each driver).

You can also program suitable time delays into various technician operations, such as the time it takes to jack and lower the car, replace wheels, time from the driver entering the pit lane to coming to a stop, time to leave the pit lane etc. It might also be interesting to program some random time variance into those times to simulate the fact that sometime things don’t always go as planned, e.g. sometimes a technician has trouble getting the wheel nut off with an air gun. 

 

You can also program the driver lap times into the simulation to reflect the fact that drivers go at different speeds (not that different, they are still competitive with each other). Other things you might like to simulate include time for a technician to go and get tires from stores after each pit stop, refuelling time (typically takes ~5 secs), wheel replacement might take 2-5 seconds (maybe different for each corner).

 

To make the simulation interesting, it should display what is happening during the race, e.g. Lap number for each car, technician status and action in real time, pit lane status, driver status, what car is in the pits etc. This can be done in text by allocating a portion of the screen to each tech and letting them move the cursor position around and write something in real time to their portion of the screen. You will of course need a mutex to protect the screen as per lab 5. The exact display and how you present it is up to you. Maybe you can use colour and reverse video etc to highlight things. Expect better displays and simulations to attract better grades

 


More products