Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Operation Management Expert

A Sudoku puzzle uses a 9 × 9 grid in which each column and row, as well as each of the nine 3 × 3 subgrids, must contain all of the digits 1 • • • 9. Figure 4.19 presents an example of a valid Sudoku puzzle. This project consists of designing a multithreaded application that determines whether the solution to a Sudoku puzzle is valid.

There are several different ways of multithreading this application. One suggested strategy is to create threads that check the following criteria:

  • A thread to check that each column contains the digits 1 through 9
  • A thread to check that each rowcontains the digits 1 through 9
  • Nine threads to check that each of the 3 × 3 subgrids contains the digits 1 through 9

This would result in a total of eleven separate threads for validating a Sudoku puzzle. However, you are welcome to create even more threads for this project. For example, rather than creating one thread that checks all nine 198 Chapter 4 Threads columns, you could create nine separate threads and have each of them check one column.

6 2 4 5 3 9 1 8 7

5 1 9 7 2 8 6 3 4

8 3 7 6 1 4 2 9 5

1 4 3 8 6 5 7 2 9

9 5 8 2 4 7 3 6 1

7 6 2 3 9 1 4 5 8

3 7 1 9 5 6 8 4 2

4 9 6 1 8 2 5 7 3

2 8 5 4 7 3 9 1 6

Figure 4.19 Solution to a 9 × 9 Sudoku puzzle.

Passing Parameters to Each Thread

The parent thread will create the worker threads, passing each worker the location that it must check in the Sudoku grid. This step will require passing several parameters to each thread. The easiest approach is to create a data structure using a struct. For example, a structure to pass the row and column where a thread must begin validating would appear as follows:

/* structure for passing data to threads */

typedef struct

{ int row;

int column;

} parameters;

Both Pthreads and Windows programs will create worker threads using a strategy similar to that shown below:

parameters *data = (parameters *) malloc(sizeof(parameters));

data->row = 1;

data->column = 1;

/* Now create the thread passing it data as a parameter */

The data pointer will be passed to either the pthread create() (Pthreads) function or the CreateThread() (Windows) function, which in turn will pass it as a parameter to the function that is to run as a separate thread.

Returning Results to the Parent Thread

Each worker thread is assigned the task of determining the validity of a particular region of the Sudoku puzzle. Once a worker has performed this Bibliographical Notes 199

7, 12, 19, 3, 18

7, 12, 19, 3, 18, 4, 2, 6, 15, 8

Original List

2, 3, 4, 6, 7, 8, 12, 15, 18, 19

Merge Thread

Sorted List

Sorting

Thread0

Sorting

Thread1

4, 2, 6, 15, 8

Figure 4.20 Multithreaded sorting.

check, it must pass its results back to the parent. One good way to handle this is to create an array of integer values that is visible to each thread. The ith index in this array corresponds to the ith worker thread. If a worker sets its corresponding value to 1, it is indicating that its region of the Sudoku puzzle is valid. A value of 0 would indicate otherwise. When all worker threads have completed, the parent thread checks each entry in the result array to determine if the Sudoku puzzle is valid.

Operation Management, Management Studies

  • Category:- Operation Management
  • Reference No.:- M92250370
  • Price:- $75

Guranteed 36 Hours Delivery, In Price:- $75

Have any Question?


Related Questions in Operation Management

1 what is google current market condition growing level

1. What is Google Current market condition: growing ,level, shrinking 2. Changes in the industry of Google 3. Who is Googles Direct competitors, Indirect competitors

Your classroom participation should include discussion

Your classroom participation should include discussion about the following: Assignment Details Reflect back on the lessons from this session. In Unit 1, you looked at ecosystems and considered what would happen if even o ...

B what are your general thoughts regarding international

b) What are your general thoughts regarding international human resource management issues? c) Are you surprised that expatriates are so expensive? d) Have you ever been an expatriate? What do you think of the reasons wh ...

Imagine that your company is in agribusiness and is

Imagine that your company is in agribusiness and is considering entering China with a self-cleaning feed bunk for cattle. There are no trade barriers to ship this item to China. The item has low value-to-weight. The tech ...

Question due to the recent meat recalls western steakhouse

Question : Due to the recent meat recalls, Western Steakhouse is considering incorporating. Feldman, the owner, wants to protect his personal assets in the event the restaurant is used. Which advantage of incorporating i ...

Company starbuck1 provide details on plans to achieve the

Company StarBuck 1. Provide details on plans to achieve the objective highlighting the possible risks and contingency plans. 2. Provide details on which systems can be implemented to achieve the objectives on time and to ...

1 please think of a position and propose a strategy to best

1. Please think of a position and propose a strategy to best motivate the employee. For example, you could say that a commission pay structure is the best way to motivate a Real Estate Broker and state why. 2. Can you th ...

For this assignment you will take on the role of a vice

For this assignment, you will take on the role of a Vice President of a major organization. The CEO has assigned you the responsibility of educating the leaders within the organization of the importance of maintaining an ...

Audit evidence is often considered to be the

Audit evidence is often considered to be the “proof” auditor’s need in order to render an unqualified opinion. Audit evidence comes from extremely compelling documentation to evidence which is questionable at best. Using ...

Over the past 5 weeks demand for wine at winstons winery

Over the past 5 weeks, demand for wine at Winston's Winery has been 950, 2200, 3300, 1800, and 1550 bottles. Winston has placed weekly orders for glass bottles of 1150, 2400, 3900, 1050, and 900 units. (Recall that the s ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As