Question: Course: Operating System Course Code: CS-583 Task#1: Thread Synchronization Suppose that a person runs three branches of School A. Files branchA.txt, branchB.txt and branchC.txt contains
Course: Operating System
Course Code: CS-583
Task#1:
Thread Synchronization Suppose that a person runs three branches of School A. Files branchA.txt, branchB.txt and branchC.txt contains data of students of each branch. You are required to make threads in JAVA for reading data from these files simultaneously and write them to a students.txt while writing data into file thread must be synchronized because a shared file is being accessed by all three threads at the same time.
Task#2:
Deadlock Multi-Threading A bank account is accessed from various users it may be accessed using ATM, Mobile app other banks with in country and outside country. Assume that bank account is accessed by unlimited users. When any user wants access to bank account, its request for lock is send if resource (bank account) is free lock is guaranteed, otherwise user is set to waiting mode. Suppose that a person A went to Bank A for transferring amount from account1 to accoutn2 and at the same time person B went to Bank B for transferring amount from account 2 to account 1. Transaction at Bank A requested for to lock on account1, resource (account 1) was free and lock was acquired by Transaction at Bank A. At the same time Transaction at Bank B requested for lock on account 2. Account 2 was free and was locked by Transaction at Bank B. Transaction at Bank A requests to lock account 2 that was already locked by Transaction at Bank B. Transaction at Bank A goes into waiting state similarly Transaction at Bank B request to lock account 1 that was already locked by Transaction at Bank A so Transaction at Bank B goes into waiting state. Both the Transactions are in circular wait. You are supposed to write a C# application to handle above situation so that deadlock does not occur.
Answer both the tasks correctly
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
