Question

a)Given the following solution for the critical section problem for two processes (the code shown is for processes Pi),...

a)Given the following solution for the critical section problem for two processes (the code shown is for processes Pi), show why it does not satisfy the mutual exclusion requirement. Here,lock is a shared variable initialized to FALSE. (Hint: Indicate one scenario where the mutual exclusion requirement is violated.)

do {

           lock = FALSE;

          while (lock);

          lock = TRUE

        Critical section

          /Empty section

          

       Remainder section

}

(b)Does this satisfy the progress requirement? Justify your answer

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

a Ans)

In the code for every process, there is a local variable "lock" which is made as FALSE. so, irrespective of the shared lock value the lock is made FALSE and every process is entering into the critical section.

Example:

Let say P0 has entered into the critical section by making lock as TRUE and it is not yet left the critical section.

Now P1 is initiated and executes it's the first line of code and make lock as FALSE and enters into critical sections.

which results in the violation of the mutual exclusion principle.

b Ans)

No, it doesn't satisfy the progress requirement. when a process entered into the critical section it makes the lock as TRUE and while leaving the critical section it didn't change the lock value and not allowing other processes to enter into the critical section. so it is not satisfying the progress requirement. To satisfy the progress requirement for any critical section problem it changes the value of lock while it leaving the critical section.

Add a comment
Know the answer?
Add Answer to:
a)Given the following solution for the critical section problem for two processes (the code shown is for processes Pi),...
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
  • a. Given the solution for the critical section problem for two processes (the code shown is...

    a. Given the solution for the critical section problem for two processes (the code shown is for processes Pi), show why it does not satisfy the mutual exclusion requirement. Here, lock is a shared variable initialized to FALSE. (Hint: Indicate one scenario where the mutual exclusion requirement is violated.): do { while (lock); lock=TRUE Critical section lock=FALSE; Remainder section } b. What happens if lock is initialized to TRUE in the code above?

  • Following is the hardware TestAndSet solution for critical-section problem. Can this solution sat...

    Following is the hardware TestAndSet solution for critical-section problem. Can this solution satisfy bounded waiting? Explain your answer. Shared boolean variable: lock (initialized to false) Solution: while (true) { while(TestAndSet(&lock)) ; /*do nothing //critical section lock = FALSE; //remainder section }

  • The following code fragment is a 2-process "solution" to the critical section problem try ] =...

    The following code fragment is a 2-process "solution" to the critical section problem try [i] = true ; while (incs[j]) no-op; while (turn=j and try[j]) no-op; incs [i] = true ; critical section try [i] = false; incs [i] = false; turn = j ; Does the above "solution" meet all 3 conditions of critical sections? Please explain your answer.

  • I undertand the algo is Peterson's Solution and that it will not cause deadlocks or busy waiting. But does this so...

    I undertand the algo is Peterson's Solution and that it will not cause deadlocks or busy waiting. But does this solve the critical section problem in its entirety such as in the case of more than 2 processes. Does this Scanned Documents 1.jpg w the following code. What algorithm does this implement? solve the critical section problem, defend your decision, explain in detail Revi #define FALSE O #define TRUE 1 /*number of processes / #define N 2 int turn int...

  • TRUE-FALSE     Basic synchronization principles and multithreading 1. Java user threads can implement both busy-waiting and no-busy-waiting...

    TRUE-FALSE     Basic synchronization principles and multithreading 1. Java user threads can implement both busy-waiting and no-busy-waiting policy. 2. Priority inversion avoids deadlocks. 3. Spinlock mutex can be used as an adaptive mutex. 4. Java RTE can be blocked for Input/Output operation. 5. Interrupted user thread, which executes a method in a monitor, must be rolled back to undo any changes it performed. 6. The synchronization primitive by disabling interrupts can be used by an application program. 7. Bounded-waiting requirement is...

  • operating system engineering , please read the question and solve on the given skeleton code ....

    operating system engineering , please read the question and solve on the given skeleton code . Write a multi-threaded program with Semaphores as counters and pthread_mutex_t mutex to solve the producer-consumer problem: A bounded buffer is simply a global integer array of size N (2) which can be accessed by multiple threads. • Create two types of threads - Producer (2) and Consumer (2). Producers will write to the buffer, and the consumers will read the buffer. In this scenario,...

  • What are the three requirements for a solution to the critical-section problem? Consider the following solution...

    What are the three requirements for a solution to the critical-section problem? Consider the following solution to the dining-philosophers' problem. // Global variables. Shared among threads int state [5]; semaphore mutex; I/ Initially set to 1 semaphore s [5] I Initially s[i] is set to 0 for all i Initially statei]-THINKING for all i void philosopher (int i) f int left(int i) f // Philosopher to the left of i // % is the mod operator. while(TRUE) thinkO take.forks ()...

  • Zybooks 11.12 LAB*: Program: Online shopping cart (continued) Python 3 is the code needed and this...

    Zybooks 11.12 LAB*: Program: Online shopping cart (continued) Python 3 is the code needed and this is in Zybooks Existing Code # Type code for classes here class ItemToPurchase: def __init__(self, item_name="none", item_price=0, item_quantity=0): self.item_name = item_name self.item_price = item_price self.item_quantity = item_quantity # def __mul__(self): # print_item_cost = (self.item_quantity * self.item_price) # return '{} {} @ ${} = ${}' .format(self_item_name, self.item_quantity, self.item_price, print_item_cost) def print_item_cost(self): self.print_cost = (self.item_quantity * self.item_price) print(('{} {} @ ${} = ${}') .format(self.item_name, self.item_quantity, self.item_price,...

  • Our 1st new array operation/method is remove. Implement as follows: public static boolean remove( int[] arr,...

    Our 1st new array operation/method is remove. Implement as follows: public static boolean remove( int[] arr, int count, int key ) { 1: find the index of the first occurance of key. By first occurance we mean lowest index that contains this value. hint: copy the indexOf() method from Lab#3 into the bottom of this project file and call it from inside this remove method. The you will have the index of the value to remove from the array 2:...

  • Using the book, write another paragraph or two: write 170 words: Q: Compare the assumptions of...

    Using the book, write another paragraph or two: write 170 words: Q: Compare the assumptions of physician-centered and collaborative communication. How is the caregiver’s role different in each model? How is the patient’s role different? Answer: Physical-centered communication involves the specialists taking control of the conversation. They decide on the topics of discussion and when to end the process. The patient responds to the issues raised by the caregiver and acts accordingly. On the other hand, Collaborative communication involves a...

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
Active Questions
ADVERTISEMENT