C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Interested Variable MechanismWe 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 Non CS Int[i] = T ; while ( Int[j] == T ) ; Critical Section Int[i] = F ; For Process Pj Non CS Int [1] = T ; while ( Int[i] == T ) ; Critical Section Int[j]=F ; 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.
Let's analyze the mechanism on the basis of the requirements. Mutual ExclusionIn 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. ProgressIn 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 WaitingTo 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.
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 NeutralityThe mechanism is a complete software mechanism executed in the user mode therefore it guarantees portability or architectural neutrality.
Next TopicPaterson Solution
|