[go: up one dir, main page]

0% found this document useful (0 votes)
17 views46 pages

Code Migration

The document provides an overview of process management, including definitions of processes, context switching, and the differences between threads and processes. It discusses user-level and kernel-level threads, their advantages and disadvantages, as well as the concept of lightweight processes and code migration. Additionally, it covers process migration mechanisms, message forwarding, and handling co-processes in heterogeneous systems.

Uploaded by

siddhesh.co0456
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views46 pages

Code Migration

The document provides an overview of process management, including definitions of processes, context switching, and the differences between threads and processes. It discusses user-level and kernel-level threads, their advantages and disadvantages, as well as the concept of lightweight processes and code migration. Additionally, it covers process migration mechanisms, message forwarding, and handling co-processes in heterogeneous systems.

Uploaded by

siddhesh.co0456
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

Process Management

Definition of Process
• Process - A program in execution
– A process should not maliciously affect correctness
of each other.
– Therefore, a process has its own address space
consisting of:
• Text region
– Stores the code that the processor executes
• Data region
– Stores variables and dynamically allocated memory
• Stack region
– Stores instructions and local variables
2 2
3
Process
• Process – a unit of allocation
• Allocation means
– initializing memory segment
– Zeroing a data segment
– Copying program into text segment
– Setting up a stack for temporary data

• Switching CPU between 2 processes is


expensive.

4
Context switch
• Context Switch : saving the current context.
• Foll. Actions takes place:
– Saving the CPU context
• Register values, program counter, stack, stack pointer ,
open files, child processes.
– Modification of Memory Mgmt. Unit (MMU)
• MMU -contains all memory references, mainly
translation of virtual memory to physical addresses.
• Invalidate address translation cache such as in the
translation lookaside buffer. (TLB)

5
Threads
• An OS that has thread facility, the basic unit of
CPU utilization is a thread.
• A thread has –
– Program Counter
– Register Set
– Stack
• They share the address space
– i.e. they share code seg, data seg, OS resources like
open files & signals.
6
Threads vs. Processes
Benefits:
• Less time to create a new thread because the newly
created thread uses the current process address space.
• Less time to terminate
• Less time to switch between 2 threads within the same
process, because the newly created thread uses the
current process address space
• Less communication overhead - because they share
address space.

7
Thread Implementation

User Level Thread Kernel Level Thread


Thread Library is used to Kernel is aware of threads &
construct a thread that Scheduling
executes in entirely in user
mode
No kernel intervention Thread mgmt. done by the
kernel
No thread library but system
calls to the kernel.

8
User Level Threads
• It is cheap to create & destroy threads.
– Thread creation – allocate stack to the thread.
– Destroying a thread - freeing stack memory.
• Thread switching is done in few instructions
– Only the values of the CPU registers are stored.
– Thread switching does not involve the kernel.
• Disadv:
– If a thread involves a blocking system call, the
entire process is blocked and thus all the threads of
9 that process. (if kernel is single threaded)
ULT
• Process as a whole gets 1 time slice,
irrespective of whether it has 10 threads or
1000 threads.
• Therefore 2 threads of 1 process cannot run
simultaneously unless the threading library and
underlying OS supports it.

10
Kernel Level Thread
• Thread Mgmt is done by the kernel.
• Every thread operation (creation, deletion etc.) will
have to be carried out by the kernel.
• Switching thread context is as expensive as process
context.
Advantages
– Kernel can simultaneously schedule many threads of same
process on many processors (as kernel has complete
knowledge).
– Good for applications that block as blocking is done on a
thread level.
11
KLT
• Kernel level threads are slow.
• Since kernel has to do scheduling of threads, it
requires TCB. (Thread Control Block), which is
an extra overhead.

12
Light weight Process (LWP)
• Hybrid form of ULT & KLT.
• There can be several LWPs per process.

13
LWP
• Application threads are attached to LWP, LWPs
are attached to KLT.
• So when a blocking system call is made only
that LWP is blocked i.e. that KLT is blocked
but the kernel can schedule another KLT.
Adv: a blocking SC will not block the entire
process.
Disadv: creation & deletion of LWPs is
expensive just like kernel level thread.
14
Code Migration
Why?
• Overall system performance should be
improved.
• i.e. move process from heavily loaded process
to lightly loaded machine.

15
Code Migration Examples
• Moving (part of) a client to a server –
processing data close to where the data resides.
It is often too expensive to transport an entire
database to a client for processing, so move the
client to the data.
• Moving (part of) a server to a client –
checking data prior to submitting it to a server.
The use of local error-checking (using
JavaScript) on Web forms is a good example of
this type of processing. Error-check the data
16
close to the user, not at the server.
Code Migration Models

• A running process consists of three


“segments”:
1. Code – instructions.
2. Resource – external references to
resources like files, printers, etc.
3. Execution – current state.

17
Code Migration Characteristics

• Weak Mobility: just the code is moved –


and it always restarts from its initial state.
– e.g., Java Applets.
– Comment: simple implementation, but limited
applicability.
• Strong Mobility: code & state is moved –
and execution restarts from the next statement.
– e.g., D’Agents.
– Comment: very powerful, but hard to implement.
18
More Characteristics
• Sender-Initiated vs. Receiver-Initiated.
• Which side of the communication starts
the migration?
1. The machine currently executing the code
(known as sender-initiated)
2. The machine that will ultimately execute
the code (known as receiver-initiated).

