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?

Designing issues in a network -fault tolerance, Fault tolerance Machine...

Fault tolerance Machine failures, Communication faults, storage device crashes, and decays of storage media should be tolerated by the system to some extent. A fault tolerant s

Assembly, Write a program that will input two numbers from the keyboard and...

Write a program that will input two numbers from the keyboard and execute each of the signed and unsigned multiply and divide instructions. For each instruction, the program shoul

Locks - mutexes, Locks (also known as mutexes, short for mutual exclusion l...

Locks (also known as mutexes, short for mutual exclusion locks) provide mutual exclusion to shared data inside a critical session. They are implemented by means of two atomic routi

What is critical section problem, What is critical section problem? Con...

What is critical section problem? Consider a system consists of 'n' processes. Every process has segment of code called a critical section, in which the process might be changi

Explain best fit algorithm, BEST FIT ALGORITHM Here scanning is for th...

BEST FIT ALGORITHM Here scanning is for the finest fit one. Signifies it searches the entire list for the best fit position. For the process therefore in that the process will

Batch system, what is a batch system give me answer in simple words so that...

what is a batch system give me answer in simple words so that i can understand

Describe the purpose of the checkpoint mechanism, Describe the purpose of t...

Describe the purpose of the checkpoint mechanism. How habitually must checkpoints be performed? Explain how the frequency of checkpoints affects: System performance while no

Explain debugging a multi threaded program, Debugging a multi threaded prog...

Debugging a multi threaded program The following list points out few of the more frequent oversights and errors that can cause bugs in multithreaded programs. 1.    Ephemeral

What are overlays, What are overlays? To enable a process to be larger ...

What are overlays? To enable a process to be larger than the amount of memory allocated to it, overlays are used. The idea of overlays is to keep in memory only those instructi

What is the basic approach of page replacement, What is the basic approach ...

What is the basic approach of page replacement? If no frame is free is available, find one that is not presently being used and free it. A frame can be freed by writing its con

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