Interested Variable Mechanism

We have to make sure that the progress must be provided by our synchronization mechanism. In the turn variable mechanism, progress was not provided due to the fact that the process which doesn't want to enter in the critical section does not consider the other interested process as well.

The other process will also have to wait regardless of the fact that there is no one inside the critical section. If the operating system can make use of an extra variable along with the turn variable then this problem can be solved and our problem can provide progress to most of the extent.

Interested variable mechanism makes use of an extra Boolean variable to make sure that the progress is provided.

For Process Pi

For Process Pj

In this mechanism, an extra variable interested is used. This is a Boolean variable used to store the interest of the processes to get enter inside the critical section.

A process which wants to enter in the critical section first checks in the entry section whether the other process is interested to get inside. The process will wait for the time until the other process is interested.

In exit section, the process makes the value of its interest variable false so that the other process can get into the critical section.

The table shows the possible values of interest variable of both the processes and the process which get the chance in the scenario.

Interest [Pi]Interest [Pj]Process which get the chance
TrueTrueThe process which first shows interest.
TrueFalsePi
FalseTruePj
FalseFalseX

Let's analyze the mechanism on the basis of the requirements.

Mutual Exclusion

In interested variable mechanism, if one process is interested in getting into the CPU then the other process will wait until it becomes uninterested. Therefore, more than one process can never be present in the critical section at the same time hence the mechanism guarantees mutual exclusion.

Progress

In this mechanism, if a process is not interested in getting into the critical section then it will not stop the other process from getting into the critical section. Therefore the progress will definitely be provided by this method.

Bounded Waiting

To analyze bounded waiting, let us consider two processes Pi and Pj, are the cooperative processes wants to execute in the critical section. The instructions executed by the processes are shown below in relative manner.

Process PiProcess PjProcess PiProcess Pj
1. Int [Pi] = True
2. while (Int [Pj] == True);
3. Critical Section
1. Int [Pj] = True
2. while (Int[Pi]==True);
1. Int [Pi] = False
2. Int [Pi] = True
3. while (Int [Pj] == True); //waiting for Pj
1. While (Int [Pi] == True); //waiting for Pj

Initially, the interest variable of both the processes is false. The process Pi shows the interest to get inside the critical section.

It sets its Interest Variable to true and check whether the Pj is also interested or not. Since the other process's interest variable is false hence Pi will get enter into the critical section.

Meanwhile, the process Pi is preempted and Pj is scheduled. Pj is a cooperative process and therefore, it also wants to enter in the critical section. It shows its interest by setting the interest variable to true.

It also checks whether the other process is also interested or not. We should notice that Pi is preempted but its interested variable is true that means it needs to further execute in the critical section. Therefore Pj will not get the chance and gets stuck in the while loop.

Meanwhile, CPU changes Pi's state from blocked to running. Pi is yet to finish its critical section hence it finishes the critical section and makes an exit by setting the interest variable to False.

Now, a case can be possible when Pi again wants to enter in the critical section and set its interested variable to true and checks whether the interested variable of Pj is true. Here, Pj's interest variable is True hence Pi will get stuck in the while loop and waits for Pj become uninterested.

Since, Pj still stuck in the while loop waiting for the Pi' interested variable to become false. Therefore, both the processes are waiting for each other and none of them is getting into the critical section.

This is a condition of deadlock and bounded waiting can never be provided in the case of deadlock.

Therefore, we can say that the interested variable mechanism doesn't guarantee deadlock.

Architectural Neutrality

The mechanism is a complete software mechanism executed in the user mode therefore it guarantees portability or architectural neutrality.


os Interested Variable Mechanism




Latest Courses