0% found this document useful (0 votes)
2 views

Introduction to Distributed Systems

The document provides an introduction to distributed systems, detailing their definition, goals, challenges, and types. It emphasizes the advantages of distributed systems, such as scalability and resource sharing, while also discussing the evolution of technology that enables them. Key components and transmission methods are also outlined, highlighting the importance of communication and coordination among independent computers in a network.

Uploaded by

Chalachew Mulu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Introduction to Distributed Systems

The document provides an introduction to distributed systems, detailing their definition, goals, challenges, and types. It emphasizes the advantages of distributed systems, such as scalability and resource sharing, while also discussing the evolution of technology that enables them. Key components and transmission methods are also outlined, highlighting the importance of communication and coordination among independent computers in a network.

Uploaded by

Chalachew Mulu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 155

INTRODUCTION TO DISTRIBUTED SYSTEMS

Why build a Distributed Systems?


There are a lot of advantages, including :
1. The ability to connect remote users with
remote resources in an open and scalable way.
2. Load Sharing
Chapter One: Introduction To Distributed Systems

Unit Contents
– Introduction to distributed System
– Definition of Distributed System
– Goals of a Distributed System
– Challenges of Distributed Systems
– Types of DSs
1.1. Introduction to Distributed System

Evolution of Distributed System


Computer systems are undergoing a revolution.
From 1945, when the modern computer era
began, until about 1985, computers were large
and expensive.
Starting in the mid-1980s, however, two
advances in technology began to change that
situation.
The first was the development of powerful
microprocessors.
Conti…
• Initially, these were 8-bit machines, but soon 16-,
32-, and even 64-bit CPUs became common.
The second development was the invention of
high-speed computer networks.
• The local area networks or LANs allow dozens, or
even hundreds, of machines within a building to
be connected in such a way that small amounts
of information can be transferred between
machines in a millisecond.
Conti…
• Larger amounts of data can be moved
between machines at rates of 10 to 100
million bits/sec and sometimes more.
• The wide area networks or WANs allow
millions of machines all over the earth to be
connected at speeds varying from 64 Kbps
(kilobits per second) to gigabits per second for
some advanced experimental networks.
1.2. Definition of Distributed System

• Distributed computing is a field of computer science


that studies distributed systems. Distributed
computing also refers to the use of distributed
systems to solve computational problems.
• A distributed system is a model in which components
located on networked computers communicate and
coordinate their actions by passing messages.
• The components interact with each other in order to
achieve a common goal.
• It is a computer system consisting of several
independent computers, connected by a network, that
can work together to perform a task or provide a
service.
Conti…
• It is a collection of independent computers that appear to
its users as a single coherent system.
• Typical examples include:
• The World Wide Web,
• Networked file systems,
• DNS, and
• Massive Multiprocessor Supercomputers.
• face book
• It consists of multiple computers that do not share
memory, storage or cpu.
• Because Each Computer has its own memory and runs its
own operating system. The computers can communicate
with each other through a communication network.
1.3. Goals of a Distributed System

The following are very important goals that should


be met for an efficient distributed system.
• Heterogeneity.
• Openness.
• Security.
• Connecting Users and Resources
• Scalability.
• Failure Handling.
• Concurrency.
• Transparency.
Conti…
1.Heterogeneity: The Internet enables users to access services
and run applications over a heterogeneous collection of
computers and networks.
Variations and differences that must be handled:
Network – The Internet-protocol is implemented over many
different networks
Hardware – difference in representation of data types on
different processors
Operating System – API to the same protocol and services
Varies Programming Languages – different representation of
character set and data structures implementation by different
developers.
– ensure that different programs can communicate
• requires agreement on a number of things (cf. standards)
Conti…
2. Openness: is an important goal of distributed
system in which it offers services according to
standard rules that describe the syntax and
semantics of those services.
• Open distributed system must be flexible
making it easy to configure and add new
components without affecting existing
components.
• Each component is continually open to
interaction with other components.
Conti…
3. Security :Distributed systems should allow
communication between programs/users/
resources on different computers by enforcing
necessary security arrangements.
• The security features are mainly intended to
provide confidentiality, integrity and availability.
• Confidentiality (Secrecy & privacy) is protection
against disclosure to unauthorised person.
• Integrity: provides protection against alteration
and corruption.
• Availability keeps the resource accessible at any
time and place.
Conti…
4. Scalability: At least three components:
Scalability is one of the most important goals which
are measured along three different dimensions.
• First, a system can be scalable with respect to its
size which can add more user and resources to a
system.- size scalability
• Second, users and resources can be geographically
apart- (geographical scalability).
• Third, it is possible to manage even if many
administrative organizations are spanned.-Number
of administrative domains (administrative
scalability)
Conti…
5. Connecting Remote Users with Remote Resources
• The main goal of a distributed system is to make
it easy for users to access remote resources and
to share them with others in a controlled way.
• It is cheaper to let a printer be shared by several
users than buying and maintaining printers for
each user.
• Collaborating and exchanging information can be
made easier by connecting users and resource.
Conti…
6. Transparency:
• A distributed system needs to hide the
location of its processes and resources even
though physically distributed across multiple
computers.
• The various transparencies need to be
considered are access, location, migration,
relocation, replication, concurrency, failure
and persistence.
• Aiming for distributed transparency should be
considered along with performance issues.
Conti…

Transparency Description
Access Hide differences in data representation and how a resource is
accessed

Location Hide where a resource is located


Migration Hide that a resource may move to another location
Relocation Hide that a resource may be moved to another location while
in use
Replication Hide that a resource is replicated(Copying) ata different places.
Concurrency Hide that a resource may be shared by several competitive
users.
Failure Hide the failure and recovery of a resource
Conti…
8. Failure Handling
•This means that components that are prone to defects are
replicated in such a way that if a component fails, one or more
of the non-failed replicas will continue to provide service with
no appreciable disruption.
•Failure may be:
Hardware, software and network fail!!
DS must maintain availability even in cases where
hardware/software/network have low reliability.
Many Techniques for handling failures
 Detecting failures (checksum)
