Download
programming project 1 concurrent game of life n.
Skip this Video
Loading SlideShow in 5 Seconds..
Programming Project #1 Concurrent Game of Life PowerPoint Presentation
Download Presentation
Programming Project #1 Concurrent Game of Life

Programming Project #1 Concurrent Game of Life

97 Vues Download Presentation
Télécharger la présentation

Programming Project #1 Concurrent Game of Life

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Programming Project #1Concurrent Game of Life Due Friday, March 20 Project 1

  2. Assignment • Implement a version of Conway’s Game of Life on multiple processes or threads • In this project, all processes or threads are on the same computer • In a future project, they will be distributed across different computers Project 1

  3. Objective • Refresh your memory about concurrency and synchronization • Build a concurrent application that has non-trivial synchronization demands • Lay the groundwork for a non-trivial distributed computation Project 1

  4. Conway’s Game of Life • See http://www.math.com/students/wonders/life/life.html • Introduced by John Conway • Scientific American, April 1970, p. 120 • Played on an “infinite” grid of squares • Each square may be occupied or unoccupied • Rules define how occupancy changes from one generation to next Project 1

  5. Rules of Game of Life • If an occupied square has on 0 or 1 occupied neighbors, it dies of loneliness • If an occupied square has 4 or more occupied neighbors, it dies of overcrowding • If an occupied square has 2 or 3 occupied neighbors, it survives to the next generation • If an unoccupied square has precisely 3 occupied neighbors, it “gives birth,” becoming occupied in next generation Project 1

  6. Rules of Game of Life (continued) • Game terminates if • Grid becomes empty • Pattern of occupancy repeats itself from a previous pattern • A predefined number of generations is reached Project 1

  7. Concurrent Game of Life • Divide grid into fixed-size subgrids • 3232 cells for this project • Each subgrid is computed by a separate process or thread • Called a player • Each player must get information about cells on boundary from neighboring players • Each player must tell neighboring players about its cells on its boundary Project 1

  8. Concurrent Game of Life (continued) • Parent process or thread creates each player • Initial value of subgrid (3232 array) • Array of objects denoting nearest neighbors • Null object  player is on a boundary • Invoking concurrent life life X Y gen filename print pause • X, Y are number of players in x- and y-dimension • gen is number of generations to play • filename is file with initial grid pattern • print, pause for debugging Project 1

  9. Concurrent Game of Life (continued) • File of initial grid positions • Lines of “x” and “o” characters • “x” denotes occupied; “o” denotes unoccupied • No spaces between characters • Center initial value in array of grids • E.g., oxxxxooxo denotes the R-pentomino Project 1

  10. Implementation • Any of C, C++, or Java • Must compile and run on Fossil Lab machines • Synchronization primitives • Java SYNCHRONIZED objects • Semaphores on C++ classes • … messages, other forms of IPC Project 1

  11. Testing • Concurrent programs are harder than sequential ones • At least three non-trivial test patterns • Exercise all sub-grids • Test communication across boundaries • Discuss further testing in write-up Project 1

  12. Submission • Submit via myWPI • Source code & header files • Makefile • Test patterns and output • Write-up • We will • Compile/build using make • Run your test cases • Run our test cases Project 1

  13. Grading • Successful submission — 10% • Clear, cogent write-up — 10% • Success build on Fossil Lab machines with no errors or warnings — 15% • At least three non-trivial test patterns – 15% • Successful run of your test patterns — 25% • Successful run of our test patterns — 25% Project 1

  14. Questions? Project 1