Question
program language: Spider Consider the problem of transferring some amount from one bank account to another using threads. This needs to create 100 threads to
program language: Spider
Consider the problem of transferring some amount from one bank account to another using threads. This needs to create 100 threads to transfer 1 unit from account1 to account2. The following solution (program) has been proposed:
Initially, account1 has 100 units and account2 has 0 units. After 100 transfers of 1 unit, account1 should have 0 units and the account2 should have 100 units. However, this solution will result in a race condition.
a) Examine the performance of the above program by explaining its race condition state.
b) Develop a parallel solution to overcome the race condition appeared in the above program using semaphores technique.
Output
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started