Tolerating failures
Recovery from failures
 Redundancy (replicate servers in failure-independent ways)
Conti…
9. Concurrency: Users and Applications should be
able to access shared data or objects without
interference between each other. =>
Concurrency Control
• Shared Resources should be Synchronized.
• A database is a set of data which deals with
organizational activities.
• DDB is a scheme that allows decentralization for the
management of data through same or common
language. Concurrency control deals with the issues in
coordinating concurrent accesses to a database in a
multi-user fashion.
Conti…
• Locking is a method used to control concurrent
access to data. A lock is a variable having data
items associated with it. It is a status of the
item and it tells about all operations that are
possibly applicable on it. For each item in
database one lock is available.
• Locks are used as a means of synchronizing the
access by concurrent transactions to the
database item. The most common algorithms
that offer concurrency manipulation or controls
are two phase locking(2PL), Times-tamping.
Conti…
• 2pl: Shared and Exclusive locks
• Write-lock (exclusive lock) is associated with a
database object by a transaction (Terminology:
"the transaction locks the object," or "acquires
lock for it")
before writing (inserting/modifying/deleting)
this object.
•Read-lock (shared lock) is associated with a
database object by a transaction
before reading (retrieving the state of) this
object.
Conti…
•Serializability: Ideally, transactions should
be serializable.
• Transactions are said to be serializable if the results of
running transactions simultaneously are the same as
the results of running them serially— that is, one after
the other. It is the classical concurrency scheme. It
ensures that a schedule for executing concurrent
transactions is equivalent to one that executes the
transactions serially in some order.
•A transaction in a database system must maintain
Atomicity, Consistency, Isolation, and Durability −
commonly known as ACID properties − in order to
ensure accuracy of a transaction.
1.4. Challenges of Distributed Systems
The major challenges in distributed systems are
listed below:
• Heterogeneity:
• Transparency:
• Openness.
• Concurrency.
• Security.
• Scalability.
• Partial Failure
• Privacy
1.5. Types of DS
1)Distributed processing: is a technique for implementing a
single logical set of processing functions across a number of
physical devices, so that each performs some part of the total
processing required.
2)A distributed application is software that is executed or run
on multiple computers within a network.
•These applications interact in order to achieve a specific goal
or task. Traditional applications relied on a single system to
run them.
1)A distributed file system (DFS): is a file system with data
stored on a server. The data is accessed and processed as if it
was stored on the local client machine. The DFS makes it
convenient to share information and files among users on a
network in a controlled and authorized way.
1.5. Types of DS
•A distributed operating system: is a software
over a collection of independent, networked,
communicating, and physically separate
computational nodes. Each individual node holds
a specific software subset of the global
aggregate operating system. Each subset is a
composite of two distinct service provisioners.
1)Distributed Computing Systems: Used for high
performance computing tasks
•Cluster computing systems
•Grid computing systems
Conti…
1)Distributed Information Systems: Systems mainly used for
management and integration of business functions.
• Transaction processing systems
• Enterprise Application Integration
1)Distributed Pervasive Systems or Ubiquitous computing: is a
concept in software engineering and computer science
where computing is made to appear anytime and everywhere.
•Mobile and embedded systems
•Automated Home systems
•Sensor networks
1)Cloud Computing is an information Technology(IT) paradigm that
enables ubiquitous access to shared pools of configurable system
resources and higher-level services that can be
rapidly provisioned with minimal management effort, often over
the Internet.
•Loosely coupled systems
Conti…
Grid Computing Systems: grids are usually
consists of multiple computers sharing
information over the Internet, they are
composed of different types of computers
(hardware, OS, network, security, etc.) −loosely
coupled.
Conti…

1)Tightly coupled (clustered computers) —


