$30
CSC 33200 (L) - Operating Systems –
Lab 5: Process Synchronization
The given bank.c program has 3 processes namely, the dad process and two son
processes where a son withdrawing money from the bank and the dad depositing money
in the bank, at randomly selected time intervals. The program in the given form has
synchronization errors and logical errors. The program itself compiles correctly.
In the bank there are also 2 atm machines. Meaning at a time there are only 2
processes that can request to view the balance or can withdraw or deposit money.
Task1:
Identify the critical section and synchronize the program. You would need to use P(sem)
and V(sem) operations at the right places to solve the synchronization problem. You will
also need to find the logical flaw if there is any and try to solve it. To use P(sem) and
V(sem) include the provided “sem.h” file. Your solution should solve the following
problems:
• Prevent race conditions
• Prevent a son from withdrawing money when there is no balance.
• Prevent undefined outputs like negative balance
• Prevent a process from continuously requesting access to the shared
memory. Prevent unnecessary cpu cycle.
• The problem should be solved with as few semaphore variables as
possible.
Task2:
Submit a report showing the critical section of the code ( and logical errors) and
explain your solution in detail.
Submission Instructions
• All the programs MUST be clearly indented and internally documented
• Do not include executables in the zip file.
• Make sure your programs compile and run without any errors
• Save all your programs with meaningful names and zip into a single
folder as: task5_[your last name here].zip (e.g., task5_Xyz.zip)
• Email your code with the subject line, "Task5-CSC33200(L)–Class#
12345-lastname" (e.g., Task5 - CSC33200(L)-Class #63858-Xyz)
• Email: sdebnath@ccny.cuny.edu
******
Office Hours: Tuesday 11:00am – 12:00 pm
Join Zoom Meeting
https://ccny.zoom.us/j/84269573672?pwd=SE9uNjM4V2FJTGZDU3lQdU5rdE5Odz9
Meeting ID: 842 6957 3672
Passcode: 842199
One tap mobile
+16465588656,,84269573672# US (New York)
+13017158592,,84269573672# US (Washington DC)
Dial by your location
+1 646 558 8656 US (New York)
+1 301 715 8592 US (Washington DC)
+1 312 626 6799 US (Chicago)
+1 346 248 7799 US (Houston)
+1 669 900 6833 US (San Jose)
+1 253 215 8782 US (Tacoma)
Meeting ID: 842 6957 3672
Find your local number: https://ccny.zoom.us/u/kdFSnm1j0
IMPORTANT NOTE: Please connect with zoom with a valid CCNY or CITYMAIL email
id. Please sign up with the CITYMAIL or CCNY email address at :
https://www.ccny.cuny.edu/it/zoom