08 - Chapter 1 PDF
08 - Chapter 1 PDF
CHAPTER 1
CONCURRENT PROGRAMMING -
PROBLEMS AND OPPURTUNITIES
1.1 INTRODUCTION
‘Do one thing at a time’ has been the guiding philosophy behind every
reducing the solution ofa given problem into a sequence of steps that can be executed one
after the other. A typical sequential machine architecture, built around a single processor
unit, permits only one operation to be performed at a given time. Programming Languages
leading to a solution. A set ofstatements leading to the solution ofa given problem is called
a program. The quest for increased efficiency in the utilisation ofthe processor capabilities
led to the introduction of specific purpose I/O Processors to control the I/O devices. The
use of I/O processors freed the main processor from the mundane, lengthy and device
dependent I/O operations. This technique brings in two new problems to solve. (Evans
1982)
The first is solved by using a switch through which the main processor and the
I/O processors are connected to the memory. The communication between the main
ii) The I/O processor reports to the main processor upon completion ofthe
job.
by the main processor. The main processor continues the execution of the program after
interrupts which enable the main processor to stop the execution of the program, handle
the interrupt and resume the execution of the program as though nothing has happened.
unknown in computing systems. The non-determinism stems from the fact that one is not
sure about the time of termination of an I/O job and the issue of an interrupt signal by the
I/O processor. The main processor however, services the interrupt only after the current
Eventhough the main process and the I/O jobs run simultaneosly,the I/O
processor is very much dependent on the main processor for its operation. The onus of
shielding these intricacies from the user falls on the operating system designer.
‘Think Parallel’ is the notion that would perhaps dominate the future course
ofcomputing. An attempt to solve problems more efficiently and more naturally led to the
3
developmentofnovelcomputerarchitecturesandprogrammingmethodologies. Concurrent
communications.
processes do not interact with each other. The control initiates the parallel processes and
upon termination ofall processes the operation is said to be complete. The situation is more
challenging when the processes have to interact with each other.In this case, whether a
given operation of a program was executed before, after or simultaneously with a given
operation of a parallel process assumes a great significance. Parallel programs are thus
statements within a program. Bernstein’s conditions are used to support data dependencies.
instruction spawns a process starting with the statement labelled L. This leads to two
processes, one starting with the statement labelled L and the other starting with the
number of processes. A go-to is used to transfer control to the join statement wherever
appropriate.
indicates the parallel execution of the single statements Sl..Sn. The next
statement in the program after the concurrent statement is executed only after the
implement all precedence graphs. The concurrent statement used along with other
5
extent.
interactions. In real life problems the parallel processes have to cooperate with each other
to achieve a common goal. Several techniques outlined in Section 1.3 illustrate the typical
towards the furthering of this challenging field that has ushered a new era of computing.
Coroutines - A synchronisation
concept
exclusion problem
6
implementation
RC 400 System
Secretary Concept
region
programs
Processes
problems.
G Copeland
Researchers accross the globe have made extensions to several concepts resulting in a
massive increase in the volume ofcontributions. Several new architectures were developed
and reported. An annotated bibliography ofvarious papers published in this area appears
1.3.1 Processes
Several processes running simultaneously towards a common goal form a set of co
program and sub-programs. Thus main program can call sub-programs and the sub
programs can initiate a call to the main program. However, this form of concurrency is
limited only to the transfer of control and thus is a very restricted version of parallel
programming.
the operating system designer. Process creation and maintenance incurs a lot of system
10
overhead. Thread is a concept introduced to reduce this overhead thereby increasing the
techniques.
portion ofphysical memory. However, this type ofimplementation directly leads to critical
regions to be discussed later. Another disadvantage of using shared variables is that the
process accessing the shared variable must be close to the location ofthe variable, lest the
processes. The use of hardware links provides faster communication but an inflexible
communication network. Providing logical or software links which can be mapped onto
a basic hardware interconnection scheme gives the user a great deal of flexibility at a
a) Direct Communication
explicitly specify the name ofthe receiver process and the receiver process has to explicitly
specify the name ofthe process from which it wants to receive a message. The logical link
ofthe other parallel processes. The sender process name is registered afterthe communication
and changed accordingly, which thwarts the provision of separate compilation facilities.
b) Indirect Communication
Two processes can communicate if and only if they have a shared mailbox.
Each mailbox has a unique identity. Between them, any two communicating processes
can have many mailboxes each with a unique label. The communication link thus
the operating system is providing the mailbox then it must provide the facilities for
The process that creates a mailbox is its owner by default. However, the
ownership may be relinquished by using the appropriate system calls. The child processes
of the process that has created a mailbox acquire access rights to the mailbox.
capacity to store a number of queued messages. The capacity of the link could be
In case of links with a capacity to queue the messages there is a need for an
A scheme that sends a reference to the messages rather than the original
messages greatly helps the recovery of lost messages. Either the operating system or the
sender process can detect and retransmit lost or scrambled messages. In some
implementation schemes the operating system detects the loss of a message and indicates
processing the message. The sender waits eternally for an acknowledgement. In this case
the sender process is notified by the operating system that the receiver is no more.
an acknowledgement either after receiveing a request from the sender or alongwith the
reply.
concurrent processes. The procedure on the receiver is treated as a remote procedure and
the sender marshalls the parameters in the form of as message. The parameter passing
mechanisms and the message formats are to be standardised. More importantly the failure
Concurrent processes co-operate with each other either by sharing data and/
deadlock problems as long as the processes are defined correctly. Message passing
systems may also make use of network protocols to ensure mutual exclusion. A detailed
The problem is not so simple when processes co-operate through shared data
or shared resources. As only one process may be granted access at any given time,the
shared data items and resources are termed as critical regions in process execution. There
is now a need to ensure mutual exclusion of the processes in the critical regions. Any
algorithm devised for this purpose must possess atleast the following features (Pratt
1983).
b) If the critical section is empty and there are several processes waiting
system interactions
d) No process is privileged.
In case of shared data items the mutual dependence relations among them
A severe software crisis shook the computing world during 1970-80. This was
a black decade that spelt doom to many programming languages existing until then. The
next decade however witnessed several programming paradigms vying for the top place.
The programming paradigms in the arena are given below (Muthukrishnan 1989).
b) Object-Oriented Paradigm
c) DistributedParadigm
f) Database Paradigm
The language paradigms discussed above are bifurcated into two distinct
groups.
i) Imperative Paradigms
set of inputs to a set of desired outputs. The block structured, Object- Oriented and
computed. They support inherent concurrency and lazy evaluation which permits the need
16
based on the Object-Oriented programming paradigm. CSP and DP are popular models
for distributed languages and systems. OCCAM, PLITS are languages based on the
A concern for checking computer programs for correctness was felt as early
as 1961. By checkingforcorrectnessofaprogramweattempttoestablishthattheprogram
upon execution leads to desired set of outputs for any given set of inputs. The need for
verification of programs increased with the increase in the complexity ofthe problems on
sequential programs. Other techniques evolved to verify sequential programs are axiomatic
approach, structured programming concepts etc. The programmer thus began to keep in
actions, are more difficult to be verified formally. A number of methods were suggested
assumptions about the implementation, scheduling and execution ofthe program on hand.
These assumptions are usually postulated as axioms describing the programming language
a) Safety Properties
program. These properties provide proof for partial correctness of the program using
invariant assertions and pre- and post- conditions. Invariant assertions are logical
properties that must be satisfied by the system at all times during execution. Pre- and post
conditions for a given statement ofthe program relate the state ofthe program before the
execution of that statement, to the state of the program after execution of that statement
respectively.
b) Liveness Properties
Liveness Properties establish that the required good things happen upon the
execution of the program. These properties confirm the termination of the program and
1.6 HARDWARE
architectures are giving way to more powerful parallel architectures. The operations of
sequence of instructions) and Data Stream (a collection of data items namely inputs,
intermediate results and outputs). The architecture of the machine decides the mode of
interaction between these two streams. There are several ways proposed by Flynn, Feng
and Wolfgang Handler to classify computer architectures. The most popular classification
Parallelism stems naturally from the two architectures SIMD and MIMD.
Pipeline Architectures and Vector Processing are two popular techniques employed to
b) Fault-tolerance
19
Several processor elements, shared memory modules, shared I/O facilities are
multiprocessor systems are C.mmp (dismantled), Cm*, S-l, IBM 370/168MP, Univac
1100/*x, Univac 1100/9x, Tandem/16, Cray X-MP, Denelcor HEP, IBM 3081, IBM
3084, Cyber 170, Honeywell 60/66, PDP -10 etc.
modules are situated at distances ranging from a few metres to several thousand kilometers
are called distributed systems. The message passing mechanisms in such systems is
dependent on another fully developed domain called Computer Networking. A thorough
20
Systems are also known as the Processor Pool model of distributed systems (Colouris
1990), (Lelann 1977).
concurrency also place a great demand on the underlying operating system. Some of the
multiprocessor systems mentioned earlier support their own specific operating system.
communication and synchronisation. In fact, UNIX can be readily ported onto multi
processor architectures.
support for concurrency. The key features of these three categories for a N processor
transparency and replication transparency to the programmer. There has been an ever
growing interest in the design ofDistributed Operating Systems due to the promise they
hold out to the concurrent programmer. However, the following problems are proving to
be challenging and providing ample scope for intense research activity in the area
(Tanenbaum 1992).
* Deadlocks
* Termination Detection
* File Systems
* Fault Tolerance
* Elective Algorithms
* Load Balancing
* Performance Measurement
is to ensure that atmost one process is using a share resources at any given time. This is
the Mutual Exclusion problem. As mentioned in section 1.2, solutions for this problem are
22
seen as early as 1963. The solutions have attained more maturity over the past three
decades andculminated in language level support for mutual exclution and synchronisation.
Such an abstraction mechanism at the language level has greatly simplified the task ofthe
concurrent programmer.
motivation to propose a new structuring concept called the concurrent monitor for
survey of various solutions proposed in the literature to solve the mutual exclusion
problem.
of its implementation on both tightly coupled and loosely coupled machine architectures
are mentioned. A new shared memory model is proposed. Solution for popular
between the Ada model and the concurrent monitor is presented to illustrate the
as monolithic, parallel banks and multiport ^^e/'ir-i in chapter 4 . The key issue has
been to generate a trace with the distinction between the read and write requests.
passing systems operating on the principle of token ring architectures. An algorithm for
one to examine a variety of load balancing strategies. The results of simulation studies of
modified to considerably reduce the execution time by using additional storage space.