Question
Problem1 :A Latin square is a square grid of size n x n, with a number written in each cell, such that each number between
Problem1 :A Latin square is a square grid of size n x n, with a number written in each cell, such that each number between 1 and n appears exactly once in each row and once in each column. Latin squares come in many sizes; this assignment consists of designing a multithreaded application that determines whether the solution to a 5 x 5 Latin square is valid. Figure 1 presents an example of a valid Latin square. Figure 1: Valid Latin Square There are several different ways of multithreading this application indicated below you are free to choose the way you prefer. You can add more threads as you are needed. A thread or five threads to check that each column contains uniquely the digits 1 through 5. A thread or five threads to check that each row contains uniquely the digits 1 through 5. The parent thread (main) is responsible to (1) create other threads and (2) print the result which is validity of square. Declare a 5 x 5 square that you would check its validity as a global variable with valid values. Do not forget to support your code with proper comments (i.e., documentation) and use all functions that are essential to complete the application (create, join and exit threads) properly.
Problem 2: Use the same source code of previous problem and create a child process using fork() system call to check its version of the global 5 x 5 square after changing its values to invalid within the child process. Make sure the child process must run and finish its execution before parent process. Show validity of the square in both processes parent (valid) and child (invalid) along with their IDs. Do not forget to support your code with proper comments (i.e., documentation) and use all required system calls (fork, wait, exit) functions that are essential to complete the application properly.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored 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