Posts

DEAD LOCK IN Computer

A deadlock is a condition where a  program  cannot access a resource it needs to continue. When an active  application  hits a deadlock, it may "hang" or become unresponsive. Resources, such as saved or cached  data , may be locked when accessed by a specific  process  within a program. Locking the data prevents other processes from overwriting the data prematurely. If a process or  query  needs to access locked data, but the process locking the data won't let it go, a deadlock may occur. For example, the following situation will cause a deadlock between two processes: Process 1 requests resource B from process 2. Resource B is locked while process 2 is running. Process 2 requires resource A from process 1 to finish running. Resource A is locked while process 1 is running. The result is that process 1 and process 2 are waiting for each other to finish. Since neither process can continue until the other one completes, a deadlock is created. Avoiding Deadlocks Developers  c

Sleeping Barber problem in Process Synchronization

Image
Problem :  The analogy is based upon a hypothetical barber shop with one barber. There is a barber shop which has one barber, one barber chair, and n chairs for waiting for customers if there are any to sit on the chair. If there is no customer, then the barber sleeps in his own chair. When a customer arrives, he has to wake up the barber. If there are many customers and the barber is cutting a customer’s hair, then the remaining customers either wait if there are empty chairs in the waiting room or they leave if no chairs are empty. Solution :  The solution to this problem includes three  semaphores .First is for the customer which counts the number of customers present in the waiting room (customer in the barber chair is not included because he is not waiting). Second, the barber 0 or 1 is used to tell whether the barber is idle or is working, And the third mutex is used to provide the mutual exclusion which is required for the process to execute. In the solution, the customer has th