Question

Assume that we desire to have deadlock-free mutual exclusion using locks on a shared object implemented...

Assume that we desire to have deadlock-free mutual exclusion using locks on a shared object implemented via a set of shared registers.

  1. Suppose we allow threads to go through the lock method without writing to any of the shared registers?

  1. In general, it will be impossible to tell if a thread is in the critical section by examining the shared object.

  2. It will result in deadlocks.

  3. Both (a) and (b)

  4. Neither (a) nor (b)

  1. Suppose a thread attempts to lock and finds that the shared lock object indicates that there is no thread in the critical section. Assume no other thread is attempting to lock. What will happen?

  1. The thread will wait

  2. The thread will deadlock

  3. The thread will enter the critical section

  4. The lock object will be in an in inconsistent state

  1. Suppose threads A and B are attempting to lock at the same time. Assume that there is a single shared variable. Let the value of 0 mean that no object is in the CS. Assume that a value of 1 in this variable indicates that A is entering/is in the CS and a value of 2 in the same register indicates that B is entering/is in the CS. Assume that A and B both read the register, initially 0, and are about to update them. Suppose A updates the register to 1. What would be the result? Select all that apply.

  1. A will enter the CS.

  2. The two threads will deadlock.

  3. B will wait for A to complete the execution of the CS.

  4. B will eventually obliterate the value written by A.

  5. The lock object will be in an inconsistent state.

  6. Both A and B could be in the CS at the same time.

The diagram given at the end shows the execution of three threads on a single object o1. The horizontal axis has time increasing as we go from left to right. The thicker lines show the durations of method calls. Assume that the schedule is from the perspective of an imaginary global observer in real time. So if a vertical line intersects two thick lines, the corresponding method calls are interleaved.

  1. Identify all quiescent periods.

  2. Is the object quiescently consistent? Explain.

  3. What would be a program order?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

ANSWER

Qus:- Assume that we desire to have deadlock-free mutual exclusion using locks on a shared object implemented via a set of shared registers.

Suppose we allow threads to go through the lock method without writing to any of the shared registers?

  1. In general, it will be impossible to tell if a thread is in the critical section by examining the shared object.
  2. It will result in deadlocks.
  3. Both (a) and (b)
  4. Neither (a) nor (b)

Ans -)

Both a and b.

If share register are not updated by threads that another threads thinks no one in critical section and it also comes in critical section without updating which leads deadlock.

Qus -) Suppose a thread attempts to lock and finds that the shared lock object indicates that there is no thread in the critical section. Assume no other thread is attempting to lock. What will happen?

  1. The thread will wait
  2. The thread will deadlock
  3. The thread will enter the critical section
  4. The lock object will be in an in inconsistent state

Ans -)

The thread will enter the critical section.

If no other thread in critcal section then the thread will enter by locking so no other thread can access critical section until when thread inside critical section unlocks or leave the critical section.

Qus -) Suppose threads A and B are attempting to lock at the same time. Assume that there is a single shared variable. Let the value of 0 mean that no object is in the CS. Assume that a value of 1 in this variable indicates that A is entering/is in the CS and a value of 2 in the same register indicates that B is entering/is in the CS. Assume that A and B both read the register, initially 0, and are about to update them. Suppose A updates the register to 1. What would be the result? Select all that apply.

  1. A will enter the CS.
  2. The two threads will deadlock.
  3. B will wait for A to complete the execution of the CS.
  4. B will eventually obliterate the value written by A.
  5. The lock object will be in an inconsistent state.
  6. Both A and B could be in the CS at the same time.

Ans -)

The two threads will deadlock.

B will eventually obliterate the value written by A.

The lock object will be in an inconsistent state.

Both A and B could be in the CS at the same time.

Add a comment
Know the answer?
Add Answer to:
Assume that we desire to have deadlock-free mutual exclusion using locks on a shared object implemented...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Suppose threads A and B are attempting to lock at the same time. Assume that there...

    Suppose threads A and B are attempting to lock at the same time. Assume that there is a single shared variable. Let the value of 0 mean that no object is in the CS. Assume that a value of 1 in this variable indicates that A is entering/is in the CS and a value of 2 in the same register indicates that B is entering/is in the CS. Assume that A and B both read the register, initially 0, and...

  • JAVA 3 PLEASE ANSWER AS MANY QUESTIONS AS POSSIBLE! ONLY 2 QUESTIONS LEFT THIS MONTH!!! Question...

    JAVA 3 PLEASE ANSWER AS MANY QUESTIONS AS POSSIBLE! ONLY 2 QUESTIONS LEFT THIS MONTH!!! Question 12 pts Which is a valid constructor for Thread? Thread ( Runnable r, int priority ); Thread ( Runnable r, String name ); Thread ( int priority ); Thread ( Runnable r, ThreadGroup g ); Flag this Question Question 22 pts What method in the Thread class is responsible for pausing a thread for a specific amount of milliseconds? pause(). sleep(). hang(). kill(). Flag...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT