Description
Purpose of This Project
To provide experience with pthreads in UNIX
Problem Statement:
Read through the programming project –Sudoku Solution Validator from page 197 to 199 in
the textbook, and finish it using pthreads under UNIX. Your project must meet the following
requirements for full credit:
1. The input will be a txt file whose name is given on the command line. This file contains
digits 0-9 in a 9×9 grid. There will be a space between each digit so that you may read in the
data either as integers or as characters. Sample txt files (t1.txt, t2.txt) are provided in
iCollege under Homework2 folder.
2. Create the threads in the following way: one thread for the first three rows, one for the
middle three rows, one for the last three rows, one for the first three columns, one for the
middle three columns, one for the last three columns, one for the top three subgrids, one for
the middle three subgrids, and one for the bottom three subgrids. The total number of threads
is 9 (without including the parent thread).
3. The output of the program should be displayed to the screen with a message stating whether
the Sudoku solution is valid or not. (That is to say whether the 9×9 grid in the txt file is a
valid Sudoku or not).
Design Notes
1. Program in c in the Linux Virtual Machine environment. A skeleton of Sudoku.c can be
downloaded from iCollege.
2. Appropriate error checking of the command line and the file open should be completed.
3. Since the grid is shared between threads, it should be declared in the global data space before
the main program. This also would be the case for any other data being shared between
threads.
2
Assignment:
1. (20 points) Implementation of this project individually. Programs should exhibit a modular
or object-oriented design. Poor design will not earn full credit.
Using gcc -pthread -o Sudoku Sudoku.c to compile, and then an executable file Sudoku
would be generated. Use ./Sudoku to execute the program.
2. (5 points). Provide a high-level description of the program describing the functionality of
the major components (including data structures) of the program and how they interact with
each other to achieve the task.
3. (5 points). Discuss the advantages and disadvantages of using 9 threads to solve this problem
vs. using 3 threads (one to do all the rows, one to do all the columns, one to do all the 3×3
subgrids) vs. using 1 thread to do all the checking.
What to submit (submit through iCollege):
1) Upload file Sudoku.c and a project report (named as “HW2.pdf” or “HW2.doc”) to D2L. The
project report should include 1). The source code of Sudoku.c; 2) a screenshot of the output;
3) Description for question 2 (see above); 4) discussion for question 3 (see above).