100% found this document useful (1 vote)
211 views36 pages

Distributed System: Processes in DS

The document discusses processes and threads in distributed systems. It defines a process as a program in execution that contains code, activity, and resources. Processes can create child processes. Threads allow parallel execution within a process by running instructions concurrently and sharing the process's resources. Using threads for client-server requests provides advantages over processes like more efficient resource usage and easier synchronization. Threads allow a server to handle multiple concurrent requests asynchronously without losing CPU time.
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
100% found this document useful (1 vote)
211 views36 pages

Distributed System: Processes in DS

The document discusses processes and threads in distributed systems. It defines a process as a program in execution that contains code, activity, and resources. Processes can create child processes. Threads allow parallel execution within a process by running instructions concurrently and sharing the process's resources. Using threads for client-server requests provides advantages over processes like more efficient resource usage and easier synchronization. Threads allow a server to handle multiple concurrent requests asynchronously without losing CPU time.
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/ 36

DISTRIBUTED SYSTEM

Chapter 3
Processes in DS
Objectives
•After accomplishing of this chapter, Students will be able to understand:

 Definition of Processes in OS and DS perspective..


 Definition of Threads & Their Implementation
 Advantage of Thread and Why Thread
 Code Migration
 Servers and Design Issues
 Software Agents and Agent Technology
Definition of Process(OS….Definition)

•A process is a program that is loaded into memory, found under executing and
it is a collection of one or more threads (What is thread??) and associated

system resources.

•Process can create one or more other processes referred to as child processes
and these processes in turn can create child processes.

•Related Processes that are cooperating to get some job done often need to
communicate with one another and synchronize their activities.
Definition of Process (Computing)
•In computing, a process is the instance of a computer program that is being executed
by one or many threads.

•It contains the program code, its activity and depending on the operating
system (OS).

• Process may be made up of multiple threads of execution that execute


instructions concurrently.

•Several processes may be associated with the same program, for example, opening
up several instances of the same program often results in more than one process
being executed.
Cont…
• To understand the role of threads in distributed systems, it is important
to understand what a process is, how processes and threads relate.

• To execute a program, an operating system creates a number of virtual


processors, each one for running a different program.

• To keep track of these virtual processors, the operating system has a


process table, containing entries to store CPU register values, memory
maps, open files, accounting information, privileges, etc.
Cont…
Cont…
• A process is often defined as a program in execution, that is, a program
that is currently being executed on one of the operating system's virtual
processors.

• In other words, the fact that multiple processes may be concurrently


sharing the same CPU and other hardware resources is made
transparent.
Cont…
• Each time a process is created, the operating system must create a complete
independent address space and allocation can mean initializing memory
segments.

• Likewise, switching the CPU between two processes may be relatively


expensive as well.

• Apart from saving the CPU context (which consists of register values,
program counter, stack pointer, etc.), the operating system will also have to
modify registers of the memory management unit (MMU).
Cont…
Cont…
Cont…
Generally Process is
• A process is often defined as a program in execution, that is, a program
that is currently being executed on one of the operating system's virtual
processors.

• In other words, the fact that multiple processes may be concurrently


sharing the same CPU and other hardware resources is made transparent.

• For example, to efficiently organize client-server systems, it is often


suitable to make use of multithreading techniques.
What is Multitasking?

• Today's microprocessors can only execute one program instruction at a


time.

• But because they operate so fast, they can be made to appear to run many
programs and serve many users simultaneously.

• This illusion is created by rapidly multiplexing the processor over the set
of active tasks.

• The processor operates at speeds that make it seem as though all of the
user's tasks are being performed at the same time.
Cont…
• The concept of multitasking is really quite straightforward: a number of
programs (we will call them “tasks”) appear to be running on the same
CPU simultaneously.

• This is achieved by allowing each task to run for a short while and then
interrupting it, saving its machine registers’ contents, loading the
registers with the data for the next task, and continuing processing. 
Cont…
•Multitasking is a method to allow multiple processes to share processors (CPUs)
and other system resources.

•Multitasking is the capability of the operating system of running several


applications/processes at the same time.

•It is therefore deeply related to the OS capability for managing shared resources,
and in particular for arbitrating conflicts resulting from resource over-commitment.

• In a multitasking environment, the totality of the computer’s resources (memory,


files, CPU time) are allocated to different applications/processes, and they are
managed according to specific priority policies.
Cont…
•When CPU resources are over-dedicated, the operating system schedules the
different active processes by performing a process switch at regular time intervals,

distributing the available CPU cycles according to a well-defined priority policy.

•Multitasking is therefore the natural execution model of single or multiprocessor


systems.

•It is the way several applications/processes share the resources of a computing


platform.
Generally Multitasking is
• In computing, multitasking is the concurrent execution of multiple tasks (also known
as processes) over a certain period of time.

• New tasks can interrupt already started ones before they finish, instead of waiting for them to
end.

• As a result, a computer executes segments of multiple tasks in an interleaved manner, while the
tasks share common processing resources such as central processing units (CPUs) and main
memory.