refers typically to a set of highly integrated
machines that run the same process in parallel,
subdividing the task in parts that are made
individually by each one, and then put back
together to make the final result. Unlike grid
computers, computer clusters have
each node set to perform the same task,
controlled and scheduled by software. The
components of a cluster are usually connected
to each other through fast local area networks.
Conti…
• In most circumstances, all of the nodes use the
same hardware and the same operating system.
•Clusters are usually deployed to improve
performance and availability over that of a
single computer, while typically being much
more cost-effective than single computers of
comparable speed or availability.
Conti…
• Cluster differs from Cloud and Grid in that
a cluster is a group of computers connected
by a local area network (LAN), whereas cloud
and grid are more wide scale and can be
geographically distributed.
Multiprocessor Systems
• A multiprocessor system is simply a computer that has more than
one CPU on its motherboard or inside its own die. If the operating
system is built to take advantage of this, it can run different
processes on different CPUs, or different threads belonging to the
same process.
• Over the years, many different multiprocessing options have been
explored for use in distributed computing. CPUs can be connected
by bus or switch networks, use shared memory or their own private
RAM, or even a hybrid approach.
• These days, multiprocessor systems are available commercially for
end-users, and mainstream operating systems like Mac OS X,
Microsoft Windows and Linux already have built-in support for this.
Additionally, recent Intel CPUs have begun to employ a technology
called Hyper-threading that allows more than one thread (usually
two) to run on the same CPU. New Intel processors also feature
multiple processor cores to double the number of threads again.
Multicomputer Systems
• A multicomputer system is a system made up of several
independent computers interconnected by a telecommunications
network.
• Multicomputer systems can be homogeneous or heterogeneous:
A homogeneous distributed system is one where all CPUs are
similar and are connected by a single type of network. They are
often used for parallel computing which is a kind of distributed
computing where every computer is working on different parts of
a single problem.
• In contrast a heterogeneous distributed system is one that can be
made up of all sorts of different computers, eventually with vastly
differing memory sizes, processing power and even basic
underlying architecture. They are in widespread use today, with
many companies adopting this architecture due to the speed with
which hardware goes obsolete and the cost of upgrading a whole
system simultaneously.
Multicomputer Systems
• 3-tier architecture — Application servers usually store
data on a third machine, known as the database
server. This is called three-tier architecture whereas
generic client/server architecture is two-tier. Three
tier systems move the client intelligence to a middle
tier so that stateless clients can be used. This
simplifies application deployment. Most web
applications are 3-Tier.
• N-tier (Multi-Tier) architecture — N-Tier refers
typically to web applications which further forward
their requests to other enterprise services. This type
of application is the one most responsible for the
success of application servers.
1.6. Components or elements of DS
• A distributed system consists of hardware and
software components located in a network of
computers that communicate and coordinate
their actions only by passing messages.
• Hardware
• Software
• Users
• Data or Resources to be shared /accessed
• Network or communication link
•For synchronous data transfer, both the sender and
receiver access the data according to the same
clock.
•Synchronous(Full Duplex) Transmission is clock
pulse driven where as, Asynchronous Transmission
is event driven.
•Synchronous Transmission is efficient, reliable and
is used for transferring a large amount of data. It
provides real-time communication between
connected devices. Chat Rooms, Video
Conferencing, telephonic conversations, as well as
face to face interactions, are some of the examples
of Synchronous Transmission.
• In Asynchronous Transmission data flows in a
half duplex mode, 1 byte or a character at a
time. It transmits the data in a continuous
stream of bytes. In general, the size of a
character sent is 8 bits to which a parity bit is
added i.e. a start and a stop bit that gives the
total of 10 bits. It does not require a clock for
synchronization; rather it uses the parity bits to
tell the receiver how to interpret the data.
• It is simple, fast, economical and does not
require a 2-way communication. Letters,
emails, forums, televisions and radios are some
of the examples of Asynchronous Transmission.
• Key Differences Between Serial And Parallel Transmission
• Serial transmission requires a single line to communicate and
transfer data whereas, parallel transmission requires multiple lines.
• Serial transmission used for long distance communication whereas,
the parallel transmission used for shorter distance.
• Error and noise are least in serial as compared to parallel
transmission. Since one bit follows another in Serial Transmission
whereas, in Parallel Transmission multiple bits are sent together.
• Parallel transmission is faster as the data is transmitted using
multiples lines whereas, in Serial transmission data flows through a
single wire.
• Serial Transmission is full duplex as the sender can send as well as
receive the data whereas, Parallel Transmission is half duplex since
the data is either sent or received.
• Serial transmission cables are thinner, longer and economical in
comparison with the Parallel Transmission cables.
• Serial Transmission is reliable and straightforward whereas, Parallel
Transmission is unreliable and complicated.
Chapter Two: Distributed Systems Architecture
Outlines
 Architectural Styles: Important styles of architecture for
distributed systems.
Layered architectures
Object-based architectures
Data centered architectures
Event-based architectures
 System Architectures:
 Centralized architectures
 Application layering
 Multitier architectures
 Decentralized architectures
 Structured peer-to-peer
 Unstructured peer-to-peer
 Hybrid architectures
 Edge-server systems
 Collaborative distributed systems
Distributed Systems Organization
 It is now commonly accepted that designing
or adopting an architecture is crucial for the
successful development of large systems.
 The notion of an architectural style is
important. Such a style is formulated in
terms of components, the way that
components are connected(connectors) to
each other, the data exchanged between
components, and finally how these
elements are jointly configured into a
system.
 A component is a modular unit with well-
defined required and provided interfaces
that is replaceable within its environment.
 Software architectures: how various
software components are organized and
how they interact.
 System architecture: An instance of a
software architecture after deciding on the
software components, their interaction and
their placement.
For example, a connector can be formed by the
facilities for (remote) procedure calls, message
passing, or streaming data.
Using components and connectors, we can
come to various configurations, which, in turn
have been classified into architectural styles.
Several styles have by now been identified, of
which the most important ones for distributed
systems are:
1. Architectural Styles
• Formulated in terms of components, and the
way they are connected by connectors:
•A component is a modular unit with well-
defined interfaces; replaceable; reusable
•A connector is a communication link between
modules; mediates coordination or cooperation
among components.
• Four styles that are most important:
• Layered architecture
• Object-based architecture
• Data-centered architecture
• Event-based architecture
1.Layered architectures:
•The basic idea for the layered style is simple:
•Components are organized in a layered fashion
where a component at layer L; is allowed to call
components at the underlying layer Li.
•A key observation is that control generally flows
from layer to layer: requests go down the
hierarchy whereas the results flow upward.
2. Object-based architectures
•In this case components are objects, and these components
are connected through a (remote) procedure call mechanism.
•The layered and object-based architectures still form the most
important styles for large software systems.

•Object-based style for distributed object systems.


• It is less structured
component = object
connector = RPC or RMI or CORBA
3. Data-Centered (shared data space) architectures:
Data-centered architectures evolve around the idea
that processes communicate through a common
(passive or active) repository.
For example, a wealth of networked applications
have been developed that rely on a shared distributed
file system in which virtually all communication takes
place through files.
Likewise, Web-based distributed systems, are largely
data-centric: processes communicate through the use
of shared Web-based data services.
4. Event-Based Architectures:
In event-based architectures, processes essentially
communicate through the propagation of events.
For distributed systems, event propagation has generally been
associated with what are known as publish/subscribe systems.
The basic idea is that processes publish events after which the
middleware ensures that only those processes that subscribed to
those events will receive them. The main advantage of event-
based systems is that processes are loosely coupled.
In principle, they need not explicitly refer to each other. This is
also referred to as being decoupled in space.
•Publish-subscribe: publish–subscribe is
a messaging pattern where senders of messages,
called publishers, do not program the messages to
be sent directly to specific receivers, called
subscribers, but instead categorize published
messages into classes without knowledge of
which subscribers, if any, there may be. Similarly,
subscribers express interest in one or more classes
and only receive messages that are of interest,
without knowledge of which publishers, if any,
there are.
2. System Architectures
Distributed systems are actually organized by
considering where software components are
placed.
 Centralized architectures
 Application layering & Multitier architectures
 Decentralized architectures
 Structured peer-to-peer
 Unstructured peer-to-peer
 Hybrid architectures
 Edge-server systems
 Collaborative distributed systems
