This repository has been archived by the owner on Jun 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
discussion.txt
9 lines (5 loc) · 2.3 KB
/
discussion.txt
1
2
3
4
5
6
7
8
9
Nico Eka Dinata (770318)
Using LTSA to check the behaviour of the original model confirms my suspicion for Assignment 1a that there is potential deadlock in the implementation of the system. The specific run that LTSA displays for the deadlock scenario shows the guard relentlessly escorting new groups into the museum as often as they can, not allowing for enough "time" for the groups already in the museum to leave first, eventually resulting in deadlock.
This issue is less apparent in the implementation most likely because of the stochastic nature of parallel programming in Java, where we have no say which thread gets a go upon calling `notifyAll()`. To add to this, the interval for group production and operation times of the guard are also randomised. This leads to potential "lucky runs", where the particular intervals in those runs are such that there will always be some space in the museum for the guard to escort new groups in, hiding the problem. In contrast, there is no explicit notion of durations in LTSA, and so the action ordering that will eventually lead to deadlock can be statically analysed and detected.
In my reflection for assignment 1a I mentioned that the lack of a gap between groups in the museum will lead to deadlock, and so in the modified model I suggested that there is a strict capacity limit enforced in the museum, thereby providing an artificial gap. I reasoned that deadlock is caused by the guard being able to keep escorting new groups into the museum while ignoring the groups inside, causing the groups to eventually compete for a shared resource (the foyer). Therefore, I modified the model so that the guard can only exit to escort new groups if we know for a fact that the foyer can sustain the groups already currently in the museum.
This means that once the capacity limit has been hit, the producer halts until a group currently inside the museum reaches the end, departs from the museum, and the guard is outside to escort the new group in. There is an obvious performance cost from doing this due to the enforced decline in rate of "production" and "consumption". This is arguably worth it, however, as the model is now free of deadlock and the museum can still sustain 2 * ROOM_COUNT number of groups, which is still very close to the maximum number of groups it can fit in all locations.