2. INTER PROCESS COMMUNICATION
An independent process is not affected by the execution
of other processes while a co-operating process can be
affected by other executing processes. Though one can
think that those processes, which are running
independently, will execute very efficiently but in
practical, there are many situations when co-operative
nature can be utilised for increasing computational
speed, convenience and modularity. Inter process
communication (IPC) is a mechanism which allows
processes to communicate each other and synchronize
their actions. The communication between these
processes can be seen as a method of co-operation
between them.
4. CRITICAL SECTION
A Critical Section is a code segment that accesses
shared variables and has to be executed as an
atomic action. It means that in a group of
cooperating processes, at a given point of time,
only one process must be executing its critical
section.
5. RACE CONDITION
A race condition is an
undesirable situation that
occurs when a device or
system attempts to
perform two or more
operations at the same
time, but because of the
nature of the device or
system, the operations
must be done in the
proper sequence to be
done correctly.
6. RACE CONDITION
Incorrect behaviour of a
program due to concurrent
execution of critical sections
by two or more threads.
For example, if thread one
deletes an entry in a linked
list while thread 2 is
accessing the same entry.
7. SOLUTION
A simple solution to critical section can be thought as shown
below,
acquireLock();
Process Critical Section
releaseLock();
A thread must acquire a lock prior to executing critical section. The
lock can be acquired by only one thread. There are various ways to
implement locks in the above pseudo code.