Page 104 - DCAP403_Operating System
P. 104
Unit 6: Process Synchronization
Some of these resources (such as memory) are simultaneously shared by all processes. Such Notes
resources are being used in parallel between all running processes on the system. Other resources
must be used by one process at a time, so must be carefully managed so that all processes get access
to the resource. Such resources are being used in concurrently between all running processes on
the system. The most important example of a shared resource is the CPU, although most of the
I/O devices are also shared. For many of these shared resources the operating system distributes
the time a process requires of the resource to ensure reasonable access for all processes. Consider
the CPU, the operating system has a clock which sets an alarm every few hundred microseconds.
At this time the operating system stops the CPU, saves all the relevant information that is needed
to re-start the CPU exactly where it last left off (this will include saving the current instruction
being executed, the state of the memory in the CPUs registers, and other data), and removes
the process from the use of the CPU. The operating system then selects another process to run,
returns the state of the CPU to what it was when it last ran this new process, and starts the CPU
again. Let’s take a moment to see how the operating system manages this.
In this unit, we shall discuss about the deadlock. A deadlock is a situation wherein two or more
competing actions are waiting for the other to finish, and thus neither ever does. It is often seen
in a paradox like ‘the chicken or the egg’.
This situation may be likened to two people who are drawing diagrams, with only one pencil and
one ruler between them. If one person takes the pencil and the other takes the ruler, a deadlock
occurs when the person with the pencil needs the ruler and the person with the ruler needs the
pencil, before he can give up the ruler. Both requests can’t be satisfied, so a deadlock occurs.
6.1 Synchronization Process
Process synchronization refers to the idea that multiple processes are to join up or handshake
at a certain point, so as to reach an agreement or commit to a certain sequence of action.
Synchronization involves the orderly sharing of system resources by processes.
To illustrate the process synchronization, consider the above railway intersection diagram. You
can think of this intersection as a system resource that is shared by two processes: the car process
and the train process. If only one process is active, then no resource conflict exists. But what
happens when both processes are active and they both arrive at the intersection simultaneously?
In this case, the shared resource becomes a problem. They cannot both use the resource at the
same time or a collision will occur. Similarly, processes sharing resources on a computer must be
properly managed in order to avoid “collisions.”
Figure 6.1: Railway-road Intersection
Consider a machine with a single printer running a time-sharing operation system. If a process
needs to print its results, it must request that the operating system give it access to the printer’s
LOVELY PROFESSIONAL UNIVERSITY 97