SlideShare ist ein Scribd-Unternehmen logo
1 von 5
Basic TO algorithm :
Case 1 : If Tj requests read operation on data item x,
       If TS(Tj) < WTS(x) then
               Reject the operation and abort Tj;
               Restart Tj with new timestamp;
       Else
               Execute read operation;
               Set RTS(x) = max {RTS(x), TS(Tj)};
Case 2 : If Tj requests write operation on data item x,
       If TS(Tj) < RTS(x) and TS(Tj) < WTS(x) then
               Reject the operation and abort Tj;
               Restart Tj with new timestamp;
       Else
               Execute write operation;
               Set WTS(x) = TS(Tj);

RTS(x) is read timestamp of x – sometimes called RTM(x)
WTS(x) is write timestamp of x – sometimes called WTM(x)

PROBLEM :
Consider a data item X. Let RTM(X) = 25 and WTM(X) = 20. Let the pair (<Ri(X),TS>, Wi(X), TS)
denote a read / write request of transaction Ti on the item X with timestamp TS. Indicate the
behavior of the basic timestamp method with the following sequence of requests.
<R1(X), 19>, <R2(X), 22>, <W3(X), 21>,
<W4(X), 23>, <R5(X), 28>, <W6(X), 27>
ANSWER :
a) <R1(X), 19> - it means that T1 transaction wants to perform read(X) operation and TS(T1)=19.
       From basic TO algorithm,
   As, TS(T1) < WTM(X), reject the operation and abort T1 and restart T1 with new timestamp.

b) <R2(X), 22> - it means that T2 transaction wants to perform read(X) operation and TS(T1)=22.
       From basic TO algorithm,
   As, TS(T2) > WTM(X), perform the operation and set RTM(X),
       RTM(X) = max{RTM(X), TS(T2)}
                = max{25, 22}
                = 25

c) <W3(X), 21> - it means that T3 transaction wants to perform write(X) operation and TS(T1)=21.
        From basic TO algorithm,
    As, TS(T3) < RTM(X) but TS(T3) > WTM(X), perform the operation and set WTM(X),
        WTM(X) = TS(T3) = 21
d) <W4(X), 23> - it means that T4 transaction wants to perform write(X) operation and TS(T1)=23.
        From basic TO algorithm,
    As, TS(T4) < RTM(X) but TS(T4) > WTM(X) (i.e. new WTM value 21), perform the operation
and set WTM(X),
        WTM(X) = TS(T4) = 23

e) <R5(X), 28> - it means that T5 transaction wants to perform read(X) operation and TS(T1)=28.
       From basic TO algorithm,
   As, TS(T5) > WTM(X) (i.e. new WTM value 23), perform the operation and set RTM(X),
       RTM(X) = max{RTM(X), TS(T5)}
                 = max{25, 28}
                 = 28

f) <W6(X), 27> - it means that T6 transaction wants to perform write(X) operation and TS(T1)=27.
        From basic TO algorithm,
    As, TS(T6) < RTM(X)(i.e. new RTM value 28) but TS(T6) > WTM(X) (i.e. new WTM value 23),
perform the operation and set WTM(X),
        WTM(X) = TS(T6) = 27

Distributed Deadlock Detection Algorithm :
   This algorithm works by successive iterations.
   At each iteration each site receives potential deadlock information which was produced by other
   sites during the previous iteration, then it performs deadlock detection and finally it sends
   potential deadlock information to other sites. Therefore, the communication between local
   deadlock detectors occurs between different iterations of the algorithm.
   It may happen that two sites may send the same global deadlock information to each other. This
   would cause that the same deadlock be discovered twice, which is not necessary. To avoid this
   unnecessary transmission, the algorithm uses the following rule :
   The potential deadlock cycle is transmitted only if the transaction identifier of the
   transaction for which EX waits is greater than the transaction identifier of the transaction
   waiting for EX.
   For example, consider following DWFG,

          Site 1    T1       T2




          Site 2    T1       T2
The local deadlock detectors at each site builds the LWFG as follows,

          At site 1   T1            T2                  EX




         At site 2    T1             T2                  EX




 NOTE : In LWFG, all output and input ports are collected into a single node, called external (EX).

  From above LWFFGs , we obtain that only site 2 transmits the potential deadlock cycle because at
site 2 EX is waiting for T2 and T1 is waiting for EX in the potential cycle (from the above rule).

   At each iteration of the algorithm, the local deadlock detectors at each site perform the following
   actions :
   1) Build the LWFG using local information. The LWFG includes the node EX.
   2) For each message which has been received, perform the following modifications of the
       LWFG :
       a) For each transaction in the message, add it to the LWFG if it does not already exist.
       b) For each transaction in the message, starting with EX, create an edge to the next
           transaction in the message.
       This step has included all potential deadlock information received from other sites into the
       local LWFG.
   3) Find cycles not involving EX in the LWFG. Each such cycle indicated the existence of a
       deadlock. Deadlock resolution is invoked to eliminate these deadlocks.
   4) Find cycles involving EX. These cycles are potential deadlock cycles. The rule described
       above is used to determine whether a potential deadlock cycle must be transmitted to a
       different site. If the transmission is required, the message is prepared and transmitted. The
       transmission of potential deadlock cycles terminates the current iteration of the deadlock
       detection process.
