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".

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter13: File Input And Output
Section: Chapter Questions
Problem 9PE
icon
Related questions
Question
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.
Transcribed Image 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.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Constants and Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,