A. Centralized Architectures
A centralized architecture consists of a server and multiple
clients.
In the basic client-server(request-reply) model, processes in a
distributed system are divided into two (possibly overlapping)
groups.
 A server is a process or program that can receive a request,
process it and can send a response.
 For example a server implementing a specific service such as a
file system service or a database service.
 A client is a process that requests a service from a server by
sending it a request and subsequently waiting for a reply.
 Communication between server/clients:
 Connectionless protocol: UDP is an example. allows for packets of data
to be transmitted between applications.
 Connection-oriented protocol: TCP is the most common and Reliable .
A. Centralized Architectures

General interaction between a client and a server.


•Communication between a client and a server can
be implemented by means of a simple
connectionless protocol when the underlying
network is fairly reliable as in many local-area
networks.
• In these cases, when a client requests a service, it
simply packages a message for the server,
identifying the service it wants, along with the
necessary input data. The message is then sent to the
server. The latter, in turn, will always wait for an
incoming request, subsequently process it, and
package the results in a reply message that is then
sent to the client. Using a connectionless protocol
has the obvious advantage of being more efficient.
•As long as messages do not get lost or corrupted, the
request/reply protocol just sketched works fine.
•Unfortunately, making the protocol resistant to occasional
transmission failures is not trivial.
•The only thing we can do is possibly let the client resend
the request when no reply message comes in.
•The problem, however, is that the client cannot detect
whether the original request message was lost, or that
transmission of the reply failed.
•If the reply was lost, then resending a request
may result in performing the operation twice.
•As an alternative, many client-server systems use a
reliable connection-oriented protocol. Although this solution
is not entirely appropriate in a local-area network due to
relatively low performance, it works perfectly in wide-area
systems in which communication is inherently unreliable.
• For example, virtually all Internet application protocols are
based on reliable TCP/IP connections.
•In this case, whenever a client requests a service, it first
sets up a connection to the server before sending the
request.
•The server generally uses that same connection
to send the reply message, after which the connection is torn
down. The trouble is that setting up and tearing down a
connection is relatively costly, especially when
the request and reply messages are small.
1. Application Layering

•The client-server model has been subject to many


debates and controversies over the years.
• One of the main issues was how to draw a clear
distinction between a client and a server.
•Not surprisingly, there is often no clear distinction. For
example, a server for a distributed database may
continuously act as a client because it is forwarding
requests to different file servers responsible for
implementing the database tables. In such a case, the
database server itself essentially does no more than
process queries.
•However, considering that many client-server
applications are targeted toward supporting user access
to databases, many people have advocated a distinction
between the following three levels, essentially
following the layered architectural style we discussed
previously:
• Layers of architectural style:
 The user-interface level: Client
 The processing level: Client or Server :The processing level typically
contains the applications.

 The data level: Server. The data level manages the actual data
that is being acted on. This level is persistent, which implies data
is stored outside of an application. Typically a file system or
database but could also be a NoSQL store (like Hadoop) or an
object store.
The simplified organization of an Internet search engine into three
different layers (3-tier architecture).
•The simplest organization is to have only two types of machines:
1. A client machine containing only the programs implementing
(part of) the user-interface level.
• 2. A server machine containing the rest, that is the programs
implementing the processing and data level.
• In this organization everything is handled by the server while the
client is essentially no more than a dumb terminal, possibly with a
pretty graphical interface.
•There are many other possibilities, of which we explore some of
the more common ones in this section.
•One approach for organizing the clients and servers is to
distribute the programs in the application layers of the previous
section across different machines.
• As a first step, we make a distinction between only two kinds of
machines: client machines and server machines, leading to what is
also referred to as a (physically two-tier architecture).
• E.g.
• A
• B
• C: The front end can then check the correctness and consistency of
the form, and where necessary interact with the user & Word
processor
• D: For example, many banking applications run on an end-user's
machine where the user prepares transactions and such. Once
finished, the application contacts the data- base on the bank's
server and uploads the transactions for further processing.
• E: represents the situation where the client's local disk contains
part of the data. For example, when browsing the Web, a client
can gradually build a huge cache on local disk of most recent
inspected Web pages.
• D & E are more popular and preferable systems.
• A-c thin clients
• D & E fat clients
2. Multitier Architectures

The simplest organization is to have only two types of


machines:
A client machine containing only the programs
implementing (part of) the user-interface level
A server machine containing the rest,
 the programs implementing the processing and data level
Clients can be fat or thin clients. Servers can act as
clients as well, leading to a three-tier design.
An example of a server acting as client(3-tie
architecture).
2. Decentralized Architecture
 Multitier client-server architectures are a direct consequence of
dividing applications into a user-interface, processing components,
and a data level. The different tiers correspond directly with the
logical organization of applications.
 In many business environments, distributed processing is
equivalent to organizing a client-server application as a multitier
architecture.
We refer to this type of distribution as vertical distribution. The
characteristic feature of vertical distribution is that it is achieved
by placing logically different components on different machines.
The term is related to the concept of vertical fragmentation as
used in distributed relational databases, where it means that tables
are split column-wise, and subsequently distributed across
multiple machines.
 Again, from a system management perspective, having a vertical
distribution can help: Functions are logically and physically split
across multiple machines, where each machine is tailored or
assigned to a specific group of functions.
However, vertical distribution is only one way of organizing client-
server applications. In modem architectures, it is often the
distribution of the clients and the servers that counts, which we
refer to as horizontal distribution.
In this type of distribution, a client or server may be physically split
up into logically equivalent parts, but each part is operating on its
own share of the complete data set, thus balancing the load.
In this section we will take a look at a class of modern system
architectures that support horizontal distribution, known as peer-
to-peer systems.
1. Peer2peer: An architecture where there is no special
machine or machines that provide a service or manage
the network resources. Instead all responsibilities are
uniformly divided among all machines, known as peers.
Each node or instance of the program is both a "client"
and a "server" and each has equivalent responsibilities.
Hybrid Architecture
Two types:
Types of servers
• Server systems can be broadly categorized into two kinds:
– transaction servers which are widely used in relational database systems, and
– data servers, used in object-oriented database systems
• Also called query server systems or SQL server systems
– Clients send requests to the server
– Transactions are executed at the server
– Results are shipped back to the client.
Stateless vs. stateful server:
DSs Projects(part I) (2 weeks) 20%
1. file upload and download from local database server
2. file upload and download from lan computer
3. file attach/send to e-mail
4.data encryption and decryption
5. password reset through e-mail
PHP,JAVA,C#
Presentation Style or Content:
1.Aim
2. Description
3.Development Tools
3. Implementation strategies
4. Algorithms Used
5. Implementations
5-10 slides.
Peace Presentation(5%)
1) Structured peer-peer
2) Unstructured peer-peer
3) Super-peer
4) Hybrid architecture
 Edge-server systems
 Collaborative distributed systems