PROBLEM 1:
Consider the following DWFT given below,


                     Site1      T2             T2       T3        Site2




                                T1             T1       T3        Site3


Detect the deadlock using the distributed deadlock diagram.
ANSWER :
Iteration 1:
First draw LWFG for each site.
                       T1            T2                 EX
      At site 1




                      T2             T3                EX
       At site 2



                           EX             T1                 T3
       At site 3


At site3, there is no potential deadlock cycle exists. But site1 and site2 LWFG contain potential
deadlock cycle.
The rule for transmitting the potential deadlock cycle is as follows :
    The potential deadlock cycle is transmitted only if the transaction identifier of the
    transaction for which EX waits is greater than the transaction identifier of the transaction
    waiting for EX.
From the above rule, none of the site sends the information to the remaining sites. Therefore the
iteration terminates without sending any information.
PROBLEM 2 :
   Consider following DWFG,

                              Site 1    T1        T2




                              Site 2    T1        T2

   Detect the deadlock using the distributed deadlock diagram.
   ANSWER :
   Iteration 1 :
   First draw LWFG for each site.

           T1            T2                  EX                T1         T2                 EX
   Site1                                               Site2


   Both site1 and site2 LWFGs contain potential deadlock cycle.
   The rule for transmitting the potential deadlock cycle is as follows :
       The potential deadlock cycle is transmitted only if the transaction identifier of the
       transaction for which EX waits is greater than the transaction identifier of the transaction
       waiting for EX.
   From the above rule, only site 2 transmits the potential deadlock cycle because at site 2 EX is waiting
   for T2 and T1 is waiting for EX in the potential cycle. Cycle involves EX. Therefore site1 receives
   message from site1 as (EX, T2, T1).
   Iteration 2 :
   At site 1, after receiving the message from site2, the local deadlock detector modifies the LWFG as
   follows :
       a) No need to add any transaction the LWFG as each transaction in the message is already exists
           in LWFG.
       b) For each transaction in the message i.e. T1 and T2, starting with EX, create an edge to the
           next transaction in the message.


                              T1             T2                     EX



c) There is a cycle not involving EX in the above LWFG (i.e. T1-T2-T1). Thus there is a deadlock
   detected at site1. Deadlock resolution is invoked at site1 by selecting a victim and an abort message
   for that victim is send to all sites where the victim was active (i.e. to site2).
                                           ******************

Weitere ähnliche Inhalte

Kürzlich hochgeladen

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 

Kürzlich hochgeladen (20)

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 

Empfohlen

Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Empfohlen (20)

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 

