Need of shift alteration in critical section problem?, Operating System

Assignment Help:

Explain with an example the need of Shift Alteration in critical section problem?

Consider processes Pi and Pj and consider the algorithm for Pi and Pj.

                           For Pi

                           do

   {

    while(turn!=i)

    critical section

    turn=j

    remainder section

   }whie(1);

 

For Pi

                           do

   {

    while(turn!=j)

    critical section

    turn=i

    remainder section

   }whie(1);

 

In the above code variable 'turn' is shared among the two processes. If turn=i after that process Pi is allowed to get into the critical section. This make sure that only one process at a time can be in its critical section. It doesn't satisfy the progress requirement and as a result we can do strict alteration with this code. That is if turn=0 and P1 is ready to get into the critical section, P1 can't enter into the critical section even though P0 may be in its remainder section. therefore a new algorithm which stores the state of the process is implemented. The code is:

do

{

  flag[i]=true

  while(flag[j])

  critical section

  flag[i]=false

  remainder section

}whiel(1)

 

   Here Pi is setting its flag as true. Then it confirms whether Pj is present in the critical section. If so after that it waits until the process Pj comes out of the critical section. If state of Pj is set as false after that Pi directly enters into the critical section.

 


Related Discussions:- Need of shift alteration in critical section problem?

Explain the thread local storage (tls), Explain the Thread Local Storage (T...

Explain the Thread Local Storage (TLS)    Windows NT provides unique functions for per-thread data management. Thread local storage (TLS) is a concept defined in NT so develope

Linear programming problem, A paper mill produces two grades of paper viz.,...

A paper mill produces two grades of paper viz., X and Y. Because of raw material restrictions, it cannot produce more than 400 tons of grade X paper and 300 ton

Define properties to ensure good search performance, Define Properties to E...

Define Properties to Ensure Good Search Performance A hashing function h should possess the subsequent properties to make sure good search performance: a. The hashing functi

Independent process, what is independent process? distinguished between ind...

what is independent process? distinguished between independent process and co-operating process

Determine the reasons for poor response time, Determine the reasons for Poo...

Determine the reasons for Poor response time Process busy or High I/O rates or High paging rates

Explain acyclic-graph directories, Acyclic-graph directories An acyclic...

Acyclic-graph directories An acyclic graph permits directories to have shared subdirectories and files. The similar file or subdirectory may be in two dissimilar directories. A

Explian integrating a request/response mechanism, Explian Integrating a Req...

Explian Integrating a Request/Response Mechanism Traditional application developers will need to develop a mechanism for communication between requesting (client) and respondin

Explai basic concepts of demand paging, Basic concepts When a process i...

Basic concepts When a process is to be changed in, the pager guesses which pages will be used before the process is changed out again. Instead of swapping in a entire process,

What is a reference string, What is a reference string? An algorithm is...

What is a reference string? An algorithm is evaluated by running it on a particular string of memory references and computing the number of page faults. The string of memory re

Deadlock-avoidance algorithm, Regard as a computer system that runs 5000 jo...

Regard as a computer system that runs 5000 jobs per month with no deadlock-prevention or deadlock-avoidance scheme. Deadlocks take place about twice per month and the operator must

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd