Question: Please program in C Task You are to write a program that creates two shared variables of type int. One integer is the BankAccount ,

Please program in C

Please program in C Task You are to write a program thatcreates two shared variables of type int. One integer is the BankAccount

Task You are to write a program that creates two shared variables of type int. One integer is the BankAccount , another is Turn . Both BankAccount and Turn are initialized to 0. Your program must create two processes, one parent process and one child process, and allow the parent to deposit (i.e. add) money to the BankAccount , and also allow the child process to withdraw (i.e. subtract) money from the BankAccount using Tanenbaum's strict alternation (see OS textbook Chap 4). Both the Parent and Child should loop 25 times and follow the rules below each time through the loop Parent (Dear Old Dad) Rules 1. Sleep some random amount of time between 0 - 5 seconds 2. After waking up, copy the value in BankAccount to a local variable account 3. loop while Turn != 0 do no-op; 4. if the account is than the account Then call printf("Poor Student: Not Enough Cash ($8d) ", account ); 7. Copy value from local variable account back to BankAccount 8. Set Turn 0

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!