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?

Difference between message passing and shared memory, Problem: a) To en...

Problem: a) To ensure proper operation, the operating system and all the other programs must be protected from any malfunctioning program. Describe a mechanism which is impleme

Determine scheduling policy for time-shared operating system, Determine a s...

Determine a scheduling policy that is most suitable for a time-shared operating system   Round-Robin is a scheduling policy that is most suitable for a time-shared operating s

Producer-consumer, The general idea of a producer-consumer architecture is ...

The general idea of a producer-consumer architecture is related to building a pipeline of threads, similar to the web spider from Project 2. Each step of the processing will now be

Program that will input an interger target value, When you turn in an assig...

When you turn in an assignment to be graded in this class, you are making the claim that you neither gave nor received assistance on the work you turned in (except, of course, assi

Explain the scheduleworktodo function used in netware, Explain the Schedule...

Explain the ScheduleWorkToDo Function used in Netware ScheduleWorkToDo(MyThread Function, arg, workToDo) The ScheduleWorkToDo ( ) function is specific to NetWare 4.0. This c

Assignment, You must use fork and pipe to complete this project. This proj...

You must use fork and pipe to complete this project. This project creates processes to add all numbers in a file. The user will enter a number (1, 2, or 4) of parallel processes

Write a short note on disk structure, Write a short note on disk structure ...

Write a short note on disk structure Modern disk drives are initiate as large one dimensional array of logical blocks where the logical block is the smallest unit of transfer.

Define lru page replacement policy, Define ‘LRU’ page replacement policy ...

Define ‘LRU’ page replacement policy LRU is Least Recently Used page replacement policy.

What is an operating system and its type, What is an operating system and w...

What is an operating system and what are the different types of operating systems? Operating System An Operating System or OS is a software program that allows the compute

An operating system for a real-time environment, Q. What is the major diffi...

Q. What is the major difficulty that a programmer should overcome in writing an operating system for a real-time environment? Answer: The major difficulty is keeping the oper

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