Question: In this assignment, you are asked to implement a multi - threaded word search puzzle solver that uses low - level I / O to
In this assignment, you are asked to implement a multithreaded word search puzzle
solver that uses lowlevel IO to read the file containing the puzzle table.
The puzzle table is assumed to be a squareshape D array of characters with n rows and
columns where n and n is received from the commandline.
To solve the puzzle, your program needs to use a hash set keeping the same dictionary
that was used for the previous assignment. The program scans the whole table to find
meaningful English words whose letters appear in adjacent cells located in:
the same row of table from left to right or from right to left,
the same column of table from top to bottom or from bottom to top,
a line of slope from left to right or from right to left,
a line of slope from left to right or from right to left.
The technique used to solve the puzzle using a multithreaded program is Divide &
Conquer: The given squareshape D array is divided into multiple squareshape D
subarrays. The solution of the puzzle is the aggregation of solutions to all the subpuzzles generated in step
The program uses the producerconsumer model.
producer: reads a squareshape subarray of the given D array from the input file
using lowlevel IO system calls open read, lseek There is no need to have multiple
producers as there is a single input file. Therefore, you may use the main thread itself
to play the role of producer.
consumer: searches for meaningful words in the hash table containing the dictionary.
The main thread may spawn multiple consumer threads to enhance the search speed
using concurrency.
Also, assume that the program allocates MB million bytes memory for the buffer
used by producer and consumers to exchange data. Number of equalsize cells in this buffer
is passed by the commandline argument and can be one of the following values:
and
CommandLine Arguments and Options
Your program may be executed with the following commandline arguments options:
input yyy: where yyy is the name and possibly path and extension of file containing
the squareshaped puzzle. To make your own random puzzle, you may use the program
stored in random puzzle generator.c available on Canvas.
nbuffer zz: where zz is the number of equalsize buffer cells that can be or
If the number of buffers zz does not satisfy the mentioned condition, your program
must print an error and exits immediately. Your program must spawn a consumer
thread for each of the nonempty buffer cells so that the puzzlesolving process happens
concurrently. Therefore, the number of buffers also specifies the maximum number of
concurrent consumers who solve the puzzle.
dict ddd: where ddd is the name and possibly path and extension of file containing
the dictionary. The file dict.txt which contains the list of all meaningful English words
is available on Canvas.
size ss: where ss is the number of rowscolumns of the squareshape puzzle table.
It can be any number from to inclusive If the size ss does not satisfy the
mentioned condition, your program must print an error and exits immediately.
len a:b: where a and b are positive integers specifying minimum and maximum
length of words that solve the puzzle. Please note that a b If a and b
do not satisfy the mentioned condition, your program must print an error and exits
immediately.
s: this flag means that your program must print the list of words that solve the puzzle
in alphabetical order. Implementation of this option requires the usage of mutex locks
to synchronize access to a collection object kept externally. You can use a binary search
tree to collect words so that you can easily print them all at the end.
Submissions
You need to submit a zip file compressing the C source files related to the assignment c
files header files h files and the makefile. Please use solve to name the executable
of your program in the makefile.
Below is randompuzzlegenerator.c
#include
#include
#include
#include
#define errorm c dofprintfstderrs
m;exitc;while
void mainint argc, char argv
ifargc
errorFatal error. Usage: puzzle rowno colno;
long n atoiargv;
long m atoiargv;
long k n m;
srandtimeNULL;
long l ;
whilel k
putchararand;
iflm && l k
putchar
;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
