0% found this document useful (0 votes)
141 views36 pages

Naming and Multithreading in Distributed Systems

The document discusses naming and threads in distributed systems. It defines naming as assigning names to entities to uniquely identify them. Namespaces and name resolution are described as ways to map names to entities. Namespaces organize names in a hierarchical structure, while name resolution looks up the address associated with a given name. The document also introduces threads as sequential flows of execution within a process that allow for multithreaded clients and servers.

Uploaded by

siraj mohammed
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)
141 views36 pages

Naming and Multithreading in Distributed Systems

The document discusses naming and threads in distributed systems. It defines naming as assigning names to entities to uniquely identify them. Namespaces and name resolution are described as ways to map names to entities. Namespaces organize names in a hierarchical structure, while name resolution looks up the address associated with a given name. The document also introduces threads as sequential flows of execution within a process that allow for multithreaded clients and servers.

Uploaded by

siraj mohammed
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

JJU 1

Introduction to Distributed System


(ITec3102)

Jigjiga University
IoT
Department of Information Technology

Siraj Mohammed
[Link]@[Link]

04/04/2023
2

CHAPTER 3: NAMING AND THREADS

JJU 04/04/2023
Outline
3

 Naming
 Name spaces
 Implementation of name spaces
 Name resolution
 Implementation of name resolution
 Threads
 Threads in distributed systems
 Multithreaded Clients
 Multithreaded Servers
JJU 04/04/2023
What is naming?
4

 Mapping names onto entities


 Naming is assigning a name to entities
 E.g.,
 sirmoh4@[Link]  name of a person,
registered in a DNS domain
 [Link]  name of organization (or
jigjig university), registered in a DNS domain.
 Examples of naming systems:
 DNS
 The domain name system (DNS) maps the name people use to
locate a website to the IP address.
What is Name?
5

 A name is something that refers to an entity


 In a distributed system, name can be
 String,
 Characters,
 Sequence of symbol and a combination of them.
 An entity in a distributed system can be anything.
 Typical examples include resources such as
 Hosts
 Printers
 Users
 Web pages and Others JJU 04/04/2023
Why we need names?
6

 Names play a very important role in all computer


systems/in distributed system. 
 They are used to:
 share resources
 uniquely identify entities
 refer to locations

JJU 04/04/2023
Access point
7

 To operate on an entity, it is necessary to access it through


its access point
 An entity can have more than one access point
 E.g.,
accessing an individual through different telephone
numbers
 An entity may change its access point in the course of
time
 E.g., a mobile computer getting a new IP address as it moves

JJU 04/04/2023
Entities, Addresses, Access point: Examples
8

 Example:
 Telephone as Access Point to a person.
 The Telephone Number then becomes the address of the person.
 Person can have several telephone numbers.
 Entity (or Person) can have several addresses.
 Another Example: transport layer -Level Addresses
 For server, this can be IP address and port number
 Entities may change access points and address over time
 Telephone numbers
 e-mail addresses
 IP addresses

JJU 04/04/2023
Identifiers
9

 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 – it’s never
reused

 For example, the name "John Smith" cannot be taken as a


unique reference to just a single person
 We cannot use an address as an identifier

 Solution Implementing namespace


JJU 04/04/2023
Namespace
10

 A namespace refers to named entities (objects)


distributed across multiple locations
 A namespace is a context within which the names of all
objects must be resolvable.
 A name space can be organized as a directed graph with
two types of nodes:
 Leaf node: represents the named entity and stores
information such as its address
 Directory node: a special entity that has a number of
outgoing edges.
JJU 04/04/2023
Namespace…
11

a general naming graph with a single root node


JJU 04/04/2023
Namespaces…
12

 A directory node stores a table in which an outgoing


edge is represented as a pair (edge label, node identifier),
called a directory table
 Each path in a naming graph can be referred to by the

sequence of labels corresponding to the edges of the path


and the first node in the path, such as
 N:<label1, label2, ..., labeln>, where N refers to the

first node in the path


 Such a sequence is called a path name

JJU 04/04/2023
Namespace…
13

 If the first node is the root of the naming graph, it is


called an absolute path name
 Otherwise, it is a relative path name
 Instead of the path name n0:<home, steen, mbox>, we
often use its string representation /home/steen/mbox
 There may also be several paths leading to the same
node,
 E.g., node n5 can be represented as /keys or /home/steen/keys

JJU 04/04/2023
The Implementation of a Name Space
14

 A naming service allows users and processes to add,


remove, and lookup names
 A naming service is implemented by name servers
 Name servers (e.g., DNS) can be used
 To transform domain name ([Link]) to IP address 
([Link])
 For a distributed system on a single LAN,
 a single server might sufficient
 For a large-scale distributed system
 the implementation of a name space is distributed over
multiple name servers JJU 04/04/2023
The Implementation of a Name Space…
15

 Name Space Distribution:


 In large scale distributed systems
 It is necessary to distribute the name service over multiple

name servers, usually organized hierarchically


 A name service can be partitioned into three logical layers:
 Global layer

 Administrational layer

 Managerial layer

JJU 04/04/2023
The Implementation of a Name Space…
16

 Global layer
 Formed by highest level nodes (root node and nodes close to it or its

children)
 Directory tables are rarely changed
 Global layer can be used to represent organizations
 Administrational layer
 Groups of entities that belong to the same organization or