• Multitasking automatically interrupts the running program, saving its state (partial results,
memory contents and computer register contents) and loading the saved state of another
program and transferring control to it. 
Cont…
Cont…
Cont…
•A common form of multitasking is provided by CPU's time-sharing that is a
method for interleaving the execution of users processes.

•Prevention has an important side effect for interactive process that are given
higher priority with respect to CPU bound processes.

•Therefore users are immediately assigned computing resources at the simple


pressing of a key or when moving a mouse.
What is Thread?
•Threads are quite useful for distributed system applications and many systems
interact using a client/server model of communication where a server process
listens for client requests, executes them and returns the results.

• If the server was operating as a sequential process and attempting to support


multiple client requests then two or more concurrent requests would have to be
executed serially by the server process.

•This would keep a number of buffered unanswered requests waiting


indeterminately until the server finished with earlier ones and the outstanding
requests may timeout giving the client the impression that the server has fail.
Cont…
•One alternative is to have the server split a new process to deal with every new request
and a listener process receives messages and creates a new process to execute.

•Requests then execute asynchronously under the control of the operating system and
the listener process could also provide an immediate initial response to the client if

required.

•The problem however is that process creation can be quite slow as the operating
system has to find sufficient free memory space for the process and set up other parts

of its control block.


Cont…
•A better alternative is to have the server create threads to deal with new requests and controlling thread receives
new requests.

•This is a more saleable approach from the operating system's point of view as it is a more efficient use of system
resources.

•Coordination and synchronization between the cooperating parts of the server process are achieved more efficiently
with shared memory mechanisms.

•Threads allow parallelism to be combined with the easily understood blocking communication of the client/server
model.
Cont…
•We can retain the model of our sequential process interaction with blocking calls
but still achieve parallelism in the application with threads.

•This is because when a thread in a process blocks, waiting for a reply from a
server, another thread within that process can be scheduled and so the process does

not lose its allotted CPU time.

•Another benefit is that threads allow the process to take advantage of a


multiprocessor system.
Cont…
Cont…
•Each thread runs strictly sequentially and has its own program counter and stack to keep track
of where it is.

•Threads share the CPU just as processes do: first one thread runs, then another does and can
create child threads and can block waiting for system calls to complete.

•All threads have exactly the same address space and they share code section, data section, and
OS resources (open files & signals).

•They share the same global variables and one thread can read, write, or even completely wipe
out another thread’s stack.
Advantage of Thread


Useful for Clients: if a client wants a file to be replicated on multiple servers, it can

have one thread talk to each server.


Handle Signals: such as interrupts from the keyboard and instead of letting the signal

interrupt the process, one thread is dedicated full time to waiting for signals.


Producer-Consumer Problems: are easier to implement using threads because threads

can share a common buffer.


It is possible for threads in a single address space to run in parallel, on different CPUs.
Cont…
•The main contribution of threads in distributed systems is that they allow clients and servers to
be constructed such that communication and local processing can overlap, resulting in a high
level of performance.

•Virtualization allows an application, and possibly also its complete environment including the
operating system, to run concurrently with other applications, but highly independent of the
underlying hardware and platforms, leading to a high degree of portability.

•Moreover, virtualization helps in isolating failures caused by errors or security problems and It
is an important concept for distributed systems, and we pay attention to it in a separate section.
Why Do We Need Threads?

•Simplifying: The programming model: since many activities are going on at once
more or less independently.

•They are Easier: To create and destroy than processes since they do not have any
resources attached to them.

•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.

•Real Parallelism: is possible in a multiprocessor system.


Servers and Design Issues

•How to organize servers?


Iterative server and Concurrent server
•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.


Servers and Design Issues
•Whether and how a server can be interrupted?

For instance, a user may want to interrupt a file transfer, may be it was the wrong fill

and let the client exit the client application, this will break the connection to the server,

the server will tear down the connection assuming that the client had crashed.

•Whether or not the server is stateless.



A stateless server does not keep information on the state of its clients for instance a

Web server.
Code Migration

•Code Migration is when programs are moved from one machine to another, often

moving parts of its execution environment along with it.

•Code Migration is often used for load distribution, reducing network bandwidth,

dynamic customization, and mobile agents.

•Code Migration increases scalability, improves performance, and provides

flexibility of the system.


Reason for Code Migration
•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: copies of a mobile program (called a mobile agent or a crawler
as is called in search engines) moving from site to site searching the Web.

•To have flexibility: by dynamically configuring distributed systems.


Software Agents

•A software agent is an autonomous unit (process) capable of performing a


task in collaboration(communicates) with other, possibly remote, agents.

•It is capable of reacting to, and initiating changes (proactive) in its


environment, possibly with users and other agents.

•A collaborative agent is an agent that forms part of a multiagent system, in


which agents seek to achieve some common goal through collaboration.
Cont…
•A Mobile Agent is an agent having the capability to move between different
machines; e.g., to retrieve information distributed across a large heterogeneous

network such as the Internet.

•An interface agent is an agent that assists an end user in the use of one or more
applications and has learning capabilities (it is adaptive), e.g., those that bring

buyers and sellers together.

•An information agent is an agent that manages information from different sources
such as ordering and filtering.
THANK YOU!!!
QUESTIONS???

You might also like