Problem solutions

  • 1. Basic TO algorithm : Case 1 : If Tj requests read operation on data item x, If TS(Tj) < WTS(x) then Reject the operation and abort Tj; Restart Tj with new timestamp; Else Execute read operation; Set RTS(x) = max {RTS(x), TS(Tj)}; Case 2 : If Tj requests write operation on data item x, If TS(Tj) < RTS(x) and TS(Tj) < WTS(x) then Reject the operation and abort Tj; Restart Tj with new timestamp; Else Execute write operation; Set WTS(x) = TS(Tj); RTS(x) is read timestamp of x – sometimes called RTM(x) WTS(x) is write timestamp of x – sometimes called WTM(x) PROBLEM : Consider a data item X. Let RTM(X) = 25 and WTM(X) = 20. Let the pair (<Ri(X),TS>, Wi(X), TS) denote a read / write request of transaction Ti on the item X with timestamp TS. Indicate the behavior of the basic timestamp method with the following sequence of requests. <R1(X), 19>, <R2(X), 22>, <W3(X), 21>, <W4(X), 23>, <R5(X), 28>, <W6(X), 27> ANSWER : a) <R1(X), 19> - it means that T1 transaction wants to perform read(X) operation and TS(T1)=19. From basic TO algorithm, As, TS(T1) < WTM(X), reject the operation and abort T1 and restart T1 with new timestamp. b) <R2(X), 22> - it means that T2 transaction wants to perform read(X) operation and TS(T1)=22. From basic TO algorithm, As, TS(T2) > WTM(X), perform the operation and set RTM(X), RTM(X) = max{RTM(X), TS(T2)} = max{25, 22} = 25 c) <W3(X), 21> - it means that T3 transaction wants to perform write(X) operation and TS(T1)=21. From basic TO algorithm, As, TS(T3) < RTM(X) but TS(T3) > WTM(X), perform the operation and set WTM(X), WTM(X) = TS(T3) = 21
  • 2. d) <W4(X), 23> - it means that T4 transaction wants to perform write(X) operation and TS(T1)=23. From basic TO algorithm, As, TS(T4) < RTM(X) but TS(T4) > WTM(X) (i.e. new WTM value 21), perform the operation and set WTM(X), WTM(X) = TS(T4) = 23 e) <R5(X), 28> - it means that T5 transaction wants to perform read(X) operation and TS(T1)=28. From basic TO algorithm, As, TS(T5) > WTM(X) (i.e. new WTM value 23), perform the operation and set RTM(X), RTM(X) = max{RTM(X), TS(T5)} = max{25, 28} = 28 f) <W6(X), 27> - it means that T6 transaction wants to perform write(X) operation and TS(T1)=27. From basic TO algorithm, As, TS(T6) < RTM(X)(i.e. new RTM value 28) but TS(T6) > WTM(X) (i.e. new WTM value 23), perform the operation and set WTM(X), WTM(X) = TS(T6) = 27 Distributed Deadlock Detection Algorithm : This algorithm works by successive iterations. At each iteration each site receives potential deadlock information which was produced by other sites during the previous iteration, then it performs deadlock detection and finally it sends potential deadlock information to other sites. Therefore, the communication between local deadlock detectors occurs between different iterations of the algorithm. It may happen that two sites may send the same global deadlock information to each other. This would cause that the same deadlock be discovered twice, which is not necessary. To avoid this unnecessary transmission, the algorithm uses the following rule : The potential deadlock cycle is transmitted only if the transaction identifier of the transaction for which EX waits is greater than the transaction identifier of the transaction waiting for EX. For example, consider following DWFG, Site 1 T1 T2 Site 2 T1 T2
  • 3. The local deadlock detectors at each site builds the LWFG as follows, At site 1 T1 T2 EX At site 2 T1 T2 EX NOTE : In LWFG, all output and input ports are collected into a single node, called external (EX). From above LWFFGs , we obtain that only site 2 transmits the potential deadlock cycle because at site 2 EX is waiting for T2 and T1 is waiting for EX in the potential cycle (from the above rule). At each iteration of the algorithm, the local deadlock detectors at each site perform the following actions : 1) Build the LWFG using local information. The LWFG includes the node EX. 2) For each message which has been received, perform the following modifications of the LWFG : a) For each transaction in the message, add it to the LWFG if it does not already exist. b) For each transaction in the message, starting with EX, create an edge to the next transaction in the message. This step has included all potential deadlock information received from other sites into the local LWFG. 3) Find cycles not involving EX in the LWFG. Each such cycle indicated the existence of a deadlock. Deadlock resolution is invoked to eliminate these deadlocks. 4) Find cycles involving EX. These cycles are potential deadlock cycles. The rule described above is used to determine whether a potential deadlock cycle must be transmitted to a different site. If the transmission is required, the message is prepared and transmitted. The transmission of potential deadlock cycles terminates the current iteration of the deadlock detection process.
  • 4. PROBLEM 1: Consider the following DWFT given below, Site1 T2 T2 T3 Site2 T1 T1 T3 Site3 Detect the deadlock using the distributed deadlock diagram. ANSWER : Iteration 1: First draw LWFG for each site. T1 T2 EX At site 1 T2 T3 EX At site 2 EX T1 T3 At site 3 At site3, there is no potential deadlock cycle exists. But site1 and site2 LWFG contain potential deadlock cycle. The rule for transmitting the potential deadlock cycle is as follows : The potential deadlock cycle is transmitted only if the transaction identifier of the transaction for which EX waits is greater than the transaction identifier of the transaction waiting for EX. From the above rule, none of the site sends the information to the remaining sites. Therefore the iteration terminates without sending any information.
  • 5. PROBLEM 2 : Consider following DWFG, Site 1 T1 T2 Site 2 T1 T2 Detect the deadlock using the distributed deadlock diagram. ANSWER : Iteration 1 : First draw LWFG for each site. T1 T2 EX T1 T2 EX Site1 Site2 Both site1 and site2 LWFGs contain potential deadlock cycle. The rule for transmitting the potential deadlock cycle is as follows : The potential deadlock cycle is transmitted only if the transaction identifier of the transaction for which EX waits is greater than the transaction identifier of the transaction waiting for EX. From the above rule, only site 2 transmits the potential deadlock cycle because at site 2 EX is waiting for T2 and T1 is waiting for EX in the potential cycle. Cycle involves EX. Therefore site1 receives message from site1 as (EX, T2, T1). Iteration 2 : At site 1, after receiving the message from site2, the local deadlock detector modifies the LWFG as follows : a) No need to add any transaction the LWFG as each transaction in the message is already exists in LWFG. b) For each transaction in the message i.e. T1 and T2, starting with EX, create an edge to the next transaction in the message. T1 T2 EX c) There is a cycle not involving EX in the above LWFG (i.e. T1-T2-T1). Thus there is a deadlock detected at site1. Deadlock resolution is invoked at site1 by selecting a victim and an abort message for that victim is send to all sites where the victim was active (i.e. to site2). ******************