administrational unit, e.g., departments


 Relatively stable

 Managerial layer
 Nodes that may change regularly

 e.g., nodes representing hosts of a LAN,


 shared files such as libraries
 Nodes are managed not only by system administrators, but also by
end users JJU 04/04/2023
an example partitioning of the DNS name space, including
Internet-accessible files, into three layers

17
 Example ,Adama University web address: [Link]
JJU
04/04/2023
17
What is name resolution?
18

 Given a path name, the process of looking up a name stored in


the node is referred to as name resolution;
 It consists of finding the address when the name is given by
following the path
 Goal: is to associate names and IP addresses

JJU 04/04/2023
Implementation of Name Resolution
19

 Name resolution finding the address when the name is


given
 e.g., assume the path name
 root:<nl, vu, cs, ftp, pub, globe, [Link]> is to be
resolved
 or using a URL notation, this path name would
correspond to [Link]
 Two ways of implementing name resolution
A. Iterative name resolution
B. Recursive name resolution

JJU 04/04/2023
A. Iterative name resolution:
 A name resolver hands over the complete name to the root name

server
 The root server will resolve the name as far as it can and return the

result to the client; at the minimum it can resolve the first level and
sends the name of the first level name server to the client
 The client calls the first level name server, then the second, ..., until it

finds the address of the entity

20 JJU 04/04/2023
the principle of iterative name resolution 20
 Recursive name resolution:
 A name resolver hands over the whole name to the root name server

 The root server will try to resolve the name and if it can’t, it requests

the first level name server to resolve it and to return the address
 The first level will do the same thing recursively

21 JJU 04/04/2023
the principle of recursive name resolution 21
Threads
22

 A process can contain multiple threads.


 A thread refers to a single sequential flow of activities being
executed in a process
 A thread is a lightweight process running within a larger
process
 A thread is the unit of execution within a process

JJU 04/04/2023
Threads and their Implementation
23

 Threads can be used in both distributed and nondistributed


systems
 Threads in Nondistributed Systems

Process 1 Process 2 Process 3

JJU 04/04/2023
three processes each with one thread one process with three threads
Threads and their Implementation…
24

 Each thread has its own


 Program counter
 Registers
 Stack
 But, all threads of a process share
 Address space
 Global variables and
 Other resources such as open files

JJU 04/04/2023
Threads and their Implementation…
25

JJU 04/04/2023
Multithreading
26

 Multithreading is a CPU (central processing unit)


feature that allows two or more instruction threads to
execute independently, while sharing the same
process resources
 Multithreading allows multiple concurrent tasks can
be performed within a single process.
 Multithreading allows many parts of a program to
run simultaneously

JJU 04/04/2023
Examples of Multithreading
27

 Example 1, a word processor


 While we are typing, multiple treads are used to
 Display our document
 Format the page
 Save our document
 Check the spelling of the document and
 Check the grammar of our document
 Example 2, consider your internet browser and many opened taps in
which multiple threads of execution are used to
 Load content
 Display webpage
 Display email
 Play a video and so on. JJU 04/04/2023
Why do we need Multithreading?
28

 To perform many activities at once


 To avoid blocking when waiting for input or
doing calculations
 Real parallelism is possible in a multithreads
system

JJU 04/04/2023
Threads in Distributed Systems
29

 Multithreaded Clients:
 Consider a Web browser
 Fetching different parts of a page can be implemented
as a separate thread,
 Each opening its own TCP/IP connection to the server
or to separate and replicated servers
 Each can display the results

JJU 04/04/2023
Threads in Distributed Systems…
30

 Multithreaded Servers: is any server that has


more than one thread
 To accept multiple requests at the same time  We
need multiple threads on the server side.

JJU 04/04/2023
Threads in Distributed
31
Systems…
Servers can be constructed in three ways:
1. Single-threaded process:
 It gets a request, examines it, carries it out to
completion before getting the next request
 The server is idle while waiting for disk read,
 i.e., system calls are blocking

JJU 04/04/2023
Threads in Distributed
32
Systems…
Servers can be constructed in three ways….

2. Multiple threads:
 Threads are more important for implementing servers

 e.g., a file server

How does a file serer works?


 Step-1: The dispatcher thread reads incoming multiple


requests from clients
 Step-2: The dispatcher passes it to an idle worker thread
 Step-3: The worker thread performs the actual task
JJU 04/04/2023
Threads in Distributed
33
Systems…
Servers can be constructed in three ways….
2. Multiple threads, e.g., file server

a multithreaded server organized in a dispatcher/worker model


JJU 04/04/2023
Threads in Distributed
34
Systems…
Servers can be constructed in three ways….
3. Finite-state machine:
 It gets a request, examines it, tries to fulfill the
request from cache
 Instead of blocking it records the state of the
current request and
 Proceeds to the next request

JJU 04/04/2023
Summary of Server model
35

Model Characteristics

Single-threaded process No parallelism, blocking system calls

Parallelism, blocking system calls


Threads
(thread only)

Finite-state machine Parallelism, nonblocking system calls

JJU 04/04/2023
Thank you

36 JJU 04/04/2023

You might also like