Processes: Code Migration

23
Processes: Code Processes: Code Migration Migration Chapter 3 Chapter 3 Will Cameron Will Cameron CSC 8530 CSC 8530 Dr. Schragger Dr. Schragger

description

Processes: Code Migration. Chapter 3 Will Cameron CSC 8530 Dr. Schragger. Overview. What is Code Migration What does it offer a distributed system? Models for Code Migration Weak Mobility and Strong Mobility Sender and Receiver Initiated Migration and Local Resources Binding Categories - PowerPoint PPT Presentation

Transcript of Processes: Code Migration

Page 1: Processes: Code Migration

Processes: Code MigrationProcesses: Code Migration

Chapter 3Chapter 3Will CameronWill Cameron

CSC 8530CSC 8530Dr. SchraggerDr. Schragger

Page 2: Processes: Code Migration

OverviewOverview

• What is Code MigrationWhat is Code Migration

• What does it offer a distributed system?What does it offer a distributed system?

• Models for Code MigrationModels for Code Migration

• Weak Mobility and Strong MobilityWeak Mobility and Strong Mobility

• Sender and Receiver InitiatedSender and Receiver Initiated

• Migration and Local ResourcesMigration and Local Resources

• Binding CategoriesBinding Categories

• Heterogeneous MigrationHeterogeneous Migration

Page 3: Processes: Code Migration

Code MigrationCode Migration

• ““Moving programs between machines with Moving programs between machines with the intention to have those programs be the intention to have those programs be executed at the target” (Tanenbaum and executed at the target” (Tanenbaum and Steen)Steen)

• Traditionally code migration in distributed Traditionally code migration in distributed systems took place as process migrationsystems took place as process migration

• The execution status of a program, pending signals, The execution status of a program, pending signals, other parts of the environment must be moved as wellother parts of the environment must be moved as well

• Entire process moved from one machine to anotherEntire process moved from one machine to another

• Costly and intricate task, only done for good reason: Costly and intricate task, only done for good reason: performanceperformance

Page 4: Processes: Code Migration

Why Code Migration?Why Code Migration?• Overall system performance can be Overall system performance can be

improved if processes are moved from improved if processes are moved from heavily-loaded to lightly-loaded machinesheavily-loaded to lightly-loaded machines

– Where ‘load’ is CPU queue length, CPU Where ‘load’ is CPU queue length, CPU utilizationutilization

• Load distribution algorithms played Load distribution algorithms played important roleimportant role

– Allocation and redistribution of tasks with Allocation and redistribution of tasks with respect to a set of processorsrespect to a set of processors

– In modern DS optimizing computing capacity In modern DS optimizing computing capacity is less an issue than trying to minimize is less an issue than trying to minimize communicationcommunication

– Migration to a safer environmentMigration to a safer environment

Page 5: Processes: Code Migration

PerformancePerformance– It generally makes sense to process data close to It generally makes sense to process data close to

where those data reside (get client server split where those data reside (get client server split slide)slide)

• Example: Client-server system where the server Example: Client-server system where the server manages a huge DBmanages a huge DB– If a client needs to do many db operations involving lots of If a client needs to do many db operations involving lots of

queriesqueries– It may be better to transport part of the client application to It may be better to transport part of the client application to

the server and send only the results over the networkthe server and send only the results over the network– Otherwise it may be swamped with the transfer of data Otherwise it may be swamped with the transfer of data

from the server to clientfrom the server to client

• Example: Migrating parts of the server to the clientExample: Migrating parts of the server to the client– Clients need to fill in forms translated into a series Clients need to fill in forms translated into a series

database operationsdatabase operations– Process the form on the client, sending only the completed Process the form on the client, sending only the completed

form to the serverform to the server– Reduce large number of small messages across the Reduce large number of small messages across the

networknetwork– Client perceives better performance while the server Client perceives better performance while the server

spends less time on form processing and communicationspends less time on form processing and communication

Page 6: Processes: Code Migration

Multitiered Architectures (1)Multitiered Architectures (1)

• Alternative client-server organizations (a) – (e).Alternative client-server organizations (a) – (e).

1-29

Page 7: Processes: Code Migration

Parallelism Parallelism

– Code Migration can provide parallelismCode Migration can provide parallelism– But without usual parallel difficulties due But without usual parallel difficulties due

