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:

program language: Spider Consider the problem of transferring some amount from one

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!