5) Self -Management In Distributed Systems


6) Architectures Versus Middleware
Chapter 3: Processes
Outline:
3.1. Introduction to Processes & Threads
3.2. Threads in Distributed Systems
3.3. Multithreading
3.3. Clients
3.4. Servers
3.5. Code Migration
Process Concept
• A process is an instance of a program in execution.
• Process is
– An asynchronous activity, i.e. Only single process is get
service at a time.
– The entity to which processors are assigned.
– The 'dispatchable' unit.
• Process is not the same as program. it is more than a program
code.
• A process is an 'active' entity as oppose to program which
consider to be a 'passive' entity.
• Program is an algorithm expressed in some suitable notation,
(e.g., programming language).
• Process execution must progress in sequential fashion
• A process includes:
– Program counter
– Stack
– Data section
– Contents of the processors registers
– Value of the variables
 Process memory is divided into four sections
The text section comprises the compiled program code, read in from
non-volatile storage when the program is launched.

The data section stores global and static variables, allocated and
initialized prior to executing main.

The heap is used for dynamic memory allocation, and is managed via
calls to new, delete, malloc, free, etc.

The stack is used for local variables. Space on the stack is reserved for
local variables when they are declared
Process in Memory
Process State
• As a process executes, it changes state
– new:
• The process is being created
– running:
• Instructions are being executed
– waiting:
• The process is waiting for some event to occur
– ready:
• The process is waiting to be assigned to a processor
– terminated:
• The process has finished execution
Diagram of Process State
Process Control Block (PCB)
Information associated with each process
– Process state
– Program counter
– CPU registers
– CPU scheduling information
– Memory-management information
– Accounting information
– I/O status information
CPU Switch From Process to Process
Process Scheduling

• The two main objectives of the process scheduling system are


– To keep the CPU busy at all times and
– To deliver "acceptable" response times for all programs, particularly
for interactive ones.
• Process scheduler must meet these objectives by implementing
suitable policies for swapping processes in and out of the CPU.
• Process Scheduling Queues
– Job queue – set of all processes in the system
– Ready queue – set of all processes residing in main memory,
ready and waiting to execute
– Device queues – set of processes waiting for an I/O device
– Processes migrate among the various queues
Representation of Process Scheduling
Schedulers
• Long-term scheduler (or job scheduler)
– Selects which processes should be brought into the ready queue
– Invoked very infrequently (seconds, minutes)  (may be slow)
– Controls the degree of multiprogramming
• Short-term scheduler (or CPU scheduler)
– Selects process that should be executed next and allocates CPU
– Invoked very frequently (milliseconds)  (must be fast)
• Processes can be described as either:
– I/O-bound process – spends more time doing I/O than
computations, many short CPU bursts
– CPU-bound process – spends more time doing computations;
few very long CPU bursts
Context Switch
• When CPU switches to another process, the system must save the state of the old
process and load the saved state for the new process via a context switch
• Context of a process represented in the PCB
• Context-switch time is overhead; the system does no useful work while
switching
• Time dependent on hardware support

Addition of
Medium Term
Scheduling
Operation on Process
• Process Creation
– Parent process create children processes, which, in turn create
other processes, forming a tree of processes
– Generally, process identified and managed via a process
identifier (pid)
– Resource sharing
• Parent and children share all resources
• Children share subset of parent’s resources
• Parent and child share no resources
– Execution
• Parent and children execute concurrently
• Parent waits until children terminate
Process Creation
Process Termination
• Process executes last statement and asks the operating system to
delete it (exit)
– Output data from child to parent (via wait)
– Process’ resources are deallocated by operating system
• Parent may terminate execution of children processes (abort)
– Child has exceeded allocated resources
– Task assigned to child is no longer required
– If parent is exiting
• Some operating system do not allow child to continue if its
parent terminates
– All children terminated - cascading termination
2.4 Interprocess Communication
• Processes within a system may be independent or cooperating
• Cooperating process unlike independent process can affect or be
affected by other processes execution, including sharing data
• Reasons for cooperating processes:
– Information sharing
– Computation speedup
– Modularity and Convenience
• Cooperating processes need interprocess communication (IPC)
• Two models of IPC
– Shared memory
– Message passing
3.1. Introduction to Threads
Threads Vs Processes
The processes and threads are independent
sequences of execution, the typical difference is
that threads run in a shared memory space,
while processes run in separate memory spaces.
Threads exist within a process and
every process has at least one thread.
Each process provides the resources needed to
execute a program.
Conti…

Notes: Threads share the same address space.


Thread context switching can be done entirely
independent of the operating system.
•Process switching is generally more expensive
as it involves getting the OS in the loop, i.e.,
trapping to the kernel.
•Creating and destroying threads is much
cheaper than doing so for processes.
3.2. Threads in Distributed Systems
 Thread is a basic unit of CPU utilization, consisting of a program
counter, a stack, and a set of registers, ( and a thread ID. )
 Traditional ( heavyweight ) processes have a single thread of
control - There is one program counter, and one sequence of
instructions that can be carried out at any given time.
 A thread is a single sequence stream within in a process.
 Threads are sometimes called lightweight processes. Because
they have some of the properties of processes, In a process,
threads allow multiple executions of streams.
 In many respect, threads are popular way to improve application
through parallelism.
 The CPU switches rapidly back and forth among the threads
