Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

DS Lecture 3 (1)

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 36

ntroduction to Distributed System

010101010101010100010100010111001010101010010101010101010001010100010111001
010101010010101010101010100010100010111001010101010010101010101010100010100

Lecture
010111001010101010010101010101010100010100010111001010101010010101010101010
100010100010111001010101010010101010101010100010100010111001010101010010101
010101010100010100010111001010101010010101010101010100010100010111001010101
010010101010101010100010100010111001010101010010101010101010100010100010111

Three in
001010101010010101010101010100010100010111001010101010010101010101010100010

Processes
100010111001010101010010101010101010100010100010111001010101010010101010101
010100010100010111010101010010101010100101010101010101000101000101 Since
0101010101010101010101010101010101010101010
DS
101010101000101000101110010101010100101010101010101000101000101110010101010
100101010101010101000101000101110010101010100101010101010101000101000101110
01010101010010101010101010100010100010111001010101010010
BY Basha K | Faculty of Computing and Software
Contents
•After accomplishing of this chapter, Students will be able to understand:
 Definition of Processes in OS and DS Perspective

 Concepts of Multitasking

 Definition of Threads in DS Contest

 Advantage of Thread and Why Thread

 Code Migration

 Servers and Design Issues

 Software Agents
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.

• It is also termed as a set of instructions stored in the secondary storage device


that are intended to carry out a specific job.

• Process can create one or more other processes referred to as child processes and
these processes in turn can create child processes.
Cont…
• A process is often defined as a program in execution, which 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.

• In most traditional OS, each process has an address space, a single thread of
control and other processing resources.

• It is necessary to have multiple threads of control sharing one address space


but running in parallel way.
Definition of Process (Computing…… Definition)
• In a distributed system, a process refers to a program or software application
that is running on a computer or node within the system.

• These processes are essential components of distributed computing, and they


interact with one another to achieve the system's overall goals.

• In a distributed system, a process is a self-contained program or application


that runs independently and each process has its own memory space and
resources.

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


instructions in a Parallel way.
Definition of Process (Computing…… Definition)

• In computing, a process is the instance of a computer


program that is being executed by one or many threads.
• Overall, processes in a distributed system work together to provide
services, perform tasks, and handle data in a way that can leverage the
capabilities and resources of multiple machines.

• Designing and managing these processes effectively is essential for


building robust and efficient distributed systems.
Cont…
• A modern computer operating system usually segregates virtual
memory into Kernel Space and User Space.

• The kernel is a computer program at the core of a computer's operating


system and has complete control over everything in the system.

• A Kernel is provided with a protected Kernel Space which is a separate


area of memory and this area is not accessible by other application
programs.
Cont…
• So, the code of the Kernel is loaded into this protected Kernel Space.

• User space: is that set of memory locations in which user processes run and it is
the memory area where application software and some drivers execute in the
operating system.
Functions of a Kernel

• Access Computer Resource: A Kernel can access various computer resources like the CPU,

I/O devices and other resources.

• Resource Management: It is the duty of a Kernel to share the resources between various

process in such a way that there is uniform access to the resources by every process.

• Memory Management: Every process needs some memory space. So, memory must be

allocated and deallocated for its execution. All these memory management is done by a Kernel.

• Device Management: The peripheral devices connected in the system are used by the

processes. So, the allocation of these devices is managed by the Kernel.


What is Multitasking?
• Multitasking is used to keep all of a computer's resources at work as much of the time as
possible and it is the capability of the operating system of running several applications at the
same time.

• It is therefore deeply related to the OS capability for managing shared resources, and in
particular for deciding 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, and they are managed in such a way that each one
of them gets a share according to specific priority policies.
Cont…
Cont…

• Multitasking is a method to allow multiple processes to

share processors (CPUs) and other system resources.

• It is the capability of the operating system of running several processes at the

same time by sharing the all the necessary resources.

• Multitasking, in an operating system, is allowing a user to perform more than

one computer task (such as the operation of an application program) at a time.


Cont…
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 simultaneous 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 remarkable 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.

• So, Threads allow parallelism to be combined with the easily understood blocking communication of the
client/server model.
Cont…
Single vs Multi Thread Process
Difference Between Process vs Thread
Definition:
• Process: Independent program in execution with its own memory space and
resources.
• Thread: Smaller unit of a process that shares memory space and resources.

Communication:
Memory Space: • Process: Requires inter-process
• Process: Own memory space. communication (IPC), which is complex and
• Thread: Shares memory space with other slower.
threads in the same process. • Thread: Easy communication through
shared memory.
Overhead: Isolation:
• Process: Higher overhead due to context • Process: Isolated; one process crashing
switching. does not affect others.
• Thread: Lower overhead; faster context • Thread: Less isolated; crashing one thread
switching. can impact the entire process.
Creation: Use Case:
• Process: Best for running separate
• Process: More time-consuming to create.
applications or services.
• Thread: Faster to create and manage. • Thread: Suitable for concurrent tasks
within the same application.
Why Thread in Distributed System?
•An important property of threads is that they can provide a convenient means of allowing
blocking system calls without blocking the entire process in which the thread is running.
•This property makes threads particularly attractive to use in distributed systems as it makes it
much easier to express communication in the form of maintaining multiple logical connections
at the same time.
•We illustrate this point by taking a closer look at Multithreaded In Clients and Servers side,
respectively.
Multithreaded Servers
•Practice shows that multithreading not only simplifies server code considerably, but also makes
it much easier to develop servers that exploit parallelism to attain high performance, even on
uniprocessor systems.
•Multithreaded Server: A server having more than one thread is known as Multithreaded Server.
•When a clients sends the requests, a threads is generated through which a user can
communicate with the server.
•We need to generate multiple threads to accept multiple requests from multiple clients at the
same time.
Cont…
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.

 Virtualization Allows
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 Designing Issue
• A server is a process implementing a specific service on behalf of a collection of clients. In
essence, each server is organized in the same way:

• It waits for an incoming request from a client and subsequently ensures that the request is taken
care of, after which it waits for the next incoming request.

• In the case of an iterative server, the server itself handles the request and, if necessary, returns a
response to the requesting client.

• A concurrent server does not handle the request itself, but passes it to a separate thread or
another process, after which it immediately waits for the next incoming request.

• A multithreaded server is an example of a concurrent server. An alternative implementation of a


concurrent server is to fork a new process for each new incoming request.
Cont…
• An issue is where clients contact a server. In all cases, clients send requests to an
end point, also called a port, at the machine where the server is running.

• Each server listens to a specific end point. How do clients know the end point of
a service?

• The approach is to globally assign end points for well-known services. For
example, servers that handle Internet FTP requests always listen to TCP port 21.

• Likewise, an HTTP server for the World Wide Web will always listen to TCP port
80.
Servers and Design Issues…

• How to Organize Servers?


 Iterative server and Concurrent server

• Where/How 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.


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

• The basic idea is that overall system performance can be improved if processes are
moved from heavily-loaded to lightly-loaded machines.

• Code migration in the broadest sense deals with moving programs between machines,
with the intention to have those programs be executed at the target.

• In some cases, as in process migration, the execution status of a program, pending


signals, and other parts of the environment must be moved as well.
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.


Cont…
• The client first fetches the necessary software, and then invokes the
server
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 software agent is an piece of software that functions as an agent for a


user or another program, working autonomously and continuously in a

particular environment.

• It is a computer program which works toward goals in a dynamic


environment on behalf of another entity (human or computational).

• It is inhibited by other processes and agents, but is also able to learn from
its experience in functioning in an environment over a long period of time.
Examples
Thank You!
Q?

You might also like