to the independence of code copiesto the independence of code copies• Fewer worries concerning the overriding of a Fewer worries concerning the overriding of a

shared address space, etcshared address space, etc

• ExamplesExamples– Implementing a web search as a small mobile Implementing a web search as a small mobile

program that moves from site to siteprogram that moves from site to site– Make several copies of it, send off to different sites to Make several copies of it, send off to different sites to

speed searchspeed search

Page 8: Processes: Code Migration

FlexibilityFlexibility– Traditional Distributed ApplicationsTraditional Distributed Applications

– Partition the application into different partsPartition the application into different parts– Decide in advance what machine each part should be executedDecide in advance what machine each part should be executed– Lead to multi-tiered client-server applications in chapter 1Lead to multi-tiered client-server applications in chapter 1

– If code can move between different machinesIf code can move between different machines• Can dynamically configure distributed systemsCan dynamically configure distributed systems

– Example: Server interface to a file system Example: Server interface to a file system • Client side implementation of file system interface needs to be Client side implementation of file system interface needs to be

linked to client applicationlinked to client application• Thus the software would need to be readily available to the client Thus the software would need to be readily available to the client

at the time the client application is developedat the time the client application is developed• Alternative: server provide client implementation when the client Alternative: server provide client implementation when the client

binds to the serverbinds to the server• Client dynamically downloads the implementation, sets it up, Client dynamically downloads the implementation, sets it up,

invokes serverinvokes server• RequirementsRequirements

– Protocol for downloading and initializing code is standardizedProtocol for downloading and initializing code is standardized– Downloaded code must be compatible with client machineDownloaded code must be compatible with client machine

• Security issue: (bring in Applets, security, etc)Security issue: (bring in Applets, security, etc)– Trusting the downloaded code only implements the advertised Trusting the downloaded code only implements the advertised

interfaceinterface

Page 9: Processes: Code Migration

Reasons for Migrating CodeReasons for Migrating Code

• The principle of dynamically configuring a client to communicate to a server. The principle of dynamically configuring a client to communicate to a server. The client first fetches the necessary software, and then invokes the server.The client first fetches the necessary software, and then invokes the server.

Page 10: Processes: Code Migration

Models for Code MigrationModels for Code Migration– Framework of three segmentsFramework of three segments

• Code SegmentCode Segment– Contains the set of instructions that make up the Contains the set of instructions that make up the

program being executedprogram being executed

• Resource SegmentResource Segment– References to external resources needed by the References to external resources needed by the

processprocess Files, printers, devices, other processesFiles, printers, devices, other processes

• Execution (Process) SegmentExecution (Process) Segment– Store the current execution state of a processStore the current execution state of a process

Private data, stack, program counterPrivate data, stack, program counter

Page 11: Processes: Code Migration

Weak MobilityWeak Mobility– Transfer only the Code Segment with Transfer only the Code Segment with

some initialization datasome initialization data• Program always starts from its initial stateProgram always starts from its initial state

– Java applets Java applets

• BenefitBenefit– Simplicity Simplicity – Just requires portable, executable code for the Just requires portable, executable code for the

targettarget

• Matters whether the code is merely executed Matters whether the code is merely executed by target process or a new process is createdby target process or a new process is created– Applets are simply downloaded and executed in Applets are simply downloaded and executed in

browser spacebrowser space– No need for new process, communication at targetNo need for new process, communication at target– Drawback: target process needs to be protected by Drawback: target process needs to be protected by

malicious or inadvertent code executionsmalicious or inadvertent code executions– OS solution: create a separate processOS solution: create a separate process

Page 12: Processes: Code Migration

Strong MobilityStrong Mobility– Execution segment transferred as wellExecution segment transferred as well

• Running process stopped, moved to another Running process stopped, moved to another machine, resumedmachine, resumed

• More powerful than weak, much harder to More powerful than weak, much harder to implementimplement

– Or Remote CloningOr Remote Cloning• Yields an exact copy of the original process but on Yields an exact copy of the original process but on

a different machinea different machine

• Executed in parallel to original Executed in parallel to original – UNIX: fork off a child process onto a remote machineUNIX: fork off a child process onto a remote machine– Benefit:Benefit:– Model closely resembles existing, but on another Model closely resembles existing, but on another

