Write a small parallel C program that use Pthreads to implement data parallelism

Write a program that uses multiple threads to implement Conway's Game of Life in parallel.

The game is played on a grid. Details can be found on: https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life

This algorithm will require the threads to read overlapping squares to calculate the new state of grid but it does not require overlapping writes. You will need two arrays to act as the grid for the game. One that is read-from and the other which is written-to. Each location in the grid should be written to by a single thread.

The program is run on the command line and uses parameters to configure the size of the game and the number of threads.

The usage for the program is:

data < #-threads> < grid-size> < #-iterations> -d

< #-threads> is the number of threads the program will create to run the game. This is a required parameter.

< grid-size> is one number that represents both the height and width of the grid. This is a required parameter.

< #-iterations> is how many iterations of the game the program will run before exiting. This is a required parameter.

-d This indicates that the program should print out the grid after each iteration. If the -d is present then the output should be displayed. If the -d is not present then the output is not displayed. Each new grid is calculated but the grid is never drawn on the screen. This is an optional parameter.

The parameters will always appear in this order.

For example:

data 4 10 100

will create 4 threads, a grid size of 10x10, run for 100 iterations, and never display the grid.

Where:

data 2 100 5 -d

will create 2 threads, a grid of 100x100, run for 5 iterations, and will display the grid after each iterations (5 times).

All created threads should be used to calculate a proportional amount of the grid. For example, if there are two threads then each one should calculate half of the grid. If there are three threads then each one should calculate one third of the grid.

Randomly initialize the starting grid with a reasonable number of populated squares. This program will require two arrays for the grid. One which is the current grid and one which is used to store the newly calculated grid.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.