Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this Write the code in C language please! Problem Statement: Wildfire spread simulation needs to use fuel data that describe the

I need help with this

Write the code in C language please!

image text in transcribed

image text in transcribed

image text in transcribed

Problem Statement: Wildfire spread simulation needs to use fuel data that describe the fuel types (i.e., vegetation types) of an area. There are 13 standard fuel types, represented by 1-13 integer numbers. The fuel data are stored in a grid, where the size of the grid specifies the dimension of the area and an element of the grid defines the fuel type at the corresponding location of the area. See example below for a 1010 fuel data. Given a 200200 fuel data, we are interested in counting the number of occurrences for each fuel type. Due to data errors, we also want to know if there exist any invalid data points (an invalid data point has an integer value that is not between 1 to 13 (inclusive)). Your task is to design a multi-threaded application to count the number of occurrences of each fuel type and if there exist invalid data points. Your program should create 20 new threads: - The first set of 10 worker threads count the number of occurrences for each fuel type (excluding the invalid data points), and prints out the number of occurrences for fuel type 1,2,,13, respectively. Each thread is responsible for counting 20 rows: the 1 st thread counts rows 120, the 2 nd thread counts rows 2140 the 10th thread counts rows 181200. Your task is to design a multi-threaded application to count the number of occurrences of each fuel type and if there exist invalid data points. Your program should create 20 new threads: - The first set of 10 worker threads count the number of occurrences for each fuel type (excluding the invalid data points), and prints out the number of occurrences for fuel type 1,2,,13, respectively. Each thread is responsible for counting 20 rows: the 1 st thread counts rows 120, the 2 nd thread counts rows 2140,, the 10th thread counts rows 181200. - The second set of 10 worker threads check if there exist invalid data points, and print out a message that is either "VALID data" or "INVALID data exist". Each thread is responsible for checking 20 columns: the 1st thread checks columns 120, the 2 nd thread checks columns 2140,, the 10th thread checks columns 181-200. - The parent thread combines results from all the worker threads and prints out the final results. To pass each thread's results back to the parent thread, you can follow a similar design from the Sudoku Solution Validator project described in the textbook (page 197 to 199), which is uploaded to the iCollege. Specifically, a 2D integer array in the size of [10][13] can be used to pass the occurrence number results, where the ith row corresponds to the ith worker thread, and the jth element of a row corresponds to the occurrence number for jth fuel type. Another 1D array can be used to pass the data checking results, in a similar way as described in the Sudoku Solution Validator project. - When creating a thread, the parent should assign the thread a unique ID and pass that as a parameter to the created thread. The IDs of the 20 threads are 1,2,3,,20, respectively. See the Sudoku Solution Validator project description to learn how to create worker thread and pass parameters. Note: you need to extend the parameter struct by adding an extra thread ID parameter. Write your program using pthreads. 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 integers in a 200200 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 (Wildfire_Fuel_test1.txt, Wildfire_Fuel_test2.txt) are provided in iCollege under Homework 2 folder. 2. The output of the program should be displayed to the screen with a printout message from each worker thread, and the overall printout message from the parent thread. The printout message from a worker thread should include its thread ID as part of the message. See screenshot below as an example for the 1010 fuel data described above

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 Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions

Question

What is topology? Explain with examples

Answered: 1 week ago

Question

7. Discuss the implications of a skill-based pay plan for training.

Answered: 1 week ago

Question

4. Make recommendations on steps to take to melt the glass ceiling.

Answered: 1 week ago