Skip to content

Modeled the dining philosopher problem using dynamic mutexes to simulate a bank’s electronic fund transfer mechanism.

Notifications You must be signed in to change notification settings

saibhargav1508/electronic-fund-transfer-simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

electronic-fund-transfer-simulation

You are going to simulate electronic fund transfer (EFT) between bank accounts. We will assume that there is just one bank and several accounts. Your program will take an input file in the form AccountNo1 initialBalance1 AccountNo2 initialBalance2 .. AccountNoN initialBalanceN Transfer accountNoFrom1 accountNoTo1 Amount1 Transfer accountNoFrom1 accountNoTo2 Amount2 … Transfer accountNoFrom1 accountNoTo1 Amount1

which first lists the accounts in the system along with the initial balances and then lists the transfers between accounts. You can assume that all transfers refer to existing accounts and all initial balances and the transfer amounts are nonnegative integers. Your program should take one more parameter to denote the number of worker threads that will run in parallel. Note that the main thread will initialize the accounts, read the input file and assign work (EFTs) to worker threads in a round-robin fashion until all transfers are processed.

It is possible that an account may be overdrawn and gets a negative value while processing. Your program should output on the standard output the amount in each account (in the order specified in the input file) once all transfers are computed.

Usage of your program: $ transfProg inputFile numWorkers So, as an example, assuming the input file is as below 1 1000 2 50 3 400 4 150 Transfer 1 2 200 Transfer 1 4 50 Transfer 2 3 100 your program should produce the following output regardless of the number of worker threads specified: 1 750 2 150 3 500 4 200

You can use mutexes and condition variables and/or semaphores for synchronizing your threads.

About

Modeled the dining philosopher problem using dynamic mutexes to simulate a bank’s electronic fund transfer mechanism.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages