Fri. Nov 15th, 2019

Samir Daoudi's Technical Blog

SharePoint, Office 365, C#, .Net, SQL Server News, Tips, Ebooks, Events, Webinars ….etc

Author : DAOUDI Samir | Context : MSc Software Engineering – Computer Structure

We assume the processes are P1 and P2 and the resources are R1 and R2. P1 needs R1 and R2 (in this order), P2 needs R2 and R1 (in this order).

A deadlock could occur in the following situation:

  • P1 starts and gets R1 (and locks it).
  • P2 starts and get R2 (and locks it).

    P1 needs R2 and is blocked waiting the resource to be released by P2. P2 needs R1 and is blocked waiting the resource to be released by P1.If this situation occurs, the only thing we can do is to kill one process (J.Glenn, 2010). Techniques and methods to avoid such situations have been developed and two main approaches for handling deadlocks are “Deadlock avoidance” and “Deadlock detection”.

    With the ‘Deadlock avoidance’ approach, it is required that future process resources requests can be known, and based upon this information, “a decision is made dynamically whether the current resources request will, if granted, potentially lead to a deadlock; if so, the request is denied. ”

    ‘Deadlock Prevention’ approach tries to exclude the possibility of such situation. This can be accomplished by preventing one of the four deadlock conditions, for example a process can request all the required resources on one time (M.Kifer, S.A. Smolka, 2007).
    In general, “ The Operating systems aims at avoiding a deadlock rather than preventing one”. (A.S. Godbole, 2005).

    So for preventing our processes P1 and P2 to get in deadlock session, one of them could reserve both resources R1 and R2 at the beginning.

    References:

  • J.Glenn Brookshear, “Computer Science 10th Edition”, 2010.
  • Michael Kifer, Scott A. Smolka , “Introduction to operating system design and implementation: the OSP 2 approach“, 2007.
  • Achyut S Godbole, “Operating systems”, 2005.

Leave a comment

Show Buttons
Hide Buttons
%d bloggers like this: