关于后端:159355并行系统

33次阅读

共计 1744 个字符,预计需要花费 5 分钟才能阅读完成。

159.355 Concurrent Systems Assignment 3
159.355: Concurrent Systems
Assignment 3
Hans Guesgen
1 Introduction
This is the third assignment for this course. It is worth 25% of the marks for the course. You have one problem
to solve but with two different algorithms: the permission-based Ricart-Agrawala algorithm and the token-passing
Ricart-Agrawala algorithm.
Once you have solutions, submit a zip file containing your solution together with any comments about your code
via Stream. Make sure you include your name and Massey ID number.
Remember that the course is about concurrency. It is your solutions to the concurrency problems that we want
to see, the rest of your code should be as simple as possible. Make sure that you have included sensible comments
so that the marker can understand the code even if it is not running properly.
2 Your Task: Managing Total Social Distancing
A small village in a rural area is experiencing the outbreak of a higly infectious disease. To prevent the spread of the
disease, the 25 families living in the village decide to practise total social distancing. This means that at one time, only
one family is allowed to go shopping in the local mini mart.
Since the families live far apart from each other, they can only communicate by passing messages between each other.
Luckily, one of the families has a computer scientist in the family, and she remembers the Ricart-Agrawala algorithms from
her concurrent systems class. After some brief discussion, the village decides to use these algorithms to determine who
can go shopping next.
Write two simulations for this scenario using the permission-based Ricart-Agrawala algorithm and the tokenpassing
Ricart-Agrawala algorithm. Include print statements in your code that show the workings of the algorithms.
Test your algorithms multiple times to convince yourself that no two families are in the mini mart at the same
time and that no deadlock occurs during the simulation.
You might want to use one of the BlockingQueue classes to implement send() and receive(), but this is not
mandatory.

正文完
 0