Chapter Three
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
Every process has its own memory Threads use the memory of the process
space. they belong to.
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
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.
The operating system, libraries, and other programs are unique to the guest
virtualized system.
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:
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
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.
Examples:
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 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.
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