0% found this document useful (0 votes)
28 views28 pages

Chapter Three

The document discusses processes and threads, explaining that a process is an executing instance of a program while a thread is the smallest executable unit of a process. It describes different types of threads and multithreading models. The document also covers virtualization and how it allows running multiple operating systems simultaneously on a single computer system.

Uploaded by

Urgessa Gedefa
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)
28 views28 pages

Chapter Three

The document discusses processes and threads, explaining that a process is an executing instance of a program while a thread is the smallest executable unit of a process. It describes different types of threads and multithreading models. The document also covers virtualization and how it allows running multiple operating systems simultaneously on a single computer system.

Uploaded by

Urgessa Gedefa
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/ 28

Chapter Three

Processes

3/24/2020 1
Introduction to Threads
Processes
 Process is an executing instance of a program. For example, When
you double click on the Google Chrome icon on your computer,
you start a process which will run the Google Chrome program.
 When you double click on a notepad icon on your computer, a
process is started that will run the notepad program.
 A process is sometimes referred as active entity as it resides on the
primary memory and leaves the memory if the system is rebooted.
 Several processes may related to same program.
 For example, you can run multiple instances of a notepad
program.
Each instance is referred as a process.
3/24/2020 2
Cont.….

Threads
 Thread is the smallest executable unit of a process. For example,
 when you run a notepad program, operating system creates a
process
and starts the execution of main thread of that process.
 A process can have multiple threads. Each thread will have their
own task and own path of execution in a process.
 For example, in a notepad program, one thread will be taking
user
inputs and another thread will be printing a document.
 All threads of the same process share memory of that process.
As threads of the same process
3/24/2020
share the same memory, 3
Cont.….
Process and
Threads

3/24/2020 4
Cont.….
Process vs.
Threads
Process Thread

Processes are heavy weight


operations. Threads are light weight operations.

Every process has its own memory Threads use the memory of the process
space. they belong to.

Inter thread communication is fast as


Inter process communication is threads of the same process share the
slow as processes have same memory address of the process
different memory address. they belong to.

Context switching between the Context switching between threads of


process is more expensive. the same process is less expensive.

Processes don’t share the memory Threads share the memory with
with other processes. other threads of the same process.
3/24/2020 5
Cont.….
Thread Types

User Threads
 Threads are implemented at the user level by a thread library
 Thread Library provides support for thread creation, scheduling
and management.
 User threads are fast to create and manage.

Kernel Threads
 Supported and managed directly by the OS.
 Thread creation, scheduling and management take place in kernel
space.
 Slower to create and manage.
3/24/2020 6
Cont.….
Thread Usage in Non distributed Systems

Benefits of multithreaded processes:


 Increased responsiveness to user:
 Resource Sharing:-Threads share memory and resources of
their process.
 Economy:-Less time consuming to create and manage threads
than
processes as threads share resources
 Utilization of Multiprocessor Architectures
 Many applications are easier to structure as a collection of
cooperating threads.

3/24/2020 7
Cont.….
Multithreading Models
 Three common ways of establishing a relationship between user
level threads and kernel-level threads

1. Many-to-One
 Many user-level threads mapped to single kernel thread.
 Easier thread management.
 Blocking-problem.
 No concurrency.
 Examples: Green threads for Solaris

3/24/2020 8
Cont.….
2. One-to-One
 Each user-level thread maps to a kernel thread.
 Overhead of creating kernel threads, one for each user thread.
 No blocking problem
 Provides concurrency.
 Examples: Linux, family of Windows

3. Many-to-Many
 Allows many user level threads to be mapped to many kernel
threads.
 Allows the OS to create a sufficient number of kernel threads.
 Users can create as many as user threads as necessary.
 No blocking and concurrency problems.
 Two-level 3/24/2020 Prepared By Mubarek 9
Virtualization
 Virtualization is the process of running a virtual instance of a
computer
system in a layer abstracted from the actual hardware.

 Running multiple operating systems on a single computer


system simultaneously.

 The applications running on top of the virtualized machine, it can appear as


if
they are on their own dedicated machine

 The operating system, libraries, and other programs are unique to the guest
virtualized system.

3/24/2020 Prepared By Mubarek 110


cont.….
Divided into two main categories:

1. Platform virtualization
 performed on a given hardware platform by "host" software (a control
program),
 creates a simulated computer environment (a virtual machine) for its
"guest" software.
 The "guest" software, which is often itself a complete operating system,
runs just as if it were installed on a stand-alone hardware platform.

2. Resource virtualization
 involves the simulation of combined, fragmented, or simplified resources.
 Virtualization of specific system resources, such as storage volumes,
name
spaces, and network resources.
3/24/2020 11
cont.….
Architectures of Virtual Machines
 Four distinct levels of interfaces to computers the behavior of which
that virtualization can mimic:

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).
3/24/2020 12
cont.….
Virtualization can take place in two different ways:

1. Process virtual machine

 Build a runtime system that provides an abstract instruction set that is to be


used for executing applications.

 An example of a process VM is the Java Virtual Machine, which enables any


operating system to run Java applications as if they were native to that system.
A system virtual machine is fully virtualized to substitute for a physical
machine.

2. Virtual machine monitor (VMM)

 Possible to have multiple, and different operating systems run independently


