Question: Implement your solution to question 2 in C++ or any other language that supports semaphores. Show the source code and the sample output with 2
Implement your solution to question 2 in C++ or any other language that supports semaphores. Show the source code and the sample output with 2 deposits and 2 withdrawals. Implement using threads, where two threads run concurrently each executing a deposit, a withdrawal, and a balance operation. Choose random amounts for the deposit and withdrawals for each process. The output should clearly show whether the output is from thread 1 or thread 2 and what the operation is. Here is a URL for a semaphore for C++ https://en.cppreference.com/w/cpp/thread/counting_semaphore
Please use C++ or C
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
