Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q.No.1. Use Threading and parallel processing Implement given scenario in C# A voting process is going on. Now you have two candidate who voters can

image text in transcribed
Q.No.1. Use Threading and parallel processing Implement given scenario in C# A voting process is going on. Now you have two candidate who voters can vote for - A and B. Now, the voting process will happen in various localities(cities), and each locality has its voters and a collector who counts the votes. After the collector has collected the votes, he she takes it to a central location (shared among all collectors) to add with whatever is already present in the central box Here the voting process in each locality is like a thread. Each can occur independently without interfering with another. But when the collector comes to add the votes at the central location, he/she needs to synchronize with other collectors who have also come to deposit their count Initially the central bin has count 0 for both A and B. Now collector "X" comes and deposits the following count (A- 10, B- 20). Now collector "Y" and "Z" come in at the same time. "Y" has the count (A- 5, B- 15), and collector "Z" has count (A- 12, B- 8). If both get the value from the bin to add at the same time - then "Y" will add his count to initial (10/20) and even "2" will do the same. Now when they place the new count in the box, it will be erroneous, since atleast one of them would not be having an updated count

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Combinatorial Dynamics And Entropy In Dimension One

Authors: Lluis Alseda, Jaume Llibre, Michal Misiurewicz

1st Edition

9810213441, 9789810213442

More Books

Students also viewed these Mathematics questions