19
Models for Code Migration

21 Alternatives for code migration


Migration & Local Resources
• Resource Segment requires special attention.
• It needs to be changed
• E.g. Reference to a PORT needs to be changed
when the process moves to another location.
• But reference to a file (by means of an URL)
will remain the same.

22
Types of Process-to-Resource Binding
• Strongest: Binding-by-Identifier (BI) –
Process refers to a resource by its identifier.
– E.g. Process uses a URL to refer to a specific
website.

• Binding-by-Value (BV) –
Weaker than BI, only the value of the resource
is needed.
– E.g. Program relies on std. libraries (e.g. libraries in
C, JAVA etc.)
23 – Such libraries should be locally available.
Types of Process-to-Resource
Binding
• Weakest: Binding-by-Type (BT) –
Process needs only a resource of a specific type.
– e.g., references to local devices such as monitors,
printers etc.

24
More Resource Classification
• Resources are further distinguished as one of:
1. Unattached: a resource that can be moved easily
from machine to machine e.g. data files
2. Fastened: migration is possible, but at a high cost.
E.g. local dbs & websites.
3. Fixed: a resource is bound to a specific machine
or environment, and cannot be migrated. E.g.
Local devices
• Refer to following diagram for a good
summary of resource-to-binding
characteristics (to find out what to do with
25 which resource when).
Migration and Local Resources

Actions to be taken with respect to the references


to local resources when migrating code to
26 another machine
Process Migration
• Process migration is the relocation of a process from
its current location (the source node) to another node
(the destination node).

27
Types

• Non- preemptive
– a process may be migrated before it starts executing
on its source node
• Preemptive
– a process may be migrated during the course of its
execution
• Preemptive process migration is costlier

28
Process Migration Mechanisms
Four major sub-activities
1. Freezing the process on its source node and restarting
it on its destination node
2. Transferring the process's address space from its
source node to its destination node
3. Forwarding messages meant for the migrant process
4. Handling communication between cooperating
processes that have been separated (placed on different
nodes) as a result of process migration

29
Freezing and restarting of process
• Blocks the execution of the migrant process,
postponing all external communication
– immediate blocking - when not executing system
call
– postponed blocking - when executing certain
system calls

30
Freezing and restarting of process
• Wait for I/O operations
– Fast and slow I/O Operations
• wait for fast I/O
• arrange to gracefully resume slow I/O operations at
destination
• Information about Open Files
– takes a snapshot of the process state
• Relocatable information - register contents,
program counter, etc.
31
Address space transfer
• Process state
– execution status (contents of registers), scheduling
information, memory tables, I/O states, process's
identifier, process's user and group identifiers,
information about the files opened by the process
and so on
• Address space (several megabytes) – dominates
– code, data and stack

32
Approaches to address space transfer
• Total freezing - no execution is done while
address space is transferred - simplest, slowest
• Pre transferring - address space is transferred
while the process is still running on the source
node, after the transfer, the modified pages are
picked up
• Transfer on reference - the process is restarted
before the address space is migrated - the pages
are fetched from the source node as the process
33 needs them
34
35
36
Message-Forwarding Mechanisms
• It must be ensured that all pending, en-route,
and future messages arrive at the process's new
location.

37
Message forwarding
• Three types of messages
1. received when the process execution is stopped
on the source node and has not restarted on the
destination node
2. received on the source node after the
execution started on destination node
3. sent to the migrant process after it started
execution on destination node approaches

38
Approaches to message forwarding
• Re-sending - messages of type 1 and 2 are
either dropped or negatively acknowledged, the
sender is notified and it needs to locate the
migrant process - nontransparent
• Origin site - origin node keeps the info on the
current location of the process created there,
all messages are sent to origin which forwards
them to migrant process - expensive, not fault
tolerant
39
Approaches to message forwarding
• Link traversal
• Messages of type 1 are queued and sent to
destination node as part of migration procedure
• Forwarding address (link) is left on source node
to redirect messages of type 2 and 3, link
contains the system-wide unique id of a process
and its last known location - may not be
efficient or fault tolerant

40
Approaches to message forwarding
• Link update mechanism
• During the transfer the source node
sends the notification (link update) of the
transfer to all the nodes to which the process
communicates
• Messages of type 1 and 2 are forwarded by the
source node
• Messages of type 3 are sent directly to the
destination node
41
Co-processes handling
• Need to provide efficient communication
between a parent process and sub-processes
which might have been migrated on different
nodes.
• No separation of co-processes
– disallow migration of a process if it has
children
– migrate children together with process

42
Co-processes handling
• Home node (origin site) concept
all communication between co-processes is
handled through home node
expensive

43
Migration in heterogeneous system
• DS consists of heterogeneous system.
• So code segment should be executed on each
platform.
• Weak Mobility- less severe problem.
• Because there is no run time info. that needs to
be transferred.
• Just compile the source code for different
platform.

44
Migration in heterogeneous system
• Strong mobility
• If same OS & same machine architecture
• Then possible to pass execution segment as it
is.
• Execution seg – data that is private to the
process. i.e. current stack (temp. data + register
values)

45
Migration in heterogeneous system
• Code migration is restricted to specific points

46
Migration in Heterogeneous DS’s

3-15

Using a migration stack: the principle of maintaining a migration stack to


support migration of an execution segment in a heterogeneous environment.
47 Usually requires changes to the programming language and its environment.

You might also like