Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The hw2.c file is... What I needs is... Problem Statement: Design and implement a Sudoku Solution Validator using Pthreads library in Linux virtual machine. Steps:

image text in transcribed

The hw2.c file is...

image text in transcribed

What I needs is...

image text in transcribed

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. . Follow the suggestion in the textbook to complete the C program in order to check Sudoku puzzle using 11 children threads. 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 files will be the input to the program via command line, ie., 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. 1 2 3 #include #include #include s*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)* 7 Declare the thread that checks columns* 8 void column_worker(void param) the function parameter is for the structure you defined 9 You will also need to declare threads that checks rows and 3x3 subgrids 10 11 You are suggested to declare an array of integer values that is visible to each thread. The value in the array (e or 1) indicates whether the worker thread's number is valid 12 see "Returning Results to the Parent Thread" in the textbook's project description) 13 14 15 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*/ 17 18 19 20 /'You need to call pthread_join() for each childer thread so that the parent will wait* 21 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 23 24 25 return e 26 27 28 29 *thread code for child checking all columns 30 void *column_worker(void *params) 31 32 pthread_exit (e); 34 35 36 also need to define threads for checking rows and 3x3 subgrids The C source file hw2.c A report in PDF that includes The screenshot of your program output o A high-level description of major components/functionality (including data structures) used in the program and how they interact with each other to achieve the assignment task. A copy of your C source code from hw2.c file o A discussion comparing the advantages and disadvantages when "Using 11 children threads as in your program . Using 3 threads (one for all rows, one for all columns, one for all 3x3 subgrids) Using only one single child thread to do all checking

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions

Question

3. Identify challenges to good listening and their remedies

Answered: 1 week ago

Question

4. Identify ethical factors in the listening process

Answered: 1 week ago