Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8069827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:11:16+00:00 2026-06-05T13:11:16+00:00

Consider a computer with five individual resources name R1 …. R5. Let five processes

  • 0

Consider a computer with five individual resources name R1 …. R5. Let five processes P1, …. P5 make requests in order, as follows:

i. P1 requests R2
ii. P4 requests R3
iii. P3 requests R1
iv. P2 requests R4
v. P5 requests R5
vi. P4 requests R2
vii. P5 requests R3
viii. P3 requests R5

Assume Process P_i gets R_i if R_i is currently available.

Is there deadlock and if so at what point did it occur and which processes did it involve?

Can anyone please help me out? For the first one I was thinking there’s no deadlock, but I’m not sure how to prove.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T13:11:18+00:00Added an answer on June 5, 2026 at 1:11 pm

    Assuming that’s the actual sequence of events, there is no deadlock there. Initially, all resources are free, Running that code in sequence:

    1. P1 requests R2: p1 has r2.
    2. P4 requests R3: p4 has r3.
    3. P3 requests R1: p3 has r1.
    4. P2 requests R4: p2 has r4.
    5. P5 requests R5: p5 has r5.
    6. P4 requests R2: p4 has r3, awaiting r2(p1).
    7. P5 requests R3: p5 has r5, awaiting r3(p4).
    8. P3 requests R5: p3 has r1, awaiting r5(p5).
    

    So the current state is:

    p1 has r2.
    p2 has r4.
    p3 has r1, awaiting r5(p5).
    p4 has r3, awaiting r2(p1).
    p5 has r5, awaiting r3(p4).
    

    and the chain of waits is (waiter -> blocker):

    p4 -> p1, p5 -> p4, p3 -> p5
    

    or:

    p3 -> p5 -> p4 -> p1
    

    Because there is no cycle in there, deadlock has not happened.

    Further proof can be obtained by simply having the non-waiters releasing their resources and following the chain of events:

     9. p1 releases r2, frees it up for p4 (p3 and p5 blocked, p4 has r3/r2).
    10. p4 releases r3, frees it up for p5 (p3 blocked, p5 has r5/r3).
    11. p5 releases r5, frees it up for p3 (nobody is blocked, p3 has r5).
    

    Final state after those steps is that:

    p1 has nothing.
    p2 has r4.
    p3 has r1/r5.
    p4 has r2.
    p5 has r3.
    

    Now there are no blockages and each thread can simply release whatever resources they still have allocated.


    Now, were you to expand your question to ask if deadlock were possible if those operations could happen in any order (while maintaining order within each thread), the answer is still no.

    It’s a basic tenet of mult-threading that you can avoid deadlock by ensuring all your resources are allocated in the same order in every thread. From the operations you gave, the individual threads allocate their resources as follows (order must be maintained within a thread):

    P1: R2
    P2: R4
    P3: R1 R5
    P4: R3 R2
    P5: R5 R3
    

    So, how can we ensure they’re all allocating in the same sequence? We just need to find a sequence that matches. First, we start with the above list but add spaces so that like resources are lined up and no resource is on both sides of another resource:

    P1:             R2
    P2: R4
    P3:    R1 R5
    P4:          R3 R2
    P5:       R5 R3
    
        R4 R1 R5 R3 R2  <==
    

    And there’s your sequence. Every thread is allocating resources in the order 4, 1, 5, 3, 2. Not every thread allocates every resource but that’s irrelevant here.

    That’s also not the only solution (R4 is stand-alone so it could go anywhere in the list – every other resource is involved in a single dependency chain (1,5,3,2) so their relative positions are fixed).

    However, it’s sufficient to prove that every thread is allocating the resources in a specific order, hence deadlock is impossible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As a programmer, what line of computer science or mechanism should I consider as
Consider these pseudo models: class City(models.Model): name = models.CharField() region = models.ForeignKey(Region) class Region(models.Model):
If we consider computer graphics to be the art of image synthesis where the
Consider we have a working computer support incident management web site developed with ASP.NET
Is it possible to animate the replacement of a class in javascript? Let's consider
Consider the Stable Marriage Algorithm : In mathematics and computer science, the stable marriage
consider a = ['1','2','3','4','5'] for(var i = 0; i < a.length; i++) { if
Consider: Public MustInherit Class Column Public ReadOnly Property ReturnSomethingUseful() As Object Get 'return something
Consider the code below. I do not want to create multiple instances of class
Consider this #define : #define msd_buffer ((volatile char *) MSD_BUFFER_ADDRESS) and this variable definition:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.