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?

Define segmentation, Define Segmentation  The memory allocation method...

Define Segmentation  The memory allocation method subject to “external” fragmentation is Segmentation.

Explain the threadswitchwithdelay function used in netware, Explain the Thr...

Explain the ThreadSwitchWithDelay Function used in Netware ThreadSwitchWithDelay( )   This command is used when threads are waiting for an event or resource but don't want t

What is erd, What is ERD? Entity Relationship Diagram is the graphical ...

What is ERD? Entity Relationship Diagram is the graphical representation of the object relationship pair. It is mostly used in database applications.

Define busy waiting and spinlock, Define busy waiting and spinlock. Whe...

Define busy waiting and spinlock. When a process is in its significant section, any other process that tries to enter its critical section must loop continuously in the entry c

What kernel provide for an effective user level thread, 1. What must a kern...

1. What must a kernel provide for an effective user-level thread implementation? 2. With respect to the quantum q in a scheduling algorithm, explain and discuss the impact of th

VB. Net & XML, Write a XML with database with book details (BOOK ID, Title,...

Write a XML with database with book details (BOOK ID, Title, Author, subject, publisher year, language, vendor, and price)

Explain acyclic graph directories and its implementation, Acyclic Graph Dir...

Acyclic Graph Directories In this kind of directory structure the shared directories or files can exist in the file system in two or more places at once. A tree structure excl

Read-write locks, Consider a large web-based database. In some sense, Googl...

Consider a large web-based database. In some sense, Google is sort of like this. There might be many users who want to read from the database, but only a few users who are allowed

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