1 Programming Assignment 2 CSC 4320/6320 - Operating Systems Spring 2023 Due Date: Feb. 20 (Mon.), 11:59pmPurpose of This Project To provide experience with pthreads in UNIXProblem...

Programming assignment, Please solve the whole assignment


1 Programming Assignment 2 CSC 4320/6320 - Operating Systems Spring 2023 Due Date: Feb. 20 (Mon.), 11:59pm Purpose of This Project To provide experience with pthreads in UNIX 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 10 x 10 fuel data. Given a 200 x 200 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 1st thread counts rows 1-20, the 2nd thread counts rows 21-40, …, the 10th thread counts rows 181-200. • 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 1-20, the 2nd thread checks columns 21-40, …, 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: 2 1. The input will be a txt file whose name is given on the command line. This file contains integers in a 200x200 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 Homework2 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 10 x 10 fuel data described above. Design Notes 1. Program in c in the Linux Virtual Machine environment. A skeleton of Wildfire_Fuel_Data_skeleton.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. Assignment: 1. (20 points) Implementation of this project individually. Programs should exhibit a modular design. Using gcc -pthread -o WildireFuelData Wildfire_Fuel_Data.c to compile, and then an executable file WildireFuelData would be generated. Use ./ WildireFuelData to execute the program. Note: when grading we will recompile your program and use new fuel data files to test your program. 2. (5 points). Provide a high-level description (not more than half page) 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 20 threads to solve this problem vs. using 2 threads (one to do all the fuel type counting, one to do all the data checking) vs. the parent thread does all the work (without creating new threads). What to submit (submit through iCollege): Upload file Wildfire_Fuel_Data.c and a project report (named as “HW2.pdf” or “HW2.doc”) to iCollege. The project report should include 1). a screenshot of the output for Wildfire_Fuel_test1.txt; 2) description for question 2 (see above); 3) discussion for question 3 (see above). 11 2 3 11 10 4 11 13 1 10 13 5 1 13 13 5 9 1 11 4 9 1 8 12 5 7 9 1 5 1 9 10 13 3 3 12 1 4 4 11 7 3 1 6 1 5 1 7 8 9 10 2 12 5 13 7 9 9 1 5 6 8 12 9 5 9 8 12 11 13 11 8 4 4 12 6 6 12 1 11 5 10 10 11 10 7 13 10 10 4 6 7 1 4 5 7 10 2 5 10 2 2 12 4 9 8 5 11 3 1 7 2 13 1 11 4 9 1 11 12 6 3 2 8 13 1 10 7 3 8 7 12 9 13 5 6 9 4 5 6 11 13 5 6 3 2 11 1 1 6 5 12 9 2 2 8 10 7 3 3 11 6 4 6 3 9 7 4 4 1 13 6 7 10 6 6 11 6 13 5 10 5 5 2 3 8 3 7 2 4 3 12 1 10 6 2 8 3 11 4 9 7 9 10 5 11 11 1 4 12 5 2 3 1 8 13 7 6 13 5 4 13 4 7 5 12 7 7 8 7 7 13 2 10 6 13 2 9 10 7 9 11 13 11 3 11 9 12 2 2 9 3 3 2 7 6 12 13 2 6 2 13 7 9 2 8 2 2 9 7 7 6 8 10 2 5 1 8 1 10 2 3 11 8 9 2 12 5 2 7 13 4 4 7 12 1 12 9 8 3 5 13 12 1 8 2 6 11 8 5 2 11 5 4 6 9 6 2 7 5 9 1 2 5 3 11 5 4 8 7 2 7 2 2 5 10 6 11 12 6 10 8 7 2 10 7 9 5 9 12 2 12 2 11 8 12 8 7 2 7 13 2 11 10 13 2 13 6 4 6 9 9 4 10 5 12 9 11 11 4 9 8 13 1 4 3 2 9 2 12 2 6 4 12 4 13 1 8 7 3 1 5 9 9 9 9 11 4 1 6 7 3 13 4 3 9 6 5 5 9 1 8 6 3 12 10 7 5 5 9 10 2 11 1 7 12 3 5 7 7 10 5 8 6 9 1 13 12 1 3 7 2 13 4 2 13 9 4 5 8 13 4 9 10 3 5 4 9 9 4 4 9 12 4 4 13 10 10 1 9 6 6 12 10 5 2 12 11 8 13 9 5 3 3 11 10 3 7 13 1 2 3 4 7 3 13 2 2 7 9 5 7 7 9 8 9 2 13 1 3 3 10 8 12 2 10 4 1 12 7 1 6 2 4 4 3 12 11 11 1 12 1 12 9 12 9 9 6 6 1 13 4 11 12 5 7 6 8 2 9 13 7 13 7 3 1 11 13 8 13 9 10 3 7 2 3 2 7 2 13 5 7 8 13 8 5 4 4 5 12 5 9 6 12 5 9 1 10 8 1 2 4 12 7 9 10 6 2 2 12 10 7 10 6 7 6 12 2 1 11 13 2 10 4 7 7 2 7 9 13 9 5 2 2 13 1 13 9 10 3 3 4 7 5 11 9 10 12 8 4 12 2 7 4 11 3 3 13 9 11 9 7 2 5 10 1 6 5 3 10 10 11 13 11 13 9 7 3 10 1 1 4 11 1 8 10 2 7 4 12 9 7 13 10 1 5 7 9 9 8 2 11 10 5 3 9 7 13 1 10 3 10 5 9 11 13 11 2 8 3 3 7 9 13 5 10 5 10 11 4 11 3 7 12 4 7 3 7 9 6 7 11 3 10 6 2 7 12 13 6 3 7 12 11 4 6 5 4 12 3 12 2 9 1 12 12 1 7 7 11 2 4 9 7 1 9 9 12 3 10 3 8 11 12 9 10 5 10 13 13 11 7 9 8 1 8 1 2 10 13 5 6 4 9 3 10 4 8 13 9 9 12 4 1 4 4 5 4 3 3 10 2 10 6 7 12 3 9 5 2 4 5 1 13 5 5 4 7 11 12 5 3 1 6 10 3 5 12 4 4 12 7 5 10 4 11 8 2 5 6 8 3 4 1 2 4 1 4 13 1 7 4 11 4 12 6 11 9 10 5 6 2 7 12 7 11 2 13 2 10 2 5 1 3 11 10 13 2 10 6 5 7 2 12 6 8 5 3 3 6 12 2 5 4 10 5 2 8 2 4 9 1 6 2 5 13 6 8 2 11 11 3 11 7 13 13 7 12 7 1 8 3 2 4 4 6 8 8 6 4 7 1 12 11 5 3 7 2 4 5 8 9 2 1 11 5 12 5 3 5 3 8 9 11 11 3 6 7 9 4 12 8 10 7 6 8 7 9 3 8 13 7 5 7 8 2 7 8 1 13 11 4 4 1 5 8 7 7 9 3 3 1 8 2 8 9 10 12 9 10 5 12 10 5 9 2 12 4 7 4 7 12 9 2 8 6 5 10 2 10 9 12 3 6 6 10 12 1 2 3 1 1 13 1 12 7 2 12 4 10 6 8 3 9 8 3 6 4 11 5 6 9 5 10 13 9 9 6 4 6 3 6 8 3 10 8 11 7 9 9 9 8 11 9 12 3 13 4 5 11 10 2 11 12 9 12 11 7 6 7 6 12 10 10 10 12 9 10 7 9 9 2 5 7 4 13 2 13 12 2 10 3 12 11 13 10 9 6 6 4 7 13 1 2 10 10 9 10 11 6 9 8 5 1 11 9 9 6 2 10 1 10 3 10 3 9 8 6 13 8 1 10 1 7 2 6 7 13 3 9 8 12 4 9 1 4 4 9 13 5 6 12 9 4 7 4 5 2 10 1 13 9 11 13 5 10 9 10 11 4 1 12 8 1 11 6 9 9 1 13 7 5 10 6 11 1 2 8 2 3 9 4 3 11 8 6 5 5 6 12 7 4 13 11 8 4 5 13 11 10 7 1 12 5 13 13 1 1 2 8 3 4 7 11 8 13 10 6 13 12 8 6 6 12 5 1 7 9 1 13 9 12 12 1 5 1 8 13 4 9 8 8 7 6 11 1 13 5 8 10 1 2 3 4 7 4 2 13 8 11 4 10 10 12 4 3 3 5 5 2 10 3 7 9 3 5 12 6 11 7 12 11 7 2 9 9 5 5 12 1 3 11 9 3 8 2 11 11 7 9 3 10 8 3 4 2 2 1 9 11 7 13 5 12 1 8 2 8 7 2 1 13 1 13 9 3 6 11 13 11 10 8 13 13 11 11 11 12 6 2 3 8 2 13 13 1 12 2 8 1
Feb 19, 2023
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here