Resource and Process Management
Resource and Process Management
Resource and Process Management
If two tasks communicate n times and the average time for each
inter-task communication is t, them IPC costs for the two tasks
is n * t.
2) Optimal assignment, where tasks t1, t2, t3, t4, t5 are assigned to node p1
and task t6 is assigned to node p2.
Execution cost, x = x11 + x21 + x31 + x41 + x51 + x62
= 5 + 2 + 4 + 6 + 5 + 4 = 26
Communication cost, c = c16 + c26 + c36 + c46 + c56
= 12 + 0 + 0 + 0 + 0 = 12
Total cost = 38
Optimal assignments are found by first creating a static assignment
graph.
In the graph, the weights of the edges joining nodes represent
inter-task communication costs.
Add two nodes n1 and n2, which represent the processors p1 and
p2, respectively.
For every node other than n1 and n2, add an arc from that node to
each of n1 and n2. The weight of the arc to n1 is the cost of
execution of the module by P2, and the weight of the arc to n2 is
the cost of executing the module on P1.
Then by using the max-flow min-cut theorem, a minimum cutset
in this graph is determined (possible combinations are nt).
A cutset is defined to be a set of edges such that when these edges
are removed, the nodes of the graph are partitioned into two
disjoint subsets such that nodes in one subset are reachable from n1
and the nodes in the other are reachable from n2.
Each task node is reachable from either n1 or n2.
The weight of a cutset is the sum of the weights of the edges in the
cutset.
This sums up the execution and communication costs for that
assignment.
An optimal assignment is found by finding a minimum-weight
cutset. This may be done by the use of network flow algorithms.
Communication Cost Execution Cost
t1 t2 t3 t4 p1 p2
t1 0 35 3 8 t1 31 4
t2 35 0 6 4 t2 1 5
t3 3 6 0 23 t3 2 4
t4 8 4 23 0 t4 3 23
Static Dynamic
Cooperative Non-cooperative
1
9
Where, the processes are assigned to the processors at the
compile time, depending on the performance of the nodes.
After the assignment of processes, no change or reassignment is
possible at the runtime.
The total number of jobs in each node is fixed.
The information about the node is not collected.
The assignment job is done to the processing nodes on the basis
of the following factors:
1. Incoming time.
2. Extent of resource needed.
3. Mean execution time.
4. Inter-process communications.
Drawbacks:
Information about the system and jobs must be known before the
execution.
It is very difficult to estimate execution times of various parts of a
program accurately
Communication delay may occur under different circumstances
The assignment of jobs is done at the runtime and jobs are reassigned
at the runtime, depending upon the situation, that is, the load will be
transferred from heavily loaded nodes to lightly loaded nodes.
◦ The true load could vary depending on the remaining service times for
those processes.
Each node in the network is responsible for two roles with respect
to the bidding process: manager and contractor.
◦ The manager represents a node having a process in need of a location
to execute, and
After received bids from the contractor nodes, the manager node
chooses the best bid and the process is transferred from the
manager node to the winning contractor node.
The dynamic policies require frequent exchange of state
information among the nodes of the system.
41
The main goal of process management is to make the
best possible use of the processing resources of the
entire system by sharing them among all processes.
42
Processor Allocation deals with the process of
deciding which process should be assigned to which
processor.
43
Process Migration is the relocation of a process from its
current location to another location. This involves the
following steps:
Selection of a process that should be migrated.
Selection of the destination node.
Actual transfer of the selected process to the destination node.
The first two steps are taken care of by the process migration
policy and the third step is taken care of by the process
migration mechanism.
44
Source Node Destination Node
Process P1 in
Time
Execution Execution
suspended
46
Efficiency: the following costs should be kept to minimum.
The time required for migrating a process
The cost of locating an object (includes the migrated process)
The cost of supporting remote execution once the process is
migrated
Robustness
the failure of a node other than the one on which a process is
currently running should not affect the accessibility or execution of
that process.
Communication between Co-processes of a Job
If a single job is distributed over several nodes, then these co-
processes must be able to directly communicate with each other
irrespective of their locations.
47
The four major sub activities involved in process migration
are as follows:
1. Freezing the process on its source node and restarting on its
destination node
48
The usual process of migration is to take a “snapshot” of the
process’s state on its source node and reinstate the snapshot on
the destination node.
For this, at some point during migration,
the process is frozen on its source node,
its state information is transferred to its destination node,
the process is restarted on its destination node using this state
information.
49
Immediate and Delayed Blocking of the process
Fast and slow I/O operations: Finish fast I/O
Information about open Files: pointer
Reinstating the process on its destination node
50
Blocks the execution of the migrant process, postponing all
external communication
◦ immediate blocking - when not executing system call
The newly created copy of the process initially has a process identifier
different from the migrating process.
This allows both the old and new copies to exist and be accessible at
the same time.
If the process identifier of the new copy is different from its old copy,
the new copy’s identifier is changed to the original identifier before the
process starts executing on the destination node.
After all the state of the migrating process has been transferred and
copied into the empty process state, the new copy of the process is
unfrozen and the old copy is deleted.
52
The migration of a process involves the transfer of the following
information :
Process’s state (the execution status (contents of registers),
scheduling information, information about main memory being
used by the process (memory tables), I/O states (I/O queue,
contents of I/O buffers, interrupt signals, etc.), a list of objects to
which the process has a right to access, process's identifier,
process's user and group identifiers, information about the files
opened by the process (such as the mode and current position of
the file pointer), and so on
Process’s address space (code, data, and stack of the program)
It is necessary to completely stop the execution of the migrant
process while transferring its state information.
53
The process’s address space can be transferred to
the destination node either before or after the
process starts executing on the destination node
The address space transfer mechanisms:
Total freezing
Pretransferring
Transfer on Reference
54
A process's execution is stopped while its address space is being
transferred
It is simple and easy to implement.
Its main disadvantage is that if a process is suspended for a long
time during migration, timeouts may occur, and if the process is
interactive, the delay is more.
The address space is transferred while the process is still running on the
source node.
Therefore, once the decision has been made to migrate a process, it
continues to run on its source node until its address space has been
transferred to the destination node.
The remaining modified pages are retransferred after the process is
frozen for transferring its state information.
In the pretransfer operation,
◦ the first transfer operation moves the entire address space and
takes the longest time, thus providing the longest time for
modifications to the program's address space to occur.
◦ The second transfer moves only those pages of the address space
that were modified during the first transfer, thus taking less
time and presumably allowing fewer modifications to occur
during its execution time.
◦ Then subsequent transfer operations have to move fewer and
fewer pages, finally converging to zero or very few pages, which
are then transferred after the process is frozen.
59
Mechanisms used for message forwarding in existing DS are:
Mechanism of Resending the Message: to handle messages
of all three types.
◦ In this method, messages of types 1 and 2 are returned to the
sender as not deliverable or are simply dropped, with the
assurance that the sender of the message is storing a copy of the
data and is prepared to retransmit it.
◦ Messages of type 3 are sent directly to the process's destination
node
◦ These link update messages tell the new address of each link held
by the migrant process.
63
Reducing average response time of processes
Speeding up individual jobs
Gaining higher throughput
Utilizing resources effectively
Reducing network traffic
Improving system reliability
Improving system security
64
Passing programs, even while they are being executed,
simplifies the design of a distributed system.
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.
Moving a running process to a different machine is a costly
task. But it gives better performance.
Performance can be improved when processes are moved from
heavily-loaded to lightly-loaded nodes.
65
Eg., A client-server system in which the server manages a
huge database.
If a client application needs to perform many database operations
involving large quantities of data, it may be better to ship part of
the client application to the server and send only the results across
the network.
Otherwise, the network maybe swamped with the transfer of data
from the server to the client.
In this case, code migration is based on the assumption that it
generally makes sense to process data close to where those
data reside.
66
This same reason can be used for migrating parts of the server
to the client.
Eg. In many interactive database applications, clients need to fill in
forms that are subsequently translated into a series of database
operations.
Processing the form at the client side, and sending only the completed
form to the server, can avoid that a relatively large number of small
messages need to cross the network.
Provides flexibility.
The traditional approach to building distributed applications is to
partition the application into different parts, and decide in advance
where each part should be executed.
If code can move between different machines, it becomes possible to
dynamically configure distributed systems. Eg., suppose a server
implements a standardized interface to a file system.
67
Code migration can also help to improve performance by
exploiting parallelism.
A typical example is searching for information in the Web.
68
A process consists of three segments to migrate.
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.
An execution segment is used to store the current execution
state of a process, consisting of private data, the stack, and, of
course, the program counter.
71
1) Weak mobility:
A characteristics feature of weak mobility is that a
transferred program is always started from its
initial state.
Eg. Java applets
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.
Eg. D’ Agents.
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.
The benefit of cloning is that the model closely reassembles
the one that is already used in many applications.
The only difference is that the closed process is executed on
a different m/c.
In this sense, migration by cloning is a simple way to improve
distributed transparency.
The weak mobility is to transfer only the code segment, along
with some initialization data.
In systems that support strong mobility the execution segment
can be transferred as well.
The characteristic feature of strong mobility is that a running process
can be stopped, subsequently moved to another machine, and then
resume execution where it left off.
76
Weak mobility, also makes a difference if the migrated code is
executed by the target process, or whether a separate process is
started.
Eg., Java applets are simply downloaded by a Web browser and are
executed in the browser's address space.
The benefit of this approach is that there is no need to start a separate
process, thereby avoiding communication at the target machine.
77
A finer granularity in the form of multiple threads of control per
process makes it much easier to build distributed applications and
to attain better performance.
What is a process ? How are processes and threads related?
In traditional operating systems the basic unit of CPU utilization is
a process. Each process has its own program counter, its own
register states, its own stack, and its own address space.
Threads are a popular way to improve application performance
through parallelism.
78
In operating systems with threads facility, the basic unit of CPU
utilization is a thread.
In these operating systems, a process consists of an address
space and one or more threads of control
83
Advantages of a user-level thread library
Cheap to create and destroy threads, because all thread
administration is kept in the user's address space.
Destroying a thread mainly involves freeing memory for the
stack, which is no longer used.
Drawback of user-level threads
The invocation of a blocking system call will immediately block
the entire process to which the thread belongs, and thus also all
the other threads in that process.
These problems can be avoided by implementing threads in the
operating system's kernel.
84
Kernel level implementation is costly since every thread operation
have to be carried out by the kernel, requiring a system call.
86
The thread package can be shared by multiple LWPs.
Each LWP can be running its own (user-level) thread.
Multithreaded applications are constructed by creating threads, and
subsequently assigning each thread to an LWP.
The combination of (user-level) threads and LWPs works as follows:
The thread package has a single routine to schedule the next thread.
When creating an LWP (which is done by means of a system call), the
LWP is given its own stack, and is instructed to execute the scheduling
routine in search of a thread to execute.
If there are several LWPs, then each of them executes the scheduler.
87
The thread table, which is used to keep track of the current set of
threads, is shared by the LWPs.
Protecting this table to guarantee mutually exclusive access is done
by means of mutexes that are implemented entirely in user space.
Synchronization between LWPs does not require any kernel support.
When an LWP finds a runnable thread, it switches context to that thread.
Meanwhile, other LWPs may be looking for other runnable threads as
well.
If a thread needs to block on a mutex or condition variable, it does the
necessary administration and eventually calls the scheduling routine
88
When a thread does a blocking system call, execution changes from
user mode to kernel mode but still continues in the context of the
current LWP.
At the point where the current LWP can no longer continue, the
operating system may decide to switch context to another LWP, which
also implies that a context switch is made back to user mode.
The selected LWP will simply continue where it had previously left
off.
89
Advantages of LWPs in combination with user-level thread package
Creating, destroying, and synchronizing threads is relatively cheap
and involves no kernel intervention at all.
Provided that a process has enough LWPs, a blocking system call will
not suspend the entire process.
There is no need for an application to know about the LWPs. All it
sees are user-level threads.
LWPs can be easily used in multiprocessing environments, by
executing different LWPs on different CPUs.
Drawback: Need to create and destroy LWPs, which is just as
expensive as with kernel-level threads.
90
For high degree of distribution transparency, distributed systems
that operate in wide-area networks need to conceal long
interprocess message propagation times.
The round-trip delay in a wide-area network can easily be in the
order of hundreds of milliseconds or sometimes even seconds.
The usual way to hide communication latencies is to initiate
communication and immediately proceed with something else.
Eg.,Web browsers.
91
Multithreading simplifies server code, and makes it much easier to
develop servers that exploit parallelism to attain high performance.
Benefits of threads for writing server code: The organization of a file
server that occasionally has to block waiting for the disk.
The file server normally waits for an incoming request for a file
operation, subsequently carries out the request, and then sends back
the reply.
The dispatcher, reads incoming requests for a file operation. The
requests are sent by clients to a well-known end point for this server.
After examining the request, the server chooses an idle (i.e.,blocked)
worker thread and hands it the request.
92
A multithreaded server organized in a dispatcher/worker model.
Threads and processes can be seen as a way to do more things at
the same time.
They allow us to build (pieces of) programs that appear to be
executed simultaneously.
On a single-processor computer, there is only a single CPU, only an
instruction from a single thread or process will be executed at a
time by rapidly switching between threads and processes, the
illusion of parallelism is created.
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
99
Every (distributed) computer system offers a programming
interface to higher level software.
There are many different types of interfaces, ranging from the
basic instruction set as offered by a CPU to the vast collection of
application programming interfaces that are shipped with many
current middleware systems.
Virtualization deals with extending or replacing an existing
interface so as to mimic the behavior of another system.
Virtualization can help a lot:
the diversity of platforms and machines can be reduced by essentially letting
each application run on its own virtual machine.
Provides a high degree of portability and flexibility.
10
0
(a) General organization between a program, interface, and system.
(b) General organization of virtualizing system A on top of system B.
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).
10
2
Virtualization can take place in two different ways.
1. Can build a runtime system that essentially provides an abstract
instruction set that is to be used for executing applications.
Instructions can be interpreted ,but could also be emulated as is done for
running Windows applications on UNIX platforms.
This typeof virtualization leads to call a process virtual machine,
i.e.,virtualization is done essentially only for a single process
2. 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.
It is possible to have multiple, and different operating systems run
independently and concurrently on the same platform.
The layer is generally referred to as a virtual machine monitor (VMM).
10
3
Various interfaces offered by computer systems.
A process virtual machine, with multiple instances of (application, runtime)
combinations.
A virtual machine monitor, with multiple instances of (applications, operating
system) combinations.