Question

Given two processes, the structure of each process is as follows: do f flag [i] -ture ; while (flag [j] “ turn-j); //Critical

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

No

Because,the while condition doesn't ensure the mutual exclusion.It should be while(flag [j] && turn==i).

suppose Pj is executing the  critical section and at this time Pi is ready is to execute critical section then it set flag[i]=true and turn =i then according to the code while loop get fail and same time Pi will also enter into the critical section .So the condition of mutual exclusion is not satisfied.

Add a comment
Know the answer?
Add Answer to:
Given two processes, the structure of each process is as follows: do f flag [i] -ture...
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
  • 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...

  • 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.

  • 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

  • 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?

  • Major Homework #2 Implement a C program major_hw2.c to solve the 15-puzzle problem using the A* s...

    Major Homework #2 Implement a C program major_hw2.c to solve the 15-puzzle problem using the A* search algorithm. Please include pictures that the code runs and shows the different states as it reaches goal state please. 1. Objectives • To gain more experience on using pointers and linked lists in C programs. • To learn how to solve problems using state space search and A* search algorithm. 2. Background A* search and 15-puzzle problem have been introduced in the class....

  • Major Homework #2 Implement a C program major_hw2.c to solve the 15-puzzle problem using the A*...

    Major Homework #2 Implement a C program major_hw2.c to solve the 15-puzzle problem using the A* search algorithm. 1. Objectives • To gain more experience on using pointers and linked lists in C programs. • To learn how to solve problems using state space search and A* search algorithm. 2. Background A* search and 15-puzzle problem have been introduced in the class. For more information, please read the wiki page of 15-puzzle problem at https://en.wikipedia.org/wiki/15_puzzle, and the wiki page of...

  • accordingly answer and i pt): Polymers and Monomers. Read each question chemical structure, in a oymer chemical structure based on the polymer name and provide the monomer unit chemical st...

    accordingly answer and i pt): Polymers and Monomers. Read each question chemical structure, in a oymer chemical structure based on the polymer name and provide the monomer unit chemical structure, in addition. Lastly applications. An example answer is provided as guidance. , provide an example of how the polymers are utilized in (bio)engineering Polymer Chemical Structure Polymer Full Name and Abbreviation Usage Example for Monomer Unit Structure(s) _ _pt per box) pt per box) pt per box) Nucleic Acid (DNA)...

  • Recursion and Trees Application – Building a Word Index Make sure you have read and understood...

    Recursion and Trees Application – Building a Word Index Make sure you have read and understood ·         lesson modules week 10 and 11 ·         chapters 9 and 10 of our text ·         module - Lab Homework Requirements before submitting this assignment. Hand in only one program, please. Background: In many applications, the composition of a collection of data items changes over time. Not only are new data items added and existing ones removed, but data items may be duplicated. A list data structure...

  • ****************************************************************************************************************8 I want it same as the output and with details please and comments "For two...

    ****************************************************************************************************************8 I want it same as the output and with details please and comments "For two thousand years, codemakers have fought to preserve secrets while codebreakers have tried their best to reveal them." - taken from Code Book, The Evolution of Secrecy from Mary, Queen of Scots to Quantum Cryptography by Simon Singh. The idea for this machine problem came from this book.You will encrypt and decrypt some messages using a simplified version of a code in the book. The...

  • Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQ...

    Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQUIRED for this program will use two stacks, an operator stack and a value stack. Both stacks MUST be implemented using a linked list. For this program, you are to write functions for the linked list stacks with the following names: int isEmpty (stack); void push (stack, data); data top (stack); void pop (stack); // return TRUE if the stack has no...

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