and concurrently on the same platform.

 Example: VMware and Xen (website).

3/24/2020 13
3/24/2020 14
Clients
Networked User Interfaces
 Two ways to support client-server interaction:

1. For each remote service - the client machine will have a separate

counterpart that can contact the service over the network.

In this case, an application-level protocol will handle the synchronization,


as shown in Figure(a).
A few examples of application layer protocols are the Hypertext Transfer
Protocol (HTTP), File Transfer Protocol (FTP), Post Office Protocol (POP),
Simple Mail Transfer Protocol (SMTP), and Domain Name System (DNS

2.Provide direct access to remote services by only offering a convenient


user interface.
 The client machine is used only as a terminal with no need for local
storage, leading to an application neutral solution as shown in
Figure(b). 15
cont.…..
(a) A networked application with its own protocol. (b) A general solution
to
allow access to remote applications.

example: Web Browsers like Google Chrome and Apple Safari

3/24/2020 16
Server
General Design Issues
 A server is a process implementing a specific service on behalf of a
collection of clients.
 Each server is organized in the same way:
 it waits for an incoming request from a client
 ensures that the request is fulfilled
 it waits for the next incoming request.
 Several ways to organize servers:

Iterative server
 Iterative server handles request, then returns results to the client; any
new client requests must wait for previous request to complete (also
useful to think of this type of server as sequential). 17
cont.…
Concurrent server

Concurrent: server does not handle the request itself; a separate thread
or sub-process handles the request and returns any results to the
client; the server is then free to immediately service the next client (i.e.,
there’s no waiting, as service requests are processed in parallel).
 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.
 This approach is followed in many UNIX systems.
 The thread or process that handles the request is responsible
for returning a response to the requesting client.

18
cont.….
Where do clients contact a
server?
 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?

Globally assign end points for


well-known services.

Examples:

1. Servers that handle Internet


FTP requests always listen to
TCP port 21. 19
18
cont.….
Design issue

Stateless Server vs. State full server:

A stateless server
 a server that treats each request as an independent transaction that is
unrelated to any previous request.
 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.

Example:-A Web server is stateless.


 It merely responds to incoming HTTP requests, which can be
either
for uploading a file to the server or (most often) for fetching a file.
 When the request has been processed,
3/24/2020 the Web server forgets the 20
cont.….
A stateful server
 remembers client data (state) from one request to the next.
 Information needs to be explicitly deleted by the server.

Example:
 A file server that allows a client to keep a local copy of a file, even
for
performing update operations.
 The server maintains a table containing (client, file) entries.
 This table allows the server to keep track of which client currently
has the update permissions on which file and the most recent
version of that file.
 Improves performance of read and write operations as perceived
by 3/24/2020 21
cont.….
Advantages / Disadvantages
 Using a stateless file server, the client must specify complete file
names in each request specify location for reading or writing re-
authenticate for each request
 Using a stateful file server, the client can send less data with each
request
 A stateful server is simpler
 A stateless server is more robust: lost connections can't leave a file
in an invalid state rebooting the server does not lose state
information rebooting the client does not confuse a stateless
server

3/24/2020 22
cont.….
Server Clusters
General Organization
 A server cluster is a collection of machines connected
through a
network, where each machine runs one or more servers.
 A server cluster is logically organized into three tiers

3/24/2020 23
cont.….
First tier
 consists of a (logical) switch through which client requests are
routed.
Second tier: application processing.
 Cluster computing servers run high-performance hardware
on dedicated to delivering
 Enterprise
compute power.
server clusters - applications may need to run on
relatively low-end machines, as the required compute power
is not the bottleneck, but access to storage is.

Third tier: data-processing servers


 notably file and database servers.
 These servers may be running on specialized machines, configured
for
high-speed disk access and having large server-side data caches.
3/24/2020 24
Code Migration
 Code migration in the broadest sense deals with moving programs
between machines, with the intention to have those programs be
executed at the target.

Reasons for Migrating Code


 Code migration in DS took place in form of process migration even
though it’s costly but reason is for performance.
 From heavily loaded to lightly loaded performance
 Other reasons for supporting code migration is flexibility.
 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.
3/24/2020 25
cont.….
Different approaches to code migration
 In code migration framework, a process consists of 3 segments.
 The code segment is the part that contains the set of instructions that
make up the program that is being executed
 The resource segment contains references to external resources
needed by the process, such as files, printers, devices, other processes
and so on.
 Finally an execution segment is used to store the current execution
state of a process, consisting of private data, the stack and the
program counter.

3/24/2020 26
cont.….

1) Weak mobility:
 A characteristics feature of weak mobility is that a transferred
program is always started from its initial state.

2) Strong mobility
 A characteristics feature of strong mobility is that a running
process can be stopped, subsequently moved to another m/c and
then resume execution where it left off.
3/24/2020 27
cont.….
3. Sender initiated migration
 In sender initiated migration, migration is initiated at the m/c
where code currently resides or is being executed.
 Eg. Sending a search program access the internet to a web
database server to perform the queries at that server.
 In contrast to process migration, cloning yields an exact copy of
files
original process, but now running on a different m/c.
 The cloned process is executed in parallel to the original process.
 In UNIX systems, remote cloning takes place by forking off a
child
processes and letting that child continue on a remote m/c.
3/24/2020 28

You might also like