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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education