machinemachine

– Simple way to improve distribution transparencySimple way to improve distribution transparency

Page 13: Processes: Code Migration

Models for Code MigrationModels for Code Migration

• Alternatives for code migration.Alternatives for code migration.

Page 14: Processes: Code Migration

Sender-Initiated migrationSender-Initiated migration– Migration initiated at the machine where Migration initiated at the machine where

the code currently resides or being the code currently resides or being executedexecuted

• uploading programs to a server: Dist. File uploading programs to a server: Dist. File SystemSystem

• Sending a search program across the Internet to Sending a search program across the Internet to a Web database server to perform queriesa Web database server to perform queries

– Often requires the client be previously Often requires the client be previously registered and authenticated at that serverregistered and authenticated at that server

• Server must know all its clients b/c client will Server must know all its clients b/c client will want disk: securitywant disk: security

Page 15: Processes: Code Migration

Retriever-Initiated migrationRetriever-Initiated migration– Initiative for code migration taken by the Initiative for code migration taken by the

target machinetarget machine• Java appletsJava applets

– Simpler to implement, client takes initiative, Simpler to implement, client takes initiative, • downloading done anonymously downloading done anonymously

• server not interested in the client’s resourcesserver not interested in the client’s resources

• Code migration to client done just for improving Code migration to client done just for improving client side performance client side performance

• Just server memory and network connections Just server memory and network connections need be protectedneed be protected

Page 16: Processes: Code Migration

Migration and Local Migration and Local ResourcesResources

• This makes code migration difficult, resource This makes code migration difficult, resource segment cannot be simply transferred without segment cannot be simply transferred without being changedbeing changed– Process reference to a specific TCP port to Process reference to a specific TCP port to

communicate to another processcommunicate to another process When moved to another location, must give up port When moved to another location, must give up port

and request a new oneand request a new one

Page 17: Processes: Code Migration

Binding CategoriesBinding Categories– Binding by identifierBinding by identifier

• Not a problem: absolute URL, still validNot a problem: absolute URL, still valid

• FTP server by internet addressFTP server by internet address

• Local communication endpoints also binding by identifierLocal communication endpoints also binding by identifier

– Bind by valueBind by value• Weaker process-to-resource binding, only the value is Weaker process-to-resource binding, only the value is

neededneeded

• Execution not effected if another resource provide the same Execution not effected if another resource provide the same valuevalue

• Example: program rely on standard libraries, C, JavaExample: program rely on standard libraries, C, Java

• Always available but exact location could differAlways available but exact location could differ

– Bind by typeBind by type• Process indicates it only needs a resource of a given typeProcess indicates it only needs a resource of a given type

• References to local devices: monitors, printers..References to local devices: monitors, printers..

Page 18: Processes: Code Migration

The Resource-to-Machine The Resource-to-Machine Bindings Bindings – Often need to change the references to Often need to change the references to

resources but cannot affect the kind of resources but cannot affect the kind of process-to-resource bindingprocess-to-resource binding

• Can a reference be changed, depends on Can a reference be changed, depends on whether that resource can be moved and codewhether that resource can be moved and code– UnattachedUnattached resources can be easily moved, typically resources can be easily moved, typically

data files associated with program to be migrateddata files associated with program to be migrated– A A fastenedfastened resource can only be moved with relatively resource can only be moved with relatively

high costhigh cost Examples: local databases, complete web sitesExamples: local databases, complete web sites In theory not dependent on machine, but infeasible In theory not dependent on machine, but infeasible

to moveto move– Fixed ResourcesFixed Resources

Intimately bound to a specific machine or Intimately bound to a specific machine or environmentenvironment

often local devices, local communication endpointoften local devices, local communication endpoint

• Establishing global references can be costly Establishing global references can be costly

Page 19: Processes: Code Migration

Migration and Local Migration and Local ResourcesResources

• GR: Global ReferenceGR: Global Reference

• MV: Move the resourceMV: Move the resource

• CP: Copy the value of the resourceCP: Copy the value of the resource

• RB: Rebind process to locally available resourceRB: Rebind process to locally available resource

• Actions to be taken with respect to the references to local Actions to be taken with respect to the references to local resources when migrating code to another machine.resources when migrating code to another machine.

