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 tota

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
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.

“city1.txt” “city2.txt” “city3.txt”

V1

V2

V3

V1

V2

V3

 

V2

V3

V1

V3

V3

V3

V1

V2

V2

V2

V3

V2

 

                   

Total vaccine counts across 3 cities:

v1 = 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.
  • No makefile is required for this assignment.

 

Error Checking

  • If a pthread function returns an error, abort the program with an error message.

 

Assumptions

  • Each input file will contain at least one line. Beyond this, you cannot make any assumptions on how long the input file is.
  • You may assume that each line only contains one of the three names noted in the description

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 9 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY