Directions: Use a file city.txt for answering the questions that follow each scheduling algorithm. This file has three columns (comma separated): the first column contains the job Id, the second...


write the code in C++


Directions:<br>Use a file city.txt for answering the questions that follow each scheduling algorithm. This file<br>has three columns (comma separated): the first column contains the job Id, the second column<br>indicates the CPU burst, and column three is the arrival time of the corresponding job.<br>Parallel Programming<br>It is vaccine season! COVID19 vaccines are out, and everyone is rushing to get one.<br>Vaccines are available from six different brands and you have been entrusted to write a<br>program to count the total number of vaccines of each brand administered across 21 cities<br>in the state. Write a multithreaded program (in the file vaccines.cpp) that counts the number<br>of vaccines in 21 different files of numbers. Each line in each of the files will contain either<br>one of the following brand names: v1, v2, v3. Your program must count the number of units<br>for each vaccine brand administered, across all 21 cities, and display the total number of<br>units for each brand. The files are named

Extracted text: Directions: Use a file city.txt for answering the questions that follow each scheduling algorithm. This file has three columns (comma separated): the first column contains the job Id, the second column indicates the CPU burst, and column three is the arrival time of the corresponding job. Parallel Programming It is vaccine season! COVID19 vaccines are out, and everyone is rushing to get one. Vaccines are available from six different brands and you have been entrusted to write a program to count the total number of vaccines of each brand administered across 21 cities in the state. Write a multithreaded program (in the file vaccines.cpp) that counts the number of vaccines in 21 different files of numbers. Each line in each of the files will contain either one of the following brand names: v1, v2, v3. Your program must count the number of units for each vaccine brand administered, across all 21 cities, and display the total number of units for each brand. The files are named "city1.txt", "city2.txt", and " city21.txt". Illustrative Toy Example: If there were only three cities, with the contents of the files as below, your program should print the following. "cityl.txt" "city2.txt" "city3.txt" V1 V2 V1 V2 V3 V2 V3 V1 V2 V1 V3 V2 V2 V3 V3 V3 V3 V2 Total vaccine counts across 3 cities: vl = 4 v2 = 7 v3 = 7| Additional Requirements The program should create 21 threads, each thread should process a different input file. Your program must read the files from a directory o Do not assume the input files are in the current directory. o The directory and file names must be hard-coded into the program. Do NOT prompt the user for this information. • Assuming error-free execution, the only output the program should produce is the cumulative unit count for each vaccine brand. Do NOT print out the individual counts for each file. • The program must use appropriate data structures and loops to avoid redundant code. Code that replicates something 21 times (such as 21 pthread create calls) are not allowed. • Global variables are not permitted! Properly pass parameters into the thread function and use pthread join to return the tally from each file. Global variables are nor allowed • You must use Pthreads to implement the threading. You are not permitted to use the threading features present in C++ 11.
Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here