For this assignment, there is a functioning serial program that processes a batch of bank transactions. Your job is to convert this into a multithreaded Producer/Consumer model program using a busy-wait approach. The tests for this program have been set up in Canvas via the CODE plugin and the serial version passes all of these tests. Your multithreaded version should also pass the tests, along with compiling and running with no errors or warnings and having no style errors.
Notes:
- You should copy the bankingSystemSerial.cpp program to bankingSystemMT.cpp and make that be the multithreaded version.
- You should use 1 producer thread that will add transactions to the queue and 3 consumer threads that process them.
- Use a maximum queue size of 8
- The producer should process all of the “create” actions before adding work to the queue
- The usleep instructions in the processTransactions function should be considered as being part of the critical section
- You should lock only what is required to avoid race conditions: Locking the entire transactions vector will result in a single-threaded program and you will not be able to get full credit.
- When the program is running correctly, these are the final balances in each of the 15 accounts. You can also get this by running the bankingSystemSerial program
Account : 1000 $-377.13
Account : 1001 $1466.54
Account : 1002 $3873.19
Account : 1003 $7781.32
Account : 1004 $8030.92
Account : 1005 $8445.53
Account : 1006 $-777.38
Account : 1007 $-1424.08
Account : 1008 $674.50
Account : 1009 $29120.34
Account : 1010 $9220.96
Account : 1011 $5668.92
Account : 1012 $13219.30
Account : 1013 $66885.38
Account : 1014 $77624.40