giving illusion that the threads are running in parallel.
 Like a traditional process i.e., process with one
thread, a thread can be in any of several states
(Running, Blocked, Ready or Terminated).
 Each thread has its own stack. Since thread will
generally call different procedures and thus a
different execution history. This is why thread needs
its own stack.
 A thread has or consists of a program counter (PC), a
register set, and a stack space.
 Threads are not independent of one other like
processes as a result threads shares with other threads
their code section, data section, OS resources also
known as task, such as open files and signals.
As shown in Figure below, multi-threaded applications have
multiple threads within a single process, each having their own
program counter, stack and set of registers, but sharing common
code, data, and certain structures such as open files.
Benefits of Multithreaded Processes over single-Threaded

• Responsiveness:
– One thread may provide rapid response while other threads are
blocked or slowed down doing intensive calculations
• Resource Sharing:-
– Allows multiple tasks to be performed simultaneously in a single
address space
• Economy:-
– Creating and managing threads (and context switches between them )
is much faster than performing the same tasks for processes.
• Scalability (i.e Utilization of multiprocessor architectures):-
– A single threaded process can only run on one CPU, no matter how
many may be available, whereas the execution of a multi-threaded
application may be split amongst available processors
Cont….
• Concurrent Execution on a Single-core System

• Parallel Execution on a Multi-core System


