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

Chapter 2-Process

The document discusses processes and threads in distributed systems. It defines a process as a program in execution and notes that processes allow communication between systems but require high overhead for resource allocation and context switching. Threads execute independently within a process and have lower overhead. Threads can improve performance by overlapping communication and processing. The document also discusses client-server models, virtualization, and how threads are implemented at the user and kernel level.

Uploaded by

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

Chapter 2-Process

The document discusses processes and threads in distributed systems. It defines a process as a program in execution and notes that processes allow communication between systems but require high overhead for resource allocation and context switching. Threads execute independently within a process and have lower overhead. Threads can improve performance by overlapping communication and processing. The document also discusses client-server models, virtualization, and how threads are implemented at the user and kernel level.

Uploaded by

Sølø Ëd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

Chapter Two

Process

5/5/2020
 1

Principles in Distributed Systems

Processes
 Communication takes place between processes
 a process is a program in execution

 from OS perspective, management and scheduling of processes

is important.
Other important issues arise in distributed systems include:
 Multi threading to enhance performance by overlapping

communication and local processing


 how are clients and servers organized and server design issues

 process or code migration to achieve scalability and to

dynamically configure clients and servers

5/5/2020
 2
2.1 Threads and their Implementation

• What a process is and how are processes and threads related?


• Process tables or PCBs(Process control block) are used to keep
track of processes
• there are usually many processes executing concurrently
• processes should not interfere with each other; sharing
resources by processes is transparent
• this concurrency transparency has a high price; allocating
resources for a new process and context switching take time
• a thread also executes independently from other threads; but
no need of a high degree of concurrency transparency thereby
resulting in better performance
5/5/2020
 3

• threads can be used in both distributed and non distributed
systems
• Threads in Non distributed Systems
• a process has an address space (containing program text and
data) and a single thread of control, as well as other resources
such as open files, child processes, accounting information,
etc.

Process 1 Process 2 Process 3

5/5/2020
 4

processes each with one thread one process with three threads
• each thread has its own program counter, registers, stack,
and state; but all threads of a process share address space,
global variables and other resources such as open files, etc.

5/5/2020
 5

• Threads take turns in running
• Threads allow multiple executions to take place in the
same process environment, called multi threading
1.Simplifying the programming model: since many
activities are going on at once more or less
independently
2.They are easier to create and destroy than processes
since they do not have any resources attached to them
3.Performance improves by overlapping activities if there
is too much I/ O; i. e., to avoid blocking when waiting
for input or doing calculations, say in a spreadsheet
4. Real parallelism is possible in a multiprocessor system

5/5/2020 6
• in non distributed systems, threads can be used with
shared data instead of processes to avoid context
switching overhead interprocess communication
(IPC)

context switching as the result of IPC

5/5/2020 7

Thread Implementation
•threads are usually provided in the form of a thread package
•the package contains operations to create and destroy a thread,
operations on synchronization variables such as mutexes and
condition variables
•two approaches of constructing a thread package
a. construct a thread library that is executed entirely in user
mode (the OS is not aware of threads)
– cheap to create and destroy threads; just allocate and free
memory
– context switching can be done using few instructions; store and
reload only CPU register values
– disadvantage: invocation of a blocking system call will block
the entire process to which the thread belongs and all other
threads in that process
b. implement them in the OS’skernel
– let the kernel be aware of threads and schedule them
– expensive for thread operations such as creation and deletion
5/5/2020 8

since each requires a system call 
• solution: use a hybrid form of user-level and kernel-level
threads, called lightweight process (LWP)
Threads in Distributed Systems
• Multithreaded Clients
– consider a Web browser; fetching different parts of a page
can be implemented as a separate thread, each opening its
own TCP connection to the server
– each can display the results as it gets its part of the page
– parallelism can also be achieved for replicated servers since
each thread request can be forwarded to separate replicas
Multithreaded Servers
– servers can be constructed in three ways
A. single-threaded process
• it gets a request, examines it, carries it out to completion
before getting the next request

5/5/2020 9

b. Threads
– threads are more important for implementing
servers
• e.g., a file server
– the dispatcher thread reads incoming requests for a file
operation from clients and passes it to an idle worker thread
C. finite-state machine
• if threads are not available
• it gets a request, examines it, tries to fulfill the request
from cache, else sends a request to the file system
Model Characteristics
Single-threaded process No parallelism, blocking system calls
Threads Parallelism, blocking system calls (thread only)
Finite-state machine Parallelism, non blocking system calls

