Question
hw2.c file source code #include #include #include /* You will need a structure to store the information to be passed to each thread (see Passing
hw2.c file source code
#include
#include
#include
/* You will need a structure to store the information to be passed to each thread (see "Passing Parameters to Each Thread" in the textbook's project description)*/
/* Declare the thread that checks columns */
void *column_worker(void *param); // the function parameter is for the structure you defined
/* You will also need to declare threads that checks rows and 3x3 subgrids */
/* You are suggested to declare an array of integer values that is visible to each thread. The value in the array (0 or 1) indicates whether the worker thread's number is valid (see "Returning Results to the Parent Thread" in the textbook's project description) */
int main(int argc, char *argv[])
{
/*You need to assign values to the structure variable. Then you can create multiple worker threads by passing the information using the structure variable*/
/*You need to call pthread_join() for each childer thread so that the parent will wait*/
/* Finally, after all children returns, you can check the status array that is visible to everyone and see if it is valid. You then print out the final checking result*/
return 0;
}
/*thread code for child checking all columns*/
void *column_worker(void *params)
{
pthread_exit(0);
}
/* also need to define one thread for checking rows and one thread for checking nine 3x3 subgrids */
Problem Statement: Design and implement a Sudoku Solution Validator using Pthreads library in Linux virtual machine. Steps: Download the incomplete version of hw2.c from iCollege Read through Programming Project 1 of Chapter 4 in the textbook. Instead of using 11 threads in the textbook, complete the C program in order to check Sudoku puzzle using 3 children threads, i.e., a thread for checking all rows, a thread for checking all columns and a thread for checking all the 3 x 3 subgrids. In addition, you program should meet the following requirement: o The 9x9 data grid to be tested are stored in two txt files, grid1 and grid2, which can be downloaded from iCollege The name of the txt file will be the input to the program via command line, i.e., you can access the name of this file through argv[1] in your main() function. Then you can open the file and read the data grid from the file. o The output message stating whether or not the tested grid is a Sudoku puzzle should be finally printed to the screen. Compile the C source file using gcc -pthread -o hw2 hw2.c Use ./hw2 grid1 to test the first data grid and ./hw2 grid2 to test the second data grid Take a screenshot of the program output after you tested the two data grids. Problem Statement: Design and implement a Sudoku Solution Validator using Pthreads library in Linux virtual machine. Steps: Download the incomplete version of hw2.c from iCollege Read through Programming Project 1 of Chapter 4 in the textbook. Instead of using 11 threads in the textbook, complete the C program in order to check Sudoku puzzle using 3 children threads, i.e., a thread for checking all rows, a thread for checking all columns and a thread for checking all the 3 x 3 subgrids. In addition, you program should meet the following requirement: o The 9x9 data grid to be tested are stored in two txt files, grid1 and grid2, which can be downloaded from iCollege The name of the txt file will be the input to the program via command line, i.e., you can access the name of this file through argv[1] in your main() function. Then you can open the file and read the data grid from the file. o The output message stating whether or not the tested grid is a Sudoku puzzle should be finally printed to the screen. Compile the C source file using gcc -pthread -o hw2 hw2.c Use ./hw2 grid1 to test the first data grid and ./hw2 grid2 to test the second data grid Take a screenshot of the program output after you tested the two data grids
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started