![]() |
.. (לתיקייה המכילה) | |
Hints for better solution of the HW. | |
1. Don't rush to start programming before considering on paper every subtlety of the solution 2. Do NOT confuse between thread and object. Object is identified by its type, where each type has a particular data structure and a set of functions(methods). Different objects of the same type __do__not__ share non-static data. Thread is only a concept of executing some code. In particular, a thread can run a certain function which changes the state of a given object. If this function is run by multiple threads, the access to the shared data must be (usually) synchronized. In Java there is a confusion between the "thread" as a concept, and Thread as an object which allows to implement this concept. |
Is it OK to assume that one cell needs all its neighbors to reach the same generation in order to proceed. | |
Yes. It is OK to assume that. |
Is it OK to use ... locks? | |
The locks requirement is the lowest priority. Among several solutions that achieve the same level of parallelism, those that use fewer global object should be preferred. And among those with the same number of global object, those that use fewer locks. |
What assumptions can we make about the number of threads? Board size? | |
The board size we will use for testing will be around 100x100 cells, ~32 threads and ~100 generations. However, your solution must work for any values of the parameters. |
Can we use busy-wait, periodic pooling, etc? | |
No. If a thread can't continue computations it must wait until the data it depends on is available. This waiting must not be based on time, but on data availability only. Otherwise, a thread uses resources without performing a useful work. |
My solution would be much simpler if a thread would be allowed to access parts of the board belonging to other threads. | |
Such solution is probably a subject to deadlock or uses busy-wait. |
How many threads can I use? | |
vSplit × hSplit. It is allowed to use a single additional thread if during a computation it only waits for other threads to finish. |
What synchronization is required to access the same array from different threads? | |
According to Java Language Specifications each cell of an array behaves like an independent object. Therefore, if different threads access different array cells they don't need to synchronize. |
Can all threads work on the same shared board? | |
If each thread only accesses its own cells, then technically, yes. However, according to the assignment, the board constitutes a global data structure, and such solution will not receive a maximal grade. It is still fine to use the shared board to read the initial configuration at the beginning and write the final configuration at the end of computations (each thread – its own cells only). |
What field dimensions are expected as a program arguments? | |
Any size which is sufficient to hold an initial configuration described by LIF file. For more information see Life 1.05 format specification. Quick and dirty method: just try to specify size which is large enough. |