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 about interprocess communication, Explain about interprocess commun...

Explain about interprocess communication The cooperating processes communicate with each other via an interprocess communication facility. IPC gives a mechanism to permit proce

Explain the resource ownership by platform, Explain the Resource Ownership ...

Explain the Resource Ownership by Platform Ownership of data items may further be complicated by concepts defined in certain operating systems. Each operating system defines "p

What are the disadvantages of linked allocation, What are the disadvantages...

What are the disadvantages of linked allocation? The drawbacks are a. Used only for sequential access of files. b. Direct access is not supported c. Memory space neede

Roles of operating systems, Describe Three major roles of operating systems...

Describe Three major roles of operating systems in business computer systems

What are the main challenges for mobile computing, Question: (a) What ...

Question: (a) What are the main challenges for Mobile Computing? (b) What is the ISM band and what is particular about this frequency band? Name two wireless technologies

What are the multithreading models, What are the multithreading models? ...

What are the multithreading models? There are three models:- a) Many-to-One model b) One-to-One model c) Many-to-Many model

What is the resident set and working set of a process, What is the resident...

What is the resident set and working set of a process? Resident set is that portion of the process image that is actually in real-memory at a certain instant. Working set is th

What is long-term, What is long-term, medium-term, short-term? In a bat...

What is long-term, medium-term, short-term? In a batch system many processes are submitted than are able to be executed immediately. These processes are reel to a mass storage

Quick, why we say " OS is a resource allocator" and “OS is a control progr...

why we say " OS is a resource allocator" and “OS is a control program"?

Plot a function for value of heights, The performance of a file system depe...

The performance of a file system depends upon the cache hit rate (fraction of blocks found in the cache). If it takes 1 msec to satisfy a request from the cache, but 40 msec to sat

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