Distributed Computing, An Introduction: 1.1 Definitions
Distributed Computing, An Introduction: 1.1 Definitions
Distributed Computing, An Introduction: 1.1 Definitions
Distributed Computing,
An Introduction
This book addresses distributed computing. In this chapter, we will begin by clar-
ifying what is meant by distributed computing in the context of this book. We will
do so by looking at the history of distributed computing and by comparing this
type of computing with other forms of computing. We will then present some
basic concepts in the disciplines of operating systems, networks, and software
engineering, concepts that you will need to be familiar with in order to under-
stand the material presented in later chapters.
1.1 Definitions
Asource of confusion in the field of distributed computing is the lack of a uni-
versal vocabulary, perhaps because of the breathtaking pace with which new
ideas evolve in the field. Following are the definitions of some of the key terms
used in the context of this book. When you read the book, please keep these def-
initions in mind, and be aware that some of these terms may not have the same
definition in other contexts.
Early computing was performed on a single processor. A uni-processor, or
monolithic computing, makes use of a single central processing unit (CPU) to
execute one or more programs for each application.
Adistributed system is a collection of independent computers, interconnected
via a network, that are capable of collaborating on a task. Computers are con-
sidered independent if they do not share memory or program execution space.
21
22 CHAPTER 1 Distributed Computing, An Introduction
Such computers are called loosely coupled computers, as opposed to tightly
coupled computers; the latter can share data using common memory space.
Distributed computing is computing performed in a distributed system. In this
book, we explore the ways that computer programs, running on independent
computers, collaborate with each other to perform computing such as network
services and Web-based applications.
Anetwork service is a service provided by a special kind of program known
as a server on a network. The World Wide Web is such a service, as is elec-
tronic mail (email) and file transfer (FIP). Aserver program is just half of the
story in the so-called client-server model of distributed computing. Client-
server will be studied extensively in later chapters of this book.
Anetwork application is an application that runs on networked computers
for end users. Network applications range from enterprise applications such
as online shopping carts and electronic auction sites to noncommercial
applications such as chatrooms and network games.
The distinction between network services and network applications is not
always clear-cut, and the terms are often used interchangeably.
Request for C:omments
are specifications pro-
posed by Internet engi
neers to invite public
comments. Over the
years, thousands of such
specifications have
arisen, and they are
archived and accessible
in a number of Web
sites, including The
Intemet RFC/STD/FYI/BCP
Archive' [faq,.org, 5J.
The ARPANET, initiated
in 1970, was the prede.
cessor of the Internet.
1.2 The History of Distributed Computing
In the beginning there were stand-alone computers, each of which was capable
of executing stored programs. Connecting stand-alone computers so that data
could be exchanged among them was a natural progression. Rudimentary con-
nection of computers using cables for file sharing was practiced as early as the
1960s. However, such an undertaking requires manual intervention and cannot
be called a computer application when one or more computer programs execute
autonomously to carry out a task. Such a computer application requires data
communication, whereby two computers spontaneously exchange data using
software and hardware in order to carry out the tasks inherent in the application.
The first Internet Request for Comments (RFC), RFC I, is a proposal that speci-
fies how participating hosts can exchange information with each other through
messages. Whereas there may have been individual attempts to create network
applications on a small scale (perhaps involving two or more computers con-
nected via cables), the earliest network application was electronic mail, or
email, by which the first message was reportedly sent in 1972 on a four-node
ARPANET. (A node on a network is a computer, or host, that participates in the
network.) Automated file transfer mechanisms, which allowed data files to be
exchanged between hosts, were another natural progression, and as early as
1971 there was a proposal for such a mechanism (see RFC 114 and RFC 141). To
this day, email and file transfer remain two of the most popular network serv-
ices. The best-known network service, however, is undoubtedly the World Wide
Web (WWW). The Web was originally conceived in the late 1980s by scientists
at the Swiss research institute CERN in Geneva as an application that could sup-
port the access of hypertext over a network. The WWW has since become a plat-
form for network applications and services, including email, search engines,
and electronic commerce (e-commerce).
1.2 The History of Distributed Computing 23
The WWW was responsible for an explosion in the scale of the Internet. Until
J990, ARPA ET, the predecessor of the Internet as we know it, was primarily a
data network used by scientists, researchers, and academicians. Spurred by the
popularity of the WWW.thenetworkgrewspectacularlyintheJ990s.asillus-
trated in Figures 1. J and 1.2.
If you are interested in the history of network computing, some Web sites that
are well worth visiting are [vlmp.museophile.com, J], [zakon.org, 2), and
[isoeorg, 38]. In addition, [Hafner and Lyon, 4] is a fascinating account of the
early development of the Internet, including the people and the organizations
involved in it.
Hypertext, a term
coined by visionary Ted
Nelson, refers to textual
documents in which
associative paths may be
followed to access addi-
tional documents. The
bestknown example of
hypertext is a Web page
that contains Web links.
160,000,000
1'0,000,000
120,000,000
100,000,000
II 80,000,000
:z:
..
60,000,000
40,000,000
20,000.000
0
Hobbes' Intemet Timeline Copyright C2lD2 Robert Hlakon
htlpJIwww zakan org/robertlintemetllimelinel
pm Hom I
pm 80m
"i .ev Survey
'7
lZl69
I 08/83 S62
-
1
.f
f
Figure 1.1 The growth of Internet hosts [zakon.org, 2] (reprinted by permission).
An Internet domain is
part of the naming
scheme of resources on
the Internet.
0
0
;;;
N N N M
1
m
i
m m m
1
m m m m m
,;
.. c c
"
.,
.b
"
"
.. c c
,
, A
,
15
,
,
'"
0
'"
<
z <
'"
0
'" '"
<
, ,
Hobbes' Inlemel Timeline Copynght C2OJ2 Robert Hlaken
,
..... .....
1.600.000
1,400,000
1.100,000
i 1,000,000 ...
800,000 ..
J
400,000 ...
100,000
,.,.,.'"""....... mnm.._ll
Figure 1.2 Internet domains [zakon.org, 2) (reprinted by permission).
24 CHAPTER 1 Distributed Computing, An Introduction
HISTORICAL TnR... E... N""D.... S'-- _
by Richard Gabriel and jim Waldo, Sun MicroSystems
(Excerpted from http://www.sun.com/jini/overview/[7])
Reprinted by permission of lim Waldo.
How have we arrived at a place where
connected services and devices are the
driving forces for the next wave of com-
puting?
The most significant reason is our bet
ter understanding of physics, chemistry,
the physical bases for computation, and
chip manufacturing process. Today, a 5i9
nificantly powerful computer can be built
from one or two small chips and an entire
computer system can be built on one
small board.
There were three dimensions of
improvement: size, cost, and computa-
tional power. Since the 19605, size and
cost of computers have decreased dra-
matically while computational power has
gone through the roof.
The mainframe of the 1960s was a col-
lection of boxes in a large room-it cost
millions of dollars and set the bar for
computational power. Only a company
could afford one.
The minicomputer became possible
when the functionality of a mainframe
could be put in a few boxes. It had the
computational power of the previous
mainframe generation and could be
bought by a single department. Most
minicomputers were connected to inter-
active terminals-the beginnings of com-
puter-based culture, a community.
When a computer with the power of a
mini shrank to a box that fit beside a desk,
we got the workstation. A department
could afford to buy one for a couple of
professionals. A workstation had enough
computational power to support sophisti-
cated design, engineering, and scientific
applications, and to provide the graphical
support for them.
The personal computer was small
enough to fit on a desk and powerful
enough to support intuitive graphical user
interfaces, individuals could afford them,
and companies bought them for every
employee.
Eventually processors became small
enough and cheap enough to put one in
a car in place of an ignition system, or in
a TV instead of discrete electronics.
Today's cars can have frfty or more proces-
sors, the home over a hundred.
The computational power dimension
has another fallout. Tho overall trend
toward smaller, faster, cheaper processors
meant that fewer people had to share a
CPU, but it also meant that people in the
organization could become isolated.
When a tool is shared, it creates a com-
munity; as the tool shrinks, fewer people
use it together, and the community dis-
perses. But a community is hard to give
up. Fortunately, computational power
kept pace with the shrinking processor,
and as the community served by a single
computer system shrank, there was
enough power to support communica-
tion between systems. Thus, for example,
workstations became successful once
they could communicate and exchange
data.
The final stretch of the computational
power dimension is that now processors
are powerful enough to support a high-
level, object-oriented programming lan-
guage in such a way to support moving
objects between them. And such a
processor is small enough and cheap
enough to sit in the simplest devices.
Once there is sufficient computational
power, the ability to connect and com-
municate is the dominant factor deter-
mining value. Today for most people. a
computer runs only a few applications
1.3 Different Forms of Computing 25
and mainly facilitates communication:
email, the Web. Recall how fast Internet
popularity soared first with email and,
more recently, once the Web and
browsers became prevalent
1.3 Different Forms of Computing
To understand what is meant by distributed computing in the context of this
book, it is instructive to look at various forms of computing using computers.
Monolithic Computing
In the simplest form of computing, a single computer, such as a personal com-
puter (PC), is used for computing. The computer is not connected to any net-
work, and thus it may use only those resources within its immediate access. This
form of computing may be called monolithic computing. In the most basic
monolithic computing, the computer is used by a single user at a time. The user
oms applications on the system with no access to resources beyond those avail
able with the system. When you use applications such as a word processing pro-
gram or a spreadsheet on a PC, you are practicing this form of computing,
which may be called single-user monolithic computing.
Multiple users can engage in monolithic computing. This form of computing
(see Figure 1.3a), where the resources of a single computer can be shared by con-
current users using a technique known as timesharing, was popular in the
1970s and 1980s. The computer that proVides the centralized resource is usually
called a mainframe to differentiate it from smaller computers such as minicom-
puters and .microcomputers. Through devices known as terminals, users (who
may be geographically dispersed) can be connected to the mainframe computer
and interact with it during a terminal session. Some widely used mainframe
computers include the IBM 360 series and the Univac 1100 series. Applications
using this form of computing are typically separate programs designed to per-
form a single function, such as payroll or billing for a firm or a university.
Distributed Compl,lting
In contrast, distributed computing involves computing performed among
multiple network-connected computers, each of which has its own processor(s)
and other resources (see Figure 1.3b). Auser, using a workstation, has full use of
the resources on the local computer to whiCh its workstation is connected. In
26 CHAPTER 1 Distributed Computing, An Introduction
addition, through the interaction of the local computer and the remote com
puters, the user may access resources on the remote computers. The World Wide
Web is an excelient example of this type of computing. When you use a browser
to visit a Web site, a program such as Netscape or Internet Explorer runs on your
local system and interacts with a program (known as a Web server) running on
a remote system to fetch a file that may reside on yet another remote system.
Terminal
(a)
Mainframe computt.,'
(b)
Workstation
Figure 1.3 Centralized computing (a) versus distributed computing (b).
Parallel Computing
Similar to but distinct from distributed computing is a form of computing
known as parallel computing or parallel processing, which uses more than
one processor simultaneously to execute a single program. "Ideally, paraUel pro-
cessing makes a program run faster because there are more engines (CPUs) run-
ning it. In practice, it is often difficult to divide a program in such a way that
separate CPUs can execute different portions without interfering with each
other" [Koniges, 9]. Parallel computing is typically performed on a single com-
puter that has multiple CPUs, but, according to Koniges, it is also possible to
"perform paraliel processing by connecting the computers in a network.
However, this type of paraliei processing requires very sophisticated software
calied distributed processing software" [Koniges, 9].
Using paraliel co;nputing, one can solve problems that are otherwise impossible
to solve on one computer or solve computing-intensive problems that are oth-
erwise economicaliy untenable. Today, parallel computing is primarily used in
large-scale scientific computing in areas such as biology, aerospace, weather
forecasting, and semiconductor design. Although a fascinating subject, parallel
computing is not within the scope of this book.
1.3 Different Forms of Computing 27
WHERE _
Seller submits
information
UUNet
Many
mirrored
font-end
L.,.,' .."" .,"'!,..,-' servers
Sprint
Planned new
Starfire server
O
Buyer
submits bid
Anaconda
EBay is planning to add another Starfke attached to
the final data disks, mirroring Anaconda.
by Joseph Menn
(From La' Angeles Times, La, Angeles, Calif., Dec. 2, 1999, Joseph Menn.
Copyright Cl 1995, La, Angele, Times.)
Reprinted with permission.
EBay users rarely think about the bidding process-
until the site crashes. Behind the scenes, the online
auctioneer has a number of safeguards that rely
increasingly on duplicated, or mirrored, technolo-
gies in case one piece of machinery or software fails.
Buth the information must ,till pas, through many
different companies and type' of equipment for
everything to work properly.
o Bidder at home registers and submits an elec-
tronic bid from a personal computer.
a The bid travel, from the con,umer', Internet
service provider, through switches and routers, to
the ISP company', 'ervers.
(] The bid is sent through the Internet backbone.
The bid travels to one of EBay's ISPs, most likely
Sprint or UUNet, and through pipes to EBay.
11 The bid passes through EBay' Cisco switche,
and routers.
mThe Information reaches one of about 200
front-line Compaq servers running on Windows NT.
The servers are mirrored, so that if anyone fails, the
others pick up the slack.
a The bid is passed along to one of Sun
Microsystems' Starfire servers, named Bull and Bear,
that mirror each other.
[J The bid is added to two information-storage
databases running Oracle software, where it is
matched with the seller's information.
mThe information flow is reversed back out of
EBay, into e-mails sent to both the 'eller and poten-
tial buyers who are outbid. Confirmation is also sent
to the bidder.
IIi] From Bull, the bid amount and other details
are sent to another Starfire server, called Anaconda,
and recorded on mirrored storage disks.
Sources: Times staff, EBay
28 CHAPTER 1 Distributed Computing, An Introduction
An interested computer
owner will download a
free piece of software
(for example, a screen
saver) from SETI@home.
Then, when his or her
computer is idle while
online, the software
downloads a data file
from an Internet site for
analysis on his or her
computer. The results of
the analysis are sent
back to the Internet site
where they are com-
bined with those can
tributed by other
SETI@home participants
and used to help in the
search for extraterrestrial
signals.
Cooperative Computing
Recently, the term distributed computing has also been appIJed to cooperative com-
puting projects such as the Search for Extraterrestrial Intelligence (SETI) [setiath-
ome.ssl.berkeley.edu, IOJ and distributed.net [distributed.net, 33J. These are
projects that parcel out large-scale computing to workstations on Internet hosts,
making use of surplus CPU cycles, as described in the sidebar. (Note: Further dis-
cussion of this type of computing is not within the scope of this book.)
1.4 The Strengths and Weaknesses of -
Distributed Computing
Prior to the appearance of the World Wide Web, monolithic computing, such as
business applications running on a mainframe computer, or a single user using
a personal computer to perform word processing or spreadsheet functions, was
the dominant form of computing. Thomas Watson, the founder of IBM, was
said to have made the following statement in 1943: "I think there is a world
market for maybe five computers." Since the 1980s, however, distributed com-
puting has become as important as-if not more importailt than-monolithic
computing.
There are a number of reasons for the popularity of distributed computing:
The affordability of computers and availability of network access. Today's
personal computer has computing power superior to that of the mainframe
computers of the early days, at a fraction of the size and the cost. Coupled
with the fact that connectivity to the Internet has become universally avail-
able and generally affordable, the large number of interconnected computers
makes for an ideal community for distributed computing.
Resource sharing. The architecture of distributed computing mirrors the
computing architecture of modern organizations. Each organjzation inde-
pendently maintains computers and resources that are local to the organiza-
tion while sharing resources over the network. Using distributed computing,
organizations can pool their resources very effectively. The Web, for example,
is a powerful platform for sharing documents and other resources within and
among organizations.
Scalabiljty. With monolithic computing, the available resources are limited
to the capacity of one computer. By contrast, distributed computing provides
scalability in that increasing demand for resources can be addressed effec-
lively with additional resources. For example, more computers providing a
service such as email can be added to the network to satisfy an increase in the
demand for that service.
Fault tolerance. Compared to monolithic computing, distributed computing
provides the opportunity for fault tolerance in that a resource can be repli-
1.4 The Strengths and Weaknesses of Distributed Computing 29
cated (or mirrored) to sustain its availability in the presence of failures. For
example, backup copies of a database can be maintained on different systems
on the network, so that when one system fails, other copies can be accessed
without disrupting the service. Although it is not possible to build a distrib-
uted system that is completely reliable in the presence of failures [Fischer,
Lynch, and Paterson, 30j, it is the responsibility of a developer, when design-
ing and implementing such a system, to maximize its fault tolerance. Fault
tolerance in distributed computing is a complex topic that has received
extensive attention in the research community. Interested readers may want
to refer to sources such as the work of Pankaj Jalote Ualote, 31].
In any form of computing, there is always a trade-off between advantages and
disadvantages. The advantages already mentioned are offset by disadvantages.
Some of the most significant ones are:
Multiple points of failure. There are more points of failure in distributed
computing. Since multiple computers are involved, all of which depend on
the network for communication, the failure of one or more computers, or
one or more network links, can spell trouble for a distributed computing sys-
tem. There is a popular quote, attributed to noted computer scientist Leslie
Lamport, which says that "a distributed system is one in which the failure of
a computer you didn't even know existed can render your own computer
unusable."
Security concerns. In a distributed system, there are more opportunities for
unauthorized attack. Whereas in a centralized system all the computers and
resources are typically under the control of a single administration, in a dis-
tributed system management is decentralized, often involving a large l1um-
ber of independent organizations. The decentralization makes it difficult to
implement and enforce security policies; hence distributed computing is vul-
nerable to security breaches and unauthorized access, which unfortunately
can affect all participants on the system. This problem is clearly illustrated by
wellknown attacks on tht: Internet, such 35 worms and viruses [Eichen and
Rochlis, 21; Zetter, 221.
Because of its importance, computer security is a widely researched and
studied topic, and successful techniques have been developed for writing and
deploying secure applications. Such techniques include encryption, keys,
certificates, digital Signatures, sandboxes, authentication, and authorization.
Security is a broad topic that is beyond the scope of this book. Readers are
encouraged to pursue the topiC in references such as lOaks, 321.
Now that we have clarified the objective of this book, let's next look at some of
the basic concepts in three related disciplines in computer science: operating
systems, networks, and software engineering. Although no in-depth knowledge
of these disciplines is required as a prerequisite for this course, this book does
refer to some concepts. and terminologies associated with these disciplines. In
the rest of this chapter we will introduce these concepts and terminologies,
30 CHAPTER 1 Distributed Computing, An Introduction
WEB ATTACKS MIGHT HAVE MANY SOURCES
by Matt Richtel and Sara Robinson (NYT), Feb. 11, 2000
(reprinted with permission of the New York Times)
SAN FRANCISCO, Feb. 1o-Computer
security experts said today that evidence
now suggests that the three days of attacks
on leading Web sites may have been the
work of more than one person or group.
The analysis that more than one group
was at work called into question the con-
clusion of some security experts who were
initially skeptical that following Monday's
attack on Yahoo, multiple vandals would
have been able to muster large "copy cat"
assaults on other sites.
And while the Internet community
searched aggressively for leads, computer
experts said that it would.be difficult even
to determine which computers initiated
the attacks, let alone find the responsible
parties.
CERT, a federally financed computer
security organization formerly known as
the Computer Emergency Response
Team, said today that it was no longer
seeing an unusual number of reports of
attacks. From Monday through
Wednesday, service on several leading
Web sites, including those of the Yahoo
portal, the PTrade Group brokerage firm,
the eBay auction company and Time
Warner's CNN.com news site, were d i s ~
rupted and in some cases halted by
assaults involving dozens or more com-
puters flooding them with data feeds.
But security experts said that Web sites
and the Internet in general would remain
vulnerable for the near future because so
many organizations were failing to take
steps to prevent their computers from
being used by vandals to initiate the
attacks.
One government official said today
that tougher laws might be necessary to
combat such attacks. 'We don't consider
this a prank," Deputy Attorney General
Eric Holder said. "These are very serious
matters."
Also today, it was disclosed that more
major Web sites than had been previously
known were hit on Wednesday, the last
day of the assaults. Those included
Excite@Home, a provider of high-speed
access over cable modems, which was
attacked early Wednesday evening despite
having taken precautions to defend its
network.
At least two other major e-commerce
companies were hit with attacks on
Wednesday, according to IFsec, a com-
puter security firm in New York, though it
declined to name the companies, saying
that one of them was a client.
'We're seeing more of these than have
appeared in the popular media," said
David M. Remnitz, the chief executive of
IFsec.
In addition, users of Intemet Relay
Chat, or J.R.C., said that the forum had
been under irotense fire in the last two
weeks by attacks similar to those levied at
the e-commerce companies.
Meanwhile, network service providers
and investigators continued analyzing evi-
dence, including the packets of data that
had been used to overwhelm and paralyze
the victim sites.
Computer security experts at Stanford
University in Palo Alto, Calif., said that the
preliminary evidence suggested the
attacks might have been the work of more
than one person or group.
David J. Brumley, assistant computer
security officer for Stanford, said the
type of data included in the packets
1.4 The Strengths and Weaknesses of Distributed Computing 31
I
I
used to attack Yahoo on Monday differed
from the data in the Tuesday assault on
eBay.
"The attacks were just completely dif-
ferent between those two days," Mr.
Brumley said. "The people who did Yahoo
are different than the people who did
eBay and CNN."
Network service providers said that the
recent assaults included two types of
attacks, further suggesting that more tnan
one party may have been involved. Both
are what are known as denial of service
attacks because they prevent the targeted
site from serving its customers.
In the first, known as a SYN flood,
attackers hack into-and install software
on-a large number of computers, then
use those machines to bombard the vic-
tim site with requests to start an e<orn-
meree session. The large number of
requests overwhelms the victim's servers,
preventing customers from gaining access
to the site.
To prevent any tracing of these
requests, the vandals employ a practice
called spoofing, which alters the initiating
address.
The second type, known as a smurf
attack, again involves the use of compro-
mised machines, but it also employs a
large third-party network of computers to
"amplify" the data used in the attack and
greatly increases the effectiveness of the
assault It is believed that Stanford's net-
work of computers may have been used in
this way in the attack on Yahoo.
Security experts say it is simple to con-
figure networks so they cannot be used in
a smurf attack, yet many sites do not
know to take these steps.
Computer security experts noted that
the large numbers of computers used to
initiate the attacks this week made tracing
those attacks very difficuit.
At this point, there's been so much
traffic thrown at these people that it's
pretty hard to do a trace: said Joel de la
Garza of the Kroll-O'Gara Information
Security Group, a risk mitigation company.
Moreover, companies whose comput-
ers are hijacked and then used as plat-
forms for an assault often have no idea of
the probiem, even as the assault is going
on, computer security experts said.
Vandals can activate the assault from a
remote location, and to a company or an
individual whose computer is being used;
the only impact may appear to be a slow-
down in the activity of the network.
Victim companies and security experts
said today that in some cases the attacks
seemed more complicated than originally
thought-reinforcing how difficult they
are to prevent.
Excite@Home, for example, said it
sought to take precautionary measures in
light of the earlier attacks but was still
unable to keep its Web site from being
crippled for at least h a ~ an hour.
"To the best of our knowledge, a site
cannot take preventative measures
against ~ h e attacks without the help of
others," said Kelly Distefano, an
Excite@Home spokeswoman. She said the
company would have needed more coop-
eration from the companies that provide
Excite network services.
Peter Neumann, principal scientist at
SRI International in Menlo P.rk, Calff., reit-
erated that the success of the attacks had
shown that Internet sites were not taking
adequate precautions to prevent them-
selves from being used for attacks.
Hit's time people woke up, H Mr.
"'eumann said. "People are racing to do
electronic commerce on the Net without
any understanding of the risks-and there
are much greater risks than we've seen
here."
32 CHAPTER 1 Distributed Computing, An Introduction
1.5 Basics of Operating Systems
Distributed computing involves programs running on multiple computers. Let's
look at some of the concepts involved with the execution of programs in mod-
ern-day computers.
Computer Programs and Processes
A software program is an artifact constructed by a software developer using
some form of programming language. Typically, the language is a high-level one
that requires a compiler or an interpreter to translate it into machine language.
When a program is "run," or executed, on a computer, it is represented as a
process. On modern computers, a process consists of an executing program, its
current values, state information, and the resources used by the operating sys-
tem to manage the execution of the program. In other words, a process is a
dynamic entity that exists only when a program is run.
Figure 1.4 illustrates the state transitions during the lifetime of a process. A
process enters a ready state when a program is at the start of its execution, when
it is placed in a queue by the operating system, along with other programs that
are to be executed. When system resources (such as the CPU) are available for
its actual execution, the process is dispatched, at which point it enters the run-
ning state. It continues to execute until the process must wait for the occurrence
of an event (such as the completion of some input/output operation), at which
time it enters a blocked state. Once the anticipated event occurs, the process will
be placed on the execution queue and await its turn to execute once again. The
process repeats the ready-running-blocked cycle for as many times as necessary
until the execution of the process is completed, at which time the process is said
to be terminated.
In this book, we will use Java programs, or fragments of them, as code examples.
There are three types of Java programs: applications (Figure 1.5), applets (Figure
1.6), and servlets (Figure 1.7). Regardless of which type of program you are writ-
ing, each one is written as a Java class. AJava application program has a main
start
Queued
ready
terminated
Exit
running
Event completion
blocked
Waiting
for event
Figure 1.4 Asimplified state transition diagram of a process.
1.5 Basics of Operating Systems 33
method, and it is run as an independent (stand-alone) process. On the other
hand, an applet does not have a main method, and it is run using a browser or
the appletviewer. Aservlet is similar to an applet in that it does not have a main
method, and it is run in the context of a Web server. We will have occasion to
see examples of all three types of programs and program fragments in this book,
with applications being the form of programs most frequently employed.
AJava program is compiled into bytecode, a universal object code. When run,
bytecode is translated by the Java Virtual Machine GYM) to the machine code
native to the computer, following the state transitions that we have studied ear-
A standalone Java application is run on a local machine.
Computer
-
~ .
lava object
Java Virtual Machine
/ ~ ***.*.* *** * ***** *
.. A sample of a simple Java applic&tion .
.. H. Liu 1/8/02
*.****.*.* * * * *.*.*~ *******.**/
import java.ie.;
class MyProgram{
public static void main(Stringl J ergs)
throws IOException{
BufferedReader keyboard - new
BuferedReader(new InputStreamReader(Syst8m.in;
String theName;
System.out.println(MWhat is your name?-);
theName - keyboard.readLine( );
System.out.print(-Hello - + theName);
System.out.println(- - welcome to CSC369.\n-):
II end main
Ilend class
Figure 1.5 Astand-alone lava application (top) and the code that activates it (bottom).
34 CHAPTER 1 Distributed Computing, An Introduction
An appJet is an object downloaded (transferred) from a remote machine
and then run on a local machine.
..
,
I ~ .
An applet
I ~
-
.
.. : I ~
-
0
A sample of a simple applet .
H. Liu 1/8/02
import java.applet.Applet;
import java.awt.*;
public class MyApplet extends Applet{
public void paint(Graphics g){
setBackground(Color.blue)i
Font Claude = new Pont(-Arial-, Font.BOLD, 40);
q.setFont(Claude);
q.setColor(Color.yellow)i
q.drawString(*Hello Worldl*, 100, 100);
II end paint
fiend class
<1-- A web page which, when browsed, will run>
<1-- the MyApplet applet>
<1-- M. Liu 1/8/02>
<title>SampleApplet</title>
<hr>
<applet code=-MyApplet.class width-SOD heightE500>
</applet>
<hr>
<a h r e f - ~ Hello.java->The source.</a>
Java object
Java Virtual
Machine
Figure 1.6 An applet (top) and the Web page (bottom) that activates it.
1.S Basics of Operating Systems 3S
Aservlet is an object that runs on a remote machine and interacts
with a local process using a request-response protocol.
Aservlet
Request
I ~ = ~ ~ : ; : : : ' ; : : ; : : ; : : ~ = = ~ ---+- Aprocess
Response
, ***** **
* A sample of a simple Java aervlet .
M. Liu 1/8/02
import java.lo.-;
import java. text.:
import java.util.-;
import javax.servlet.*i
import javax.servlet.http.*;
public class HyServlet extends HttpServlet {
public void doGet (HttpServletRequest request,
BttpServletResponse response)
throws ServletException, IOException (
PrintWriter out;
String title ~ -HyServlet Output-;
Ilset content type and other response header
Ilfiel.da first
response.setContentTypeC-text/html-);
Ilthen write the data of the response
out - response.getWriter():
out.println("<HTHL><HEAD><TITLE>");
out.println(title):
out.println("</TITLE></HEAD><BODY>");
out.println("<Bl>" + title + "<lSi>"):
out.printlnC"<P>Hello Worldl"):
out.printlnc"</BODY></HTKL>");
out.close( );
} Ilend doGet
/lend class
Figure 1.7 Aservlet (top) and the code that activates it (bottom).
36 CHAPTER 1 Distributed Computing, An Introduction
Iier. Because the bytecode is an intermediate code that is the same regardless of
machine types and is translated to the specific machine code at run time, Java
programs are therefore said to be platform-independent, meaning that the
same program can be run on any machine type that supports the ]VM.
In this book, it is assumed that you have knowledge of basic]ava programming,
to the extent that you can compile and execute a stand-alone application or
applet. A stand-alone program is one that executes on its own, without
exchanging messages with another program.
Concurrent Programming
Distributed computing ;nvolves concurrent programming, which is program-
ming that involves the simultaneous execution of processes. In the following
paragraphs we look at three kinds of concurrent programming.
Concurrent processes executed on multiple computers. Much of the mate-
rial in this book deals with separate processes running concurrently on sepa-
rate, independent computers interconnected via a network. The processes
interact with each other by exchanging data over the network, but their exe-
cution is otherwise completely independent. When you access a Web page
using a browser, a process of the browser program, running on your machine,
interacts with a process running on the Web server machine.
Concurrent programming involVing multiple machines requires program-
ming support; that is, the software for the participating program must be
written to contain logic to support the interaction between processes. How
this logic can be expressed in the programs is a main theme of this book.
Concurrent processes executed on a single conlputer. Modern computers
are supported by multitasking operating systems, which allow multiple tasks,
or processes, to be executed concurrently. The concurrency may be real or vir-
tual. True concurrent multitasking on a single computer is feasible only if the
computer has multiple CPUs, so that each CPU can execute a separate
process. On a computer that has only one CPU, timesharing (see Figure 1.8),
or time-slicing, is used to allow processes to take turns being executed, creat-
ing the illusion that they are being executed in parallel.
Processes
PI
P2
P3
P4
Time
Timesharing of a resource
Figure 1.8 Timesharing on a computer.
1.5 Basics of Operating Systems 37
Since multitasking is a functionality of the operating system, no pro-
gramming is needed for this type of concurrent programming. No special
software logic needs to be contained in a program to initiate multitasking.
Concurrent programming in a process. In addition to concurrent pro-
gramming in separate processes, it is often necessary for a single program to
initiate tasks that are to be executed concurrently. For example, it may be
necessary for a program to perform other tasks while waiting indefinitely for
user input in one user interface window. It may also be desirable for a pro-
gram to execute tasks in parallel, for performance reasons. Concurrent pro-
gramming within a process is performed using two types of facilities
provided by the operating system.
Parent and Child Processes
At run time, a process may spawn subordinate processes, or child processes.
Through real or virtual multitasking, the original process, called the parent
process, continues to run simultaneously with the child processes (see Figure
1.9). Achild process is a complete process, consisting of an executing program,
its own current values, and state information, some of which is inherited from
the parent process. A parent process can be notified when a child process has
terminated.
A parent process may spawn child processes. A process may spawn child threads.
Parent process
Child processes
Child thread 1
Aprocess
Child thread 2
(0) (b)
Figure 1.9 Concurrent processing within a process.
Threads
In lieu of child processes, a process may spawn threads, also known as light-
weight processes. Threads carry a minimum of state information, but other-
wise behave the same as processes. Since they incur less overhead, threads are
preferred over child processes.
38 CHAPTER 1 Distributed Computing, An Introduction
The spawning and coordination of child threads requires programming support.
The software for the program must be written to contain logic to support the
spawning of the threads and to coordinate, or synchronize, the execution of the
family of threads spawned by the parent thread.
The concurrent execution of threads may result in a race condition. A race con-
dition occurs when a series of commands in a program are executed in parallel,
in an arbitrarily interleaved fashion, yielding nondeterministic execution out-
come. Figure 1.10 illustrates such a situation. Suppose counter is a variable shared
among two concurrent threads. Execution sequence 1, in which the instructions
of the two processes are executed serially, will result in the counter value being
incremented to 2. On the other hand, in execution sequence 2, in which the two
sets of instructions are interleaved, the counter will only be incremented to 1.
Race conditions can be avoided if mutual exclusion is proVided to a code seg-
mentto ensure that the commands in the segment can only be executed by one
thread at a time. Such a code segment is called a critical region. For our exam-
ple, the critical region comprises the code where the counter variable is accessed
and incremented.
Programming using threads is called multi-threaded programming, or
threaded programming for short. A multi-threaded program that is written to
guard against race conditions is said to be thread-safe. The development of a
complex thread-safe program reqUires advanced programming skills.
Time
fetch value in counter and load into a register I
increment value in register
store value in register to counter
fetch value in counter and load into a register
increment value in register
store value in register to counter
This execution results in the
value 2 in the counter.
fetch value in counter and load into a register
fetch value in counter and load into a register
1 in_c_'e_rn_en_t_v_a_lu_e_i_n_
r
..c e9oc
i
_'t_e_'----
1 in_c_'e_rn_en_t_v_a_lu_e_i_n_'_eg ..i_'I_e_' _
1 '_to_r_e_v_al_u_e_in_'e..o9c-is_te_,_t_o_c_o_u_n_te_r _
1__....;s;.;to;;,';.;e..v..;a;.;lu;.;e..i.. ..t;.;o..c;.;o;.;u.. n;.;te;.;' _
This execution results in the
value 1 in the counter.
Instruction executed in concurrent process or thread 1
Instruction executed in concurrent process or thread 2
Figure 1.10 A race condition ,esulting from unsynchronized concurrent processes or threads.
1.5 Basics of Operating Systems 39
Fortunately, in this book we will seldom have to use threads explicitly, as
threaded programming is nften provided behind the scenes by the toolkits that
support network applications. .
Java Threads
The Java Virtual Machine enables an application to have multiple threads of
execution running concurrently. When a Java Virtual Machine starts up, there
is usually a single thread (although in some systems a program may start with
more than one thread) that typically calls the method named main of some des-
ignated class, such as the class of an application that you wrote. Additional
threads can be spawned from an active thread, and each thread will run inde-
pendently and in parallel with other threads until it terminates.
To support threading in a program, Java provides a class named Thread as well
as an interface named Runnable interface.
From within a Java program, there are two ways to create a new thread of exe-
cution:
1. Declare a class to be a subclass of Thread. This subclass should override the
run method of class Thread. When an instance of the subclass is allocated
and started, the code in the run method is executed concurrently with the
main thread.
2. Declare a class that implements the Runnable interface. That class implements
the TUn method of the interface. When an instance of the class is allocated
and started, the code in the TUn method is executed concurrently with the
main thread.
Figure 1.11 iilustrates the use of the first means of creating a new thread of exe-
cution, while Figure 1.12 iilustrates the use of the second way.
pUblic claas RunTbreds
{
public static void main (String{J Args)
{
SomeThread pI z new SomeThread(l);
pLstart( );
SomeThread p2 new SomeThread(2);
p2.staxt() ;
SomeThread p3 = new SomeThread(3);
p3.start()i
}
}/I end c l a ~ B RunThrd.
public class SomeThread extends Thread {
lnt myID;
SomeThread(int id)
this.myID "" idi
public void rune) {
int ii
for (1 - 1; i < 11; i++)
system.out.println
("Thread"+ myID + ": .. + i) i
}
fiend elass SomeThread
Figure 1.11 Sample application that spawns three threads using a subclass of the
Thread class.
40 CHAPTER 1 Distributed Computing, An Introduction
public class RunTbread.2
{
public static void main (Strinq(J ergs)
{
Thread pi - new Thread(new
SomeThread2 ( 1) ) ;
pl. start() ;
Thread p2 - new Thread(new
SomeThread2(2;
p2.8tart();
Thread pJ - new Thread(new
SomeThread2(3;
p3.8tart() ;
}
} fiend class RunTbre.d2
class sc.eftread2 implements RUDable {
int myID;
8a.eTbrd2(int id) (
this .myID - idi
}
public vd'id ruo() {
int i;
for (1 - 1; i < 11; i++)
System.aut.println
+ ": .. + i);
}
Ilend class sa.eTbread2
Figure 1.12 Sample application that spawns three threads using an implementation of the
Runnable interface.
In java, the most straightforward way to guard against race conditions is by
using synchronized static methods. A static method with the reserved word
synchronized appearing in its signature can be executed by only one thread at a
time. Hence the code in a synchronized static method is guaranteed to be mutu-
ally exclusive. For the example shown in Figure 1.10, the code for incrementing
the counter variable should be enclosed in a synchronized static method so that
the increments to the counter can only be made by one thread at a time. Ajava
code sample iJIustraiing the USe of threads and a synchronized static method
can be found in Exercise 2(d.) at the end of this chapter.
In subsequent chapters, we will use the terms process and thread frequently. If
you are not familiar with threading, there are some exercises at the end of this
chapter that allow you to practice threading using java programming.
1.6 Network Basics
Having looked at some key concepts in operating systems that are relevant to
distributed computing, next we will do the same with network basics.
Protocols
In the context of communications, a protocol is a set of rules that must be
observed by participants. In a face-to-face meeting, human beings instinctively
follow an unspoken protocol based on eye contact, body language, and gestures.
This protocol stipulates that only one person speaks at a time while the others
listen. In a phone conversation, one party initiates the call, and then, after the
call is answered, the parties at the two ends take turns speaking, using pauses or
1.6 Network Basics 41
questions to signify when it is the other party's turn to talk.
In communications involving computers, protocols must be formally defined
and precisely implemented. For each protocol, there must be rules that specify
the following:
How is the data exchange encoded?
How are events (sending, receiving) synchronized (ordered) so that the par-
ticipants can send and receive in a coordinated manner?
The concept of protocols will become more concrete when we study a number
of protocols in the rest of this book.
It should be emphasized that a protocol is a set of rules. The specification of a
protocol does not dictate how the rules are to be implemented. For example,
Hypertext Transfer Protocol (HTTP) specifies the rules that must be observed
between a Web browser process and a Web server process. Any Web server pro-
gram written in conformance to these rules satisfies the protocol, regardless of
what programming language or syntax is employed. Therefore, you should
understand that a protocol (such as HTTP) is distinct from its implementations
(such as the varieties of Web browsers, including Netscape and Internet
Explorer).
As an analogy, the rules for a sport, say basketball, are specified by some author-
ity, say the National Basketball Association (NBA), but it is up to each individ-
ual team and then each player to execute or implement the game while
observing those rules.
Network Architecture
In the textbooks for data networks, the functionalities of a network are fre-
quently presented using a network architecture (Figure 1.13). The classic net-
work architecture, called the Open System Interconnect (051) architecture,
divides the complex functionalities of a network into seven layers. All or part of
these functionalities must be present on a computer that participates in data
communication and hence also in distributed computing. If you are interested
in the specifics of the 051 model, you should be able to find them in textbooks
on networks such as ITanenbaum, 351. For the purposes of this book, a simpli-
fied architecture that IS appropriate for the Internet will be presented.
The network architecture for the Internet is illustrated in Figure 1.1-1, where
there are four layers: physical, Internet, transport, and application. The physi-
cal layer provides the functionalities for the transmission of signals, represent-
ing a stream of data, from one computer to another. The Internet layer allows
a packet of data to be addressed to a remote computer and delivered to that
computer. The transport layer proVides the functionalities for data packets to
be delivered to a specific process running on a remote computer. Finally, the
application layer allows messages to be exchanged between programs in sup-
port of an application such as the World Wide Web.
The syntax of a pro-
gramming language is
the set of language
rules, including spelling
and grammar, of the
language.
OSI stands for Open
System Interconnect,
the name given to a
model of network archi-
tecture promoted by an
organization called the
International
Organization for
Standardization (ISO).
42 CHAPTER 1 Distributed Computing, An Introduction
Application layer - --- - ---..
________ 4_ ......
Application layer~ . ,
!
Presentation layer Presentation layer
Session layer Session layer
Transport layer Transport layer
Network layer Network layer
Data link layer Data link layer
.. Physical layer
Physical layer