Threads Type
• User Threads :- Thread management done by user-level threads library
– Three primary thread libraries: POSIX Pthreads, Win32 threads,
Java threads
• Advantages
– Does not require modification to operating systems.
– Simple Representation: Each thread is represented simply by a PC,
registers, stack and a small control block, all stored in the user
process address space.
– Simple Management: creating, switching between threads and
synchronization between threads can all be done without
intervention of the kernel.
– Fast and Efficient: Thread switching is not much more expensive
than a procedure call.
Disadvantages:
There is a lack of coordination between threads and operating
system kernel.
Therefore, process as whole gets one time slice irrespect of whether process
has one thread or 1000 threads within.
It is up to each thread to relinquish control to other threads.
Kernel Threads:- Supported by the Kernel
Examples: Windows XP/2000, Solaris and Linux, Tru64 UNIX, Mac OS X
Advantages:
Because kernel has full knowledge of all threads, Scheduler may decide to
give more time to a process having large number of threads than process
having small number of threads.
Especially good for applications that frequently block.
Disadvantages: Slow and inefficient. (e.g. threads operations are hundreds
of times slower than that of user-level threads.
Since kernel must manage and schedule threads as well as processes. It
require a full thread control block (TCB) for each thread to maintain
information about threads. As a result there is significant overhead and
increased in kernel complexity.
Threads Pools
– Create a number of threads in a pool where they await work.
– Advantages:
• Usually slightly faster to service a request with an existing
thread than create a new thread.
• Allows the number of threads in the application(s) to be
bound to the size of the pool.
Thread States

• ..
3.3. Clients vs. Servers
3.4. Code Migration
•So far, we have been mainly concerned with distributed
systems in which communication is limited to passing
data.
•However, there are situations in which passing
programs, sometimes even while they are being
executed, simplifies the design of a distributed system.
•In this section, we take a detailed look at what code
migration actually is.
• We start by considering different approaches to code
migration, followed by a discussion on how to deal with
the local resources that a migrating program uses.
•A particularly hard problem is migrating code in
heterogeneous systems, which is also discussed.
In distributed computing, code mobility is the
ability for running programs, code or objects to be
migrated (or moved) from one machine or
application to another.
It is common practice in distributed systems to
require the movement of code or processes
between parts of the system, instead of data.
Reasons for Migrating Code
•Traditionally, code migration in distributed systems
took place in the form of process migration in which
an entire process was moved from one machine to
another.
•Moving a running process to a different machine is a
costly and intricate task, and there had better be a
good reason for doing so.
•That reason has always been performance. The basic
idea is that overall system performance can be
improved if processes are moved from heavily-loaded
to lightly-loaded machines. Load is often expressed in
terms of the CPU queue length or CPU utilization, but
other performance indicators are used as well.
•Load distribution algorithms by which decisions
are made concerning the allocation and
redistribution of tasks with respect to a set of
processors, play an important role in compute-
intensive systems.
•However, in many modern distributed systems,
optimizing computing capacity is less an issue than,
for example, trying to minimize communication.
•Moreover, due to the heterogeneity of the
underlying platforms and computer networks,
performance improvement through code migration
is often based on qualitative reasoning instead of
mathematical models.
•Consider, as an example, a client-server system
in which the server manages a huge database. If
a client application needs to perform many
database operations
Synchronization
• Multithreading introduces asynchronous behavior to the
programs. If a thread is writing some data another thread
may be reading the same data at that time. This may bring
inconsistency.
• When two or more threads need access to a shared
resource there should be some way that the resource will
be used only by one resource at a time. The process to
achieve this is called synchronization.
• To implement the synchronous behavior java has
synchronous method. Once a thread is inside a
synchronized method, no other thread can call any other
synchronized method on the same object. All the other
threads then wait until the first thread come out of the
synchronized block.
•When we want to synchronize access to objects of a
class which was not designed for the multithreaded
access and the code of the method which needs to
be accessed synchronously is not available with us, in
this case we cannot add the synchronized to the
appropriate methods. In java we have the solution
for this, put the calls to the methods (which needs to
be synchronized) defined by this class inside a
synchronized block in following manner.
• Synchronized(object) {
• // statement to be synchronized
• }
Chapter 4:Communication
Unit Contents:
1. Layer Protocols
2. Types of Communication
3. RMI, RPC & COBRA
1. Layer Protocols
• Low-level layers
• Transport layer
• Application layer
• Middleware layer
• Basic networking Model:
1. The ISO OSI model &
2. The TCP/IP Model
Conti…
Protocols vs. Layers
• Layer 1: Physical Layer: Telnet, FTP,TFTP,…
• Layer 2: Data Link Layer: PPP SBTV SLIP
• Layer 3: Network Layer:IP,Ipsec,ICMP,IGMP,OSPF,RIP
• Layer 4: Transport Layer:UDP TCP,
• Layer 5: Session Layer:
• Layer 6: Presentation Layer:
• Layer 7: Application Layer
Physical Layer
• The physical layer sometimes plays an important role in the effective
sharing of available communication resources, and helps avoid
contention among multiple users. It also handles the transmission rate
to improve the flow of data between a sender and receiver.
The physical layer provides the following services:
• Modulates the process of converting a signal from one form to
another so that it can be physically transmitted over a communication
channel
• Bit-by-bit delivery
• Line coding, which allows data to be sent by hardware devices that are
optimized for digital communications that may have discreet timing on
the transmission link
• Bit synchronization for synchronous serial communications
• Start-stop signaling and flow control in asynchronous serial
communication
• Circuit switching and multiplexing hardware control of multiplexed
digital signals
• Carrier sensing and collision detection, whereby the physical layer detects
carrier availability and avoids the congestion problems caused by
undeliverable packets
• Signal equalization to ensure reliable connections and facilitate multiplexing
• Forward error correction/channel coding such as error correction code
• Bit interleaving to improve error correction
• Auto-negotiation
• Transmission mode control
• Examples of protocols that use physical layers include:
• Digital Subscriber Line
• Integrated Services Digital Network
• Infrared Data Association
• Universal Serial Bus
• Bluetooth
• Controller Area Network
• Ethernet
Data link layer
• The data link layer is used for the encoding,
decoding and logical organization of data bits. Data
packets are framed and addressed by this layer,
which has two sublayers.
• The data link layer's first sublayer is the media
access control (MAC) layer. It is used for source and
destination addresses. The MAC layer allows the
data link layer to provide the best data transmission
vehicle and manage data flow control.
• The data link layer's second sublayer is the logical
link control. It manages error checking and data
flow over a network.
Network Layer
•Logical connection setup, data forwarding, routing
and delivery error reporting are the network layer’s
primary responsibilities.
•Network layer protocols exist in every host or
router.
The session layer
• The session layer manages a session by initiating
the opening and closing of sessions between end-
user application processes.
• This layer also controls single or multiple
connections for each end-user application, and
directly communicates with both the presentation
and the transport layers.
• The services offered by the session layer are
generally implemented in application
environments using remote procedure calls
(RPCs).
Conti…
• Low-level layers:
• Physical layer: contains the specification and
implementation of bits, and their
transmission between sender and receiver.
• Data link layer: prescribes the transmission
of a series of bits into a frame to allow for
error and flow control
• Network layer: describes how packets in a
network of computers are to be routed.
Conti…
Transport Layer
Important
The transport layer provides the actual
communication facilities for most distributed
systems.
Standard Internet Protocols:
• TCP: connection-oriented, reliable, stream-
oriented
communication
• UDP: unreliable (best-effort) datagram
communication
Application layer
• Remote login to hosts: Telnet.
• File transfer: File Transfer Protocol (FTP), Trivial File
Transfer Protocol (TFTP)
• Electronic mail transport: Simple Mail Transfer
Protocol (SMTP)
• Networking support: Domain Name System (DNS)
• Host initialization: BOOTP.
Middleware layer
Middleware
The software layer that lies between the operating
system and applications on each side of a
distributed computing system in a network."
Conti…
• Observation
Middleware is invented to provide common services
and protocols
that can be used by many different applications
• A rich set of communication protocols
• (Un)marshaling of data, necessary for integrated
systems
• Naming protocols, to allow easy sharing of resources
• Security protocols for secure communication
• Scaling mechanisms, such as for replication and
caching
• Note: What remains are truly application-specific
protocols... such as?
The TCP/IP Reference Model
•TCP/IP means Transmission Control Protocol and
Internet Protocol. It is the network model used in
the current Internet architecture as well.
•Protocols are set of rules which govern every
possible communication over a network. These
protocols describe the movement of data between
the source and destination or the internet. They
also offer simple naming and addressing schemes.
Protocols and networks in the TCP/IP model:
Internet layer:
• Delivering IP packets
• Performing routing
• Avoiding congestion
2. Types of Communication
• We can view the middleware as an additional
service in client server computing:
(Consider, for example an email system.)
Distinguish:
• Transient versus persistent communication
• Asynchronous versus synchronous communication
Transient versus persistent:
• Transient communication: Comm. server discards message when
cannot be delivered at the next server, or at the receiver.
• Persistent communication: A message is stored at a communication
server as long as it takes to deliver it.
Asynchronous versus synchronous:
• Asynchronous communication: A sender continues immediately
after
it has submitted the message for transmission.
• Synchronous communication: The sender is blocked until its request
is known to be accepted. There are three places that synchronization
can take place
( see Figure above ):At request submission
• At request delivery
• After request processing
• Client/Server
Some observations
Client/Server computing is generally based on a model of transient
synchronous communication:
• Client and server have to be active at time of communication.
• Client issues request and blocks until it receives reply
• Server essentially waits only for incoming requests, and subsequently
processes them
Drawbacks of synchronous communication
• Client cannot do any other work while waiting for reply
• Failures have to be handled immediately: the client is waiting
• The model may simply not be appropriate (mail, news)
Messaging
Message-oriented middleware ( MOM )
Aims at high-level persistent asynchronous communication:
• Processes send each other messages, which are queued
• Sender need not wait for immediate reply, but can do other things
• Middleware often ensures fault tolerance
3. RMI, RPC & COBRA
•RPC (Remote Procedure Call) and RMI (Remote
Method Invocation) are two mechanisms that allow
the user to invoke or call processes that will run on
a different computer from the one the user is using.
• The main difference between the two is the
approach or paradigm they used.
•RMI uses an object oriented paradigm where the
user needs to know the object and the method of
the object he needs to invoke.
•In comparison, RPC isn’t object oriented and
doesn’t deal with objects. Rather, it calls specific
subroutines that are already established.
Conti…
• RPC is a relatively old protocol that is based on the C
language, thus inheriting its paradigm. With RPC,
you get a procedure call that looks pretty much like a
local call.
• RPC handles the complexities involved with passing the
call from the local to the remote computer.
• RMI does the very same thing; handling the complexities
of passing along the invocation from the local to the
remote computer. But instead of passing a procedural
call, RMI passes a reference to the object and the
method that is being called.
• RMI was developed by Java and uses its virtual machine.
Its use is therefore exclusive to Java applications for
calling methods on remote computers.
Conti…
• In the end, RPC and RMI are just two means of achieving
the same exact thing. It all comes down to what language
you are using and which paradigm you are used to. Using
the object oriented RMI is the better approach between
the two, especially with larger programs as it provides a
cleaner code that is easier to track down once something
goes wrong. Use of RPC is still widely accepted, especially
when any of the alternative remote procedural protocols
are not an option.
• Summary:
• 1.RMI is object oriented while RPC isn’t
2.RPC is C bases while RMI is Java only
3.RMI invokes methods while RPC invokes functions
4.RPC is antiquated(old) while RMI is the future.
Corba vs. RMI
• There is no doubt about the popularity of Java among
developers. With Java, possibilities have expanded even
further. Java’s extremely portable nature is of great
advantage. It integrates well with web browsers, making it
ideal for Web development ventures. As far as developers
are concerned, it is easy to use and implement. This is the
main reason many developers embrace the technology.
• RMI and CORBA are two of the most significant and
commonly utilized distribution systems in Java. Both are
very effective but with their own pros and cons. The
applications using these systems are enormously
expansive and almost limitless. As a developer for a
particular project, choosing between the two can be a
difficult decision to make.
Conti…
• Common Object Request Broker Architecture or simply
CORBA has many adapters.
• It can also call many languages with a CORBA interface as it is
developed to be independent of whatever language a
program it is written in.
• It is in direct competition to RMI but CORBA offers better
portability.
• CORBA can easily integrate with older systems and newer
ones that support CORBA.
• However, for developers of JAVA, the technology provides less
flexibility as it does not allow executables to be forwarded to
remote systems.
• CORBA is an extensive family of standards and interfaces.
Exploring the details of these interfaces is quite a daunting
task.
Conti…
• RMI is an abbreviation of Remote Method Invocation.
This technology was released with Java 1.1, actually
available since JDK 1.02, and it lets Java developers
invoke object methods and allows them to be executed
on remote JVMs or Java Virtual Machines. Its
implementation is rather easy particularly if you know
Java very well. It’s just like calling a process locally;
however, its calls are limited to Java only.
• Having mentioned about RMI’s Java-centric
characteristic, the only way to integrate codes in other
languages into the RMI distribution system is to use an
interface. This interface is called the Java native-code
interface. However, it can be extremely complex and,
more often than not, results to fragile codes.
Conti…

• RMI has major features that CORBA doesn’t have, most notably, the
ability to send new objects ,code and data across a network, and
for remote virtual machines to faultlessly handle new objects
• When comparing RMI and CORBA, it is like making a comparison
between an apple and an orange. Principally, one is not better than
the other. It entirely depends on the application or project involved
and the preference of the developer.
• Summary:
• 1. RMI is Java-centric while CORBA is not tied to a single language.
• 2. RMI is easier to master particularly for Java programmers and
developers.
• 3. CORBA offers greater portability due to its high adaptability to
various programming languages.
• 4. CORBA can’t send new objects across networks.
Why RPC?
• Sockets are considered low-level
• RPCs offer a higher-level form
of communication
• Client makes procedure call to “remote”
server using ordinary procedure call
mechanisms
Client and Server
Issues in RPC

• Cannot pass pointers


• Weakly typed languages
• Not always possible to determine parameter
types
• Cannot use global variables
• Remote Method Invocation
• Java’s version of RPC
• A thread may invoke a method on a remote
object
• An object is considered “remote” if it resides
in a separate Java Virtual Machine.
Remote Method Invocation
• RPC versus RMI
• RPC support procedural programming style
• RMI supports object-oriented programming
style
• Parameters to RPCs are ordinary data
structures
• Parameters to RMI are objects
Chapter-5:Naming
Outline:
1. Names, Identifies, and Addresses
2. Flat Naming
3. Structured Naming
4. Attribute Based Naming
Overview
•Names are used to refer to entities, locations,
resources and more. We need to resolve a name
to the entity it refers to. The naming system may
itself be implemented in a distributed fashion.
•How to organize and implement human friendly
names. E.g. files systems, World Wide Web
•Locating entities in a way that is independent of
current location from their names
•Resolving names by means of entity attributes
Names, Identifiers and Addresses
Properties of a true identifier:
• An identifier refers to at most one entity.
• Each entity is referred to by at most one identifier.
• An identifier always refers to the same entity
A name in a distributed system is a string of bits or
characters used to refer to an entity. Entity is something
that is operated on using some access point. The name
of the access point is called an address.
Entities: hosts, printers, disks, files, processes, users,
mailboxes, web pages, graphical windows, messages,
network connections, etc.
• An identifier is an unambiguous reference to an
entity. We need a universally unique identifier.
Properties of a true identifier:
• An identifier refers to at most one entity.
• Each entity is referred to by at most one identifier.
• An identifier always refers to the same entity
•Types of Naming Systems
•Flat naming: The identifier is simply a random bit string. It
does not contain any information whatsoever on how to
locate an access point of its associated entity. Good for machines.
•Structured naming: Composed of simple human-readable
names. Examples are file system naming and host naming on the Internet.
•Attribute-based naming: Allows an entity to be described
by (attribute, value) pairs. This allows a user to search more effectively by
constraining some of the attributes.
Global naming techniques:
The first requirement for achieving access to
remote resources is being able of naming them.
Almost any subsystem in distributed systems
requires the existence of a global naming service.
Chapter-6: Synchronization
Chapter 7
Consistency And Replication
Chapter 8
Fault Tolerance
Fault Tolerance Basic Concepts
• Being fault tolerant is strongly related to what are
called dependable systems
• Dependability implies the following:
1.Availability
2.Reliability
3.Safety
4.Maintainability
Failure Models
• Figure 8-1. Different types of failures.

You might also like