UnattachedUnattached FastenedFastened FixedFixed

By identifierBy identifier

By valueBy value

By typeBy type

MV (or GR)MV (or GR)

CP ( or MV, GR)CP ( or MV, GR)

RB (or GR, CP)RB (or GR, CP)

GR (or MV)GR (or MV)

GR (or CP)GR (or CP)

RB (or GR, CP)RB (or GR, CP)

GRGR

GRGR

RB (or GR)RB (or GR)

Resource-to machine binding

Process-to-resource

binding

Page 20: Processes: Code Migration

Heterogeneous MigrationHeterogeneous Migration– Realistic situation in DSRealistic situation in DS– Migration requires that each platform is supported for code Migration requires that each platform is supported for code

segmentsegment– IssuesIssues

• Weak MobilityWeak Mobility– No runtime info to transfer, just recompile the source code , but generate No runtime info to transfer, just recompile the source code , but generate

different segments, one per platformdifferent segments, one per platform

• Strong mobilityStrong mobility– Transfer of the execution segment: PC, registers, stack, etcTransfer of the execution segment: PC, registers, stack, etc

Highly dependent on platform Highly dependent on platform Same OS and architectureSame OS and architecture

– SolutionSolution Only allow code migration at specific execution points: when the next Only allow code migration at specific execution points: when the next

function, method, or subroutine is called (C, Java)function, method, or subroutine is called (C, Java) Migration stackMigration stack The runtime system maintains a machine independent program stackThe runtime system maintains a machine independent program stack Updated when a subroutine is called or when execution returns from Updated when a subroutine is called or when execution returns from

oneone Identifier for called subroutineIdentifier for called subroutine Jump Label pushed as wellJump Label pushed as well The address where execution should continue when the caller returnsThe address where execution should continue when the caller returns

Page 21: Processes: Code Migration

Migration in Heterogeneous Migration in Heterogeneous SystemsSystems

• The principle of maintaining a migration stack to support migration The principle of maintaining a migration stack to support migration of an execution segment in a heterogeneous environmentof an execution segment in a heterogeneous environment

3-15

Page 22: Processes: Code Migration

Heterogeneous MigrationHeterogeneous Migration – If migration takes place when a subroutine is calledIf migration takes place when a subroutine is called

• Runtime system marshals all global program-specific data to form Runtime system marshals all global program-specific data to form execution segmentexecution segment

• Machine specific data and current stack ignoredMachine specific data and current stack ignored• Marshalled data transferred to destination along with the migration stackMarshalled data transferred to destination along with the migration stack

– Only works if compiler generates code to update the migration stack Only works if compiler generates code to update the migration stack whenever a subroutine is entered or exitedwhenever a subroutine is entered or exited

– Generates labels in the caller’s code allowing a return from a Generates labels in the caller’s code allowing a return from a subroutine to be implemented as a (machine-independent) jumpsubroutine to be implemented as a (machine-independent) jump

– Suitable runtime system neededSuitable runtime system needed– Virtual MachinesVirtual Machines

• 1970s: Pascal machine independent intermediate code for an abstract 1970s: Pascal machine independent intermediate code for an abstract virtual machine on many platformsvirtual machine on many platforms

• Did not catch on with other languages: CDid not catch on with other languages: C• 1990s: Scripting Languages and Java1990s: Scripting Languages and Java

– All such systems:All such systems: Rely on a virtual machine to directly interpret code (scripting languagesRely on a virtual machine to directly interpret code (scripting languages Or interprets intermediate code generated by compiler (Java bytecode)Or interprets intermediate code generated by compiler (Java bytecode)

– Drawback: we are stuck with a specific languageDrawback: we are stuck with a specific language•

Page 23: Processes: Code Migration

ConclusionsConclusions

• Code Migration is an interesting way to Code Migration is an interesting way to improve distributed efficiency, through a improve distributed efficiency, through a sort of multiprograming provided by sort of multiprograming provided by parallelismparallelism

• Its various manifestations raise issues of Its various manifestations raise issues of security and process migration which must security and process migration which must be addressed be addressed

• Virtual Machines provide a nice solution to Virtual Machines provide a nice solution to heterogeneous migration issues heterogeneous migration issues