[SOLVED] Threading Producer-Consumer C++

I don’t know how to handle this Computer Science question and need guidance.

Struggling to find relevant content or pressed for time? – Don’t worry, we have a team of professionals to help you on
[SOLVED] Threading Producer-Consumer C++
Get a 15% Discount on this Paper
Order Now

1. Consider a Producer-Consumer problem where M Producer threads run simultaneously to fill up a buffer. Then, exactly N Consumer threads will run simultaneously to take all the data out from the buffer. An example of such scenario is a file is striped into M different site. A downloader program starts M producer threads to get these chunks independently. Once M download threads (from a pool of threads) finish producing the items, the N Consumer threads simultaneously scan the data in their own way. Again, note that N out of many possible consumers succeed. Therefore, you cannot assume that only M producers and N consumers are presents. Look at the given program 1PNC.cpp(attached with semaphore.h which is needed to run with this) that works for 1 Producer and N Consumer threads. Be sure to run the program first to see how it behaves. You need to extend the program such that it works for all M producers instead of just 1. Add necessary semaphores to the program. However, you will lose points if you add unnecessary Semaphore. To keep things simple, declare the mutexes as semaphores as well. Then test your program to make sure that it is correct. In your submission directory, include a file called Q5.cpp that contains the correct program.

2. There are 3 sets of threads A, B, C. First 1 instance of A has to run, then 2 instances of B and then 1 instance of C, then the cycle repeats. This emulates a chain of producer-consumer relationship that we learned in class, but between multiple pairs of threads. Write code to run these set of threads.

Assumptions and Instructions: There are 100s of A, B, C threads trying to run. Write only the thread functions with proper wait and signal operation in terms of semaphores. You can use the necessary number of semaphores as long as you declare them in global and initialize them properly with correct values. The actual operations done by A, B and C does not really matter. Submit a separate C++ file called Q6.cpp that includes the solution.


3. Implement a Mutex using the atomic swap(variable, register) instruction in x86. Your mutex can use busy-spin. But assume that you cannot access a register directly other than using this swap instruction. (Note in some lecture, we solved this problem with direct access to the register allowed. For instance, you could simply write $register = 1. But you are not allowed to do that directly. You must do the following: int x = 1; swap (x, $reg) .

Calculate the price
Make an order in advance and get the best price
Pages (550 words)
$0.00
*Price with a welcome 15% discount applied.
Pro tip: If you want to save more money and pay the lowest price, you need to set a more extended deadline.
We know how difficult it is to be a student these days. That's why our prices are one of the most affordable on the market, and there are no hidden fees.

Instead, we offer bonuses, discounts, and free services to make your experience outstanding.
Sign up, place your order, and leave the rest to our professional paper writers in less than 2 minutes.
step 1
Upload assignment instructions
Fill out the order form and provide paper details. You can even attach screenshots or add additional instructions later. If something is not clear or missing, the writer will contact you for clarification.
s
Get personalized services with MyCoursebay
One writer for all your papers
You can select one writer for all your papers. This option enhances the consistency in the quality of your assignments. Select your preferred writer from the list of writers who have handledf your previous assignments
Same paper from different writers
Are you ordering the same assignment for a friend? You can get the same paper from different writers. The goal is to produce 100% unique and original papers
Copy of sources used
Our homework writers will provide you with copies of sources used on your request. Just add the option when plaing your order
What our partners say about us
We appreciate every review and are always looking for ways to grow. See what other students think about our do my paper service.
Nursing
Writer did an excellent job! Thank you.
Customer 452693, January 14th, 2022
Social Work and Human Services
Thank You!
Customer 452587, November 17th, 2021
Nursing
Thank you for a great paper.
Customer 452707, August 6th, 2022
Nursing
Great writer (Proske). I highly recommend
Customer 452531, July 10th, 2021
Other
GREAT
Customer 452813, June 25th, 2022
Nursing
Always a wonderful experience!
Customer 452453, February 23rd, 2023
Nursing
Excellent work!! Thanks again!
Customer 452707, October 14th, 2022
Human Resources Management (HRM)
Could've been more wordage but the paper is accepatable.
Customer 452701, August 23rd, 2023
Criminal Justice
Excellent Work!!!
Customer 452587, March 10th, 2022
Finance
Thank You
Customer 452643, October 24th, 2021
Nursing
Did not receive paper on time.
Customer 452693, November 9th, 2022
Nursing
Great work! I can tell they put great effort in completing this assignment. Thank you.
Customer 452707, October 14th, 2022
OUR GIFT TO YOU
15% OFF your first order
Use a coupon FIRST15 and enjoy expert help with any task at the most affordable price.
Claim my 15% OFF Order in Chat

Good News ! We now help with PROCTORED EXAM. Chat with a support agent for more information

NEW

Thank you for choosing MyCoursebay. Your presence is a motivation to us. All papers are written from scratch. Plagiarism is not tolerated. Order now for a 15% discount

Order Now