Hi brothers and sisters.. I am doing my IN IT.I am following Abraham Silberschatz "Operating System Concepts".. Please help me with regards to process synchronisation since I am not able to understand the logical progression but I am aware of some concepts
Here it goes
solution to the critical-section problem must satisfy the following three
1. Mutual Exclusion: If process Pi is executing in its critical section, then no
other processes can be executing in their critical sections.
2. Progress: If no process is executing in its critical section and some processes
wish to enter their critical sections, then only those processes that are
not executing in their remainder section can participate in the decision
on which will enter its critical section next, and this selection cannot be
Bounded Waiting: There exists a bound on the number of times that other
processes are allowed to enter their critical sections after a process has made
a request to enter its critical section and before that request is granted.
We assume that each process is executing at a nonzero speed. However, we can
make no assumption concerning the relative speed of the n processes.
In Sections 7.2.1 and 7.2.2, we work up to solutions to the critical-section
problem that satisfy these three requirements. The solutions do not rely on any
assumptions concerning the hardware instructions or the number of processors
that the hardware supports. We do, however, assume that the basic machinelanguage
instructions (the primitive instructions such as load, store, and
t e s t ) are executed atomically. That is, if two such instructions are executed
concurrently, the result is equivalent to their sequential execution in some
unknown order. Thus, if n load and a store are executed concurrently, the
load will get either the old value or the new value, but not some combination
of the two.
When presenting an algorithm, we define only the variables used for synchronization
purposes, and describe only a typical process Pi whose general
structure is shown in Figure 7.1. The entry section and exit section are enclosed
in boxes to highlight these important segments of code.
Figure 7.2 The structure of process Pi in algorithm 1.
7.2.1 Two-Process Solutions
In this section, we restrict our attention to algorithms that are applicable to
only two processes at a time. The processes are numbered
Po and PI. For
convenience, when presenting Pi, we use Pi to denote the other process; that
is, j == 1 - i .
220.127.116.11 Algorithm 1
Our first approach is to let the processes share a common integer variable turn
0 (or 1). If turn == i, then process Pi is allowed to execute in its
critical section. The structure of process Pi is shown in Figure 7.2.
This solution ensures that only one process at a time can be in its critical
section. However, it does not satisfy the progress requirement, since it requires
strict alternation of processes in the execution of the critical section. For
example, if turn == 0 and PI is ready to enter its critical section, PI cannot
do so, even though Po may be in its remainder section.
-End of quote
I am able to understand all the three conditions..As the author explains that turn is a variable initialised to zero..If turn equals i,the process Pi executes but in the program the condition inside the while is turn!=i..How does this ensured that ensures that only one process at a time can be in its critical
section? Why does it not satisfy the progress requirement..
|All times are GMT +5.5. The time now is 21:43.|