5/5/2020  10
Virtualization
• The Separation between having a single CPU and
being able to pretend there are more can be
extended to other resources as well, leading to
what is known as resource virtualization.
The Role of Virtualization in Distributed Systems
• virtualization deals with extending or replacing an
existing interface so as to mimic the behavior of
another system.
• allow legacy software (various applications,
operating systems they were developed for) to run
on expensive mainframe hardware.
5/5/2020
 11

Role of Virtualization

General organization between a General organization of virtualizing


program, interface, and system. system A on top of system B.

5/5/2020
  12
Architectures of Virtual Machines
To understand the differences in virtualization, it is important to
realize that computer systems generally offer four different types of
interfaces, at four different levels:
1. An interface between the hardware and software, consisting of
machine instructions that can be invoked by any program.
2. An interface between the hardware and software, consisting of
machine instructions that can be invoked only by privileged
programs, such as an operating system.
3. An interface consisting of system calls as offered by an operating
system.
4. An interface consisting of library calls, generally forming what is
known as an application programming interface (API). In many cases,
the aforementioned system calls are hidden by an API.

5/5/2020  13
Various interfaces offered by computer systems.

Virtualization can takes place in to two different ways:

1. A process VM: we can build a runtime system that essentially provides an


abstract instruction set that is to be used for executing applications.
Eg. Java virtual machine
2. System VM: is to provide a system that is essentially implemented as a layer
completely shielding the original hardware, but offering the complete
instruction set of that same (or other hardware) as an interface.
• Virtual Machine Monitor
5/5/2020 14
Eg. VMWare
A process VM, with multiple instances of A VMM. with multiple instances of
(application, runtime) combinations (applications, OS) combinations.

5/5/2020  15
Anatomy of Clients and Servers
Two issues: user interfaces and client-side software for
distribution transparency
A. Networked User Interfaces
• to create a convenient environment for the interaction of a
human user and a remote server; e.g. mobile phones with
simple displays and a set of keys
• GUIs are most commonly used
• The X Window System (or simply X) as an example
• it has the X kernel: the part of the OS that controls the
terminal (monitor, keyboard, pointing device like a mouse)
and is hardware dependent

5/5/2020
  16
b. Client-Side Software for Distribution Transparency
• in addition to the user interface, parts of the processing and
data level in a client-server application are executed at the
client side
• an example is embedded client software for ATMs, cash
registers, etc.
• moreover, client software can also include components to
achieve distribution transparency
• e.g., replication transparency by means of client side solutions

5/5/2020  17
Servers and Design Issues
1 General Design Issues
A server is a process implementing a specific service on behalf of
a collection of clients.
a. How to organize servers?
Iterative server
• the server itself handles the request and returns the result
Concurrent server
• it passes a request to a separate process or thread and waits for
the next incoming request; e.g., a multithreaded server;

5/5/2020  18
b. Where do clients contact a server?
• using endpoints or ports at the machine where the
server is running where each server listens to a specific
endpoint

How do clients know the endpoint of a service?


• globally assign endpoints for well-known services;
e.g. FTP is on TCP port 21, HTTP is on TCP port 80
• To have Running deamon, which keeps track of the
current end points of each service implemented by a
co-located server.

5/5/2020  19
How Servers can be interrupted?
– Abruptly exit client application
– Send out-of-band data
Whether or not the server is stateless:
– A stateless server does not keep information on the
state of its clients, and can change its own state
without having to inform any client
– A particular form of a stateless design is where the
server maintains what is known as soft state, servers
maintain soft state (keeps information for limited
period of time).
– Statefull server generally maintain persistent

information on its clients.
5/5/2020 20
Code Migration
• so far, communication was concerned on passing
data
• we may pass programs, even while running and in
heterogeneous systems
• code migration also involves moving data as well:
when a program migrates while running, its status,
pending signals, and other environment variables
such as the stack and the program counter also
have to be moved

5/5/2020
  21
Reasons for Migrating Code
• to improve performance; move processes from
heavily-loaded to lightly-loaded machines (load
balancing)
• to reduce communication: move a client
application that performs many database
operations to a server if the database resides on the
server; then send only results to the client
• to exploit parallelism (for nonparallel programs):
e.g., copies of a mobile program (called a mobile
agent is called in search engines) moving from site
to site searching the Web

5/5/2020
  22
Models for Code Migration
•code migration doesn’t only mean moving code; in some cases, it
also means moving the execution status of a program, pending
signals, and other parts of the execution environment
•a process consists of three segments: code segment (set of
instructions), resource segment (references to external resources
such as files, printers, ...), and execution segment (to store the
current execution state of a process such as private data, the
stack, the program counter)
•alternatives for code migration
– weak versus strong mobility
– is it sender-or receiver-initiated
– is it executed at the target process or in a separate process
(for weak mobility); migrate or clone process (for strong
mobility)

5/5/2020
  23
Weak Mobility
• transfer only the code segment and may be some
initialization data; in this case a program always
starts from its initial stage, e.g. Java Applets
• execution can be by
– the target process (in its own address space like in
Java Applets) but the target process and local
resources must be protected (security) or
– by a separate process; still local resources must be
protected (security)

5/5/2020
  24
Strong Mobility (or process migration )
•transfer code and execution segments; helps to migrate a process in
execution; stop execution, move it, and then resume execution from
where it is stopped

•migration can be
– sender-initiated: the machine where the code resides or is
currently running; e.g., uploading programs to a server; may
need authentication or that the client is a registered one; crawlers
to index Web pages
– receiver-initiated: by the target machine; e.g., Java Applets;
easier to implement
•In a client-server model, receiver-initiated is easier to implement since
security issues are minimized; if clients are allowed to send code
(sender-initiated), the server must know them since they may access
resources such as disk on the server
5/5/2020  25
Summary of models of code migration

5/5/2020
  26
Resource-to-Machine Bindings

• with the migrate Unattached Resources: can be easily


moving program (such as data files associated with the
program)
• Fastened Resources: such as local databases and
complete Web sites; moving or copying may be possible,
but very costly
• Fixed Resources: intimately bound to a specific machine
or environment such as local devices and cannot be
moved.

5/5/2020
  27
Types of Process-to-Resource Bindings
• Binding by identifier (the strongest): a resource is referred by
its identifier; the process requires that resource; e.g., a URL to
refer to a Web page or an FTP server referred by its Internet (IP)
address
• Binding by value (weaker): when only the value of a resource is
needed; in this case another resource can provide the same value;
e.g., standard libraries of programming languages such as C or
Java which are normally locally available, but their location in
the file system may vary from site to site
• Binding by type (weakest): a process needs a resource of a
specific type; reference to local devices, such as monitors, printer

5/5/2020  28
Overview Software Agents
• Software agents(to be specific distributed agents) are software
processes or robots that can move around the system to do
specific tasks for which they are specially programmed.
• The name “agent” derives from the fact that the agents do
work on behalf of some broader objective.
• Agents collect and process information, and can exchange
such information with other agents.
• Agents architecture can be mobile, Interface, Collaborative,
Information, Reactive and hybrid.
• Challenges in distributed agent systems include coordination
mechanisms among the agents, controlling the mobility of the
agents, and their software design and interfaces.
5/5/2020
  29
Software agents main characteristics

Cooperation

Autonomy Adaptation

5/5/2020
  30
Why do we need agents?
– Increasingly networked, temporary connectivity
increasing (wireless).
– Data overload (e-mail, web pages, fax, …).
– Greater exchange of digital information
– Increasingly dependent upon electronic sources
of information.
– Desire to be ‘better informed’.
5/5/2020
  31
Agent Technologies

• Research in agents is inter-disciplinary: spanning artificial


intelligence, mobile computing, economic market models,
software engineering, and distributed computing.
• Mobile agents : “a running program” (code & data) travels.
• Agents support the development of complex, distributed, and
heterogeneous information systems.
• It needs an agent platform.

5/5/2020
  32
• One of the approach Querying the Search Interface is to use
agent technology. In this case, hidden web agents are
developed that interact with the search forms and retrieve the
result pages.
• This involves three steps:
– finding the forms,
– learning to fill the forms, and
– identifying and fetching the target (result) pages.
• ACBD- Agent Component Based Development
• Agent based customer knowledge management

5/5/2020
  33
Examples of Agents
• Buyer agents or shopping bots,
• User or personal agents,
• Monitoring and surveillance agents,
• Data Mining agents,
• Web Crawlers and,
• etc.

5/5/2020
  34

You might also like