Restructuring Distributed Algorithms for Mobile Computing Environment
flink重分区策略

Flink对于经过转换操作之后的DataStream,提供了一系列的底层操作接口,能够帮我们实现数据流的手动重分区。
为了同keyBy相区别,我们把这些操作统称为“物理分区” 操作。
Flink 中算子改变并行度,默认RebalancePartitioner分区策略。
常见的物理分区策略有随机分配(Random)、轮询分配(Round-Robin)、重缩放(Rescale)和广播(Broadcast)。
1. 随机分区(shuffle):最简单的重分区方式就是直接“洗牌”。
通过调用DataStream的.shuffle()方法,将数据随机地分配到下游算子的并行任务中去。
随机分区服从均匀分布(uniform distribution),所以可以把流中的数据随机打乱,均匀地传递到下游任务分区。
2. CustomPartitionerWrapper:用户根据自己实现Partitioner接口,来定义自己的分区逻辑。
3. ForwarPartitioner:用户将记录输出到下游本地的算子实例。
它要求上下游算子并行度一样。
简单的说,ForwarPartitioner可以来做控制台打印。
4. GlobaPartitioner:数据会被分发到下游算子的第一个实例中进行处理。
5. KeyGroupStreamPartitioner:Hash分区器,会将数据按照key 的Hash值输出到下游的实例中。
6. RebalancePartitioner:数据会被循环发送到下游的每一个实例额的Task中进行处理。
7. RescalePartitioner:这种分区器会根据上下游算子的并行度,循环的方式输出到下游算子的每个实例。
如需更多关于Flink的信息,建议查阅相关资料或者咨询计算机领域专业人士获取帮助。
稀疏矩阵csr存储规则

稀疏矩阵csr存储规则
稀疏矩阵CSR存储规则。
稀疏矩阵是指大部分元素为零的矩阵。
由于这种矩阵在实际应
用中非常常见,因此对其进行高效存储和计算非常重要。
其中,CSR (Compressed Sparse Row)是一种常用的稀疏矩阵存储格式,它通
过压缩矩阵的行来节省存储空间并提高计算效率。
在CSR存储规则中,矩阵被分解为三个数组,值数组(values)、列偏移数组(col_indices)和行偏移数组
(row_ptr)。
这种存储方式的核心思想是将矩阵按行压缩,只存储
非零元素的值以及它们所在的列索引,同时使用行偏移数组记录每
行非零元素在值数组中的起始位置。
具体来说,值数组存储所有非零元素的值,按照行优先的顺序
排列;列偏移数组存储每个非零元素所在的列索引;而行偏移数组
则记录了每行非零元素在值数组中的起始位置。
采用CSR存储规则的稀疏矩阵具有较高的存储效率和计算效率。
它可以有效地减少存储空间的占用,并且在进行矩阵乘法等计算时
能够更快地定位和访问非零元素。
因此,在大规模稀疏矩阵的处理中,CSR存储规则被广泛应用于优化存储和计算性能。
总的来说,CSR存储规则为稀疏矩阵的高效存储和计算提供了重要的技术支持,为处理大规模稀疏矩阵问题提供了有力的工具。
通过合理地利用存储空间和加速计算速度,CSR存储规则为稀疏矩阵的应用和研究提供了便利和支持。
提高防火墙集群效率的分散式均衡算法及实现

Ne l a — aa c dag rtm c e s rwal’ u tre c e c w o d b ln e lo i h t i r a ef e l c se f in y on i sl i
W UXu n. S n -a a UI 0 Ho gj n i
a gci t we t drso s e a e o db l cr h e odbl c re'b re l ieydcesdadtefe l t e s i p n eh tt t a -a e n i ln ’ g a e h n t d a oh l n a .T a —aa es vr ud nir av l erae rwa l n e s se t n h i l
( .Colg f n g me t hn iest f ce c n e h oo y 1 l eo a e n iaUnv ri o in ea dT c n lg ,Hee 3 0 6 hn ; e Ma C y S fi 0 2 ,C ia 2
2 r ut U ies , h ee cdmyS i c, e ig1 0 3 , hn) .G a a nvri C i s a e c n e B in 0 0 9 C ia d e y t n A e j
维普资讯
第2 卷 7
V0 . 7 12
第 1 期 2
NO 1 .2
计 算 机 工 程 与 设 计
Co p trE g n ei ga dDe in m ue n ie rn n sg
20 年 6 06 月
Jn 0 6 u e2 0
cu t r fii n y i c e s d l se s ' e ce c i r a e . s n Ke r s c mp t r n t o k ; f e l cu t r la — a a c ; d s i u e l o t m ywo d : o u e ; e w r s i wal l se ; o d b l e r ; n it b t d ag r h r i
obfuscate的混淆加密规则

obfuscate的混淆加密规则英文回答:Obfuscation is a technique used to make code or data difficult to understand or reverse engineer. It involves modifying the code or data in such a way that it becomes more complex and harder to comprehend. The purpose of obfuscation is to deter unauthorized access, protect intellectual property, and prevent software piracy.There are several common techniques used in obfuscation. One such technique is renaming variables and functions to meaningless or confusing names. For example, a variable named "password" could be renamed to something like"x1a2b3c4d". This makes it harder for someone to understand the purpose of the variable and its role in the code.Another technique is code restructuring, where the code is rearranged in a way that makes it more difficult tofollow the logic. This can involve adding unnecessary code,removing whitespace and comments, or splitting code into multiple files. The goal is to make the code appear more convoluted and confusing.Obfuscation can also involve encrypting sensitive data or using encryption algorithms to hide important parts of the code. This makes it harder for someone to extract sensitive information or understand the inner workings of the software.Additionally, obfuscation can include the use of anti-debugging techniques to make it harder for someone to analyze the code while it is running. This can involve detecting if a debugger is attached and taking actions to prevent it from functioning properly.Overall, the goal of obfuscation is to make itdifficult for someone to understand or modify the code, while still allowing it to function correctly. It is important to note that obfuscation is not foolproof and can be bypassed by determined attackers. However, it can provide an additional layer of protection and make it moretime-consuming for someone to reverse engineer the code.中文回答:混淆加密是一种用于使代码或数据难以理解或逆向工程的技术。
ai 修改英语作文

ai 修改英语作文Artificial Intelligence has become an increasingly prevalent tool in the field of written communication and content creation. One of the most promising applications of AI in this domain is its ability to assist in the editing and refinement of written works, including academic essays and other forms of formal writing. As AI technology continues to advance, the potential for AI-powered editing tools to enhance the quality and coherency of English essays is becoming more and more apparent.One of the primary ways in which AI can contribute to the editing of English essays is through the use of natural language processing (NLP) algorithms. These algorithms are designed to analyze the structure, grammar, and overall coherence of written text, and provide targeted feedback and suggestions for improvement. By leveraging NLP, AI-powered editing tools can identify and flag common grammatical errors, such as subject-verb agreement issues, improper use of tenses, and incorrect sentence structure. This can be particularly beneficial for non-native English speakers or those who struggle with the nuances of the language, as it can help themidentify and correct these errors before submitting their work.In addition to catching grammatical errors, AI-powered editing tools can also assist in the overall organization and flow of an essay. Through the use of machine learning algorithms, these tools can analyze the structure of an essay, identify areas where the argument or narrative may be unclear or disjointed, and provide suggestions for rearranging or restructuring the content to improve its coherence and logical progression. This can be especially useful for students who are still developing their essay-writing skills, as it can help them to craft more well-organized and persuasive essays.Another key benefit of AI-powered editing tools is their ability to provide more objective and impartial feedback on the content and quality of an essay. Unlike human editors or proofreaders, who may bring their own biases and personal preferences to the editing process, AI algorithms can analyze an essay purely based on established writing conventions and best practices. This can help to ensure that the feedback and suggestions provided are more focused on improving the overall quality and effectiveness of the essay, rather than on subjective stylistic preferences.Furthermore, AI-powered editing tools can also be programmed to provide more nuanced and contextual feedback on the content of an essay. By analyzing the specific topic, argument, and evidencepresented in the essay, these tools can offer suggestions for strengthening the overall persuasiveness and clarity of the writing. This can include recommendations for incorporating additional supporting evidence, clarifying key points, or restructuring the essay to better align with the intended purpose and audience.One potential concern with the use of AI-powered editing tools in the context of English essays is the risk of over-reliance or over-dependence on the technology. While these tools can be highly effective in identifying and addressing certain types of writing issues, they should not be seen as a replacement for the critical thinking and analytical skills that are essential to effective essay writing. It is important for students to maintain a balanced approach, using AI-powered editing tools as a supplement to their own careful proofreading and revision processes, rather than as a substitute for these essential skills.Additionally, there are concerns about the potential for AI-powered editing tools to introduce new types of errors or biases into the writing process. As these tools are ultimately reliant on the algorithms and data that they are trained on, there is a risk that they may perpetuate or amplify certain biases or inaccuracies that are present in their underlying systems. It is important for users of these tools to be aware of these potential limitations and to approach the feedback and suggestions provided with a critical eye.Despite these challenges, the potential benefits of AI-powered editing tools in the context of English essays are substantial. By leveraging the power of natural language processing and machine learning, these tools can help to improve the overall quality and effectiveness of written work, while also freeing up valuable time and resources for students and educators. As the technology continues to evolve and become more sophisticated, it is likely that we will see even greater advancements in the ability of AI to enhance the writing and editing process.In conclusion, the use of AI-powered editing tools in the context of English essays represents a promising and exciting development in the field of written communication. By providing targeted feedback and suggestions for improvement, these tools can help students to craft more polished and effective essays, while also freeing up valuable time and resources for other aspects of the writing process. However, it is important to approach the use of these tools with a balanced and critical perspective, recognizing both their potential benefits and their limitations. Ultimately, the successful integration of AI-powered editing tools into the essay-writing process will depend on the ability of students and educators to leverage this technology in a way that complements and enhances their own critical thinking and analytical skills.。
面向异构环境的分布式机器学习算法设计与优化

面向异构环境的分布式机器学习算法设计与优化随着大数据时代的到来,机器学习在各个领域的应用越来越广泛。
然而,传统的机器学习算法在处理大规模数据时面临着计算资源不足、计算速度慢等问题。
为了解决这些问题,分布式机器学习应运而生。
分布式机器学习利用多台计算机进行协同工作,将数据划分为多个部分进行处理和训练,从而提高了计算速度和模型的准确性。
然而,在实际应用中,我们常常面临着异构环境的挑战。
异构环境指的是由不同类型、不同性能、不同存储能力等特点的计算资源组成的环境。
这些异构资源对于分布式机器学习算法设计和优化提出了新的要求和挑战。
首先,在异构环境中进行任务划分是一个关键问题。
由于不同类型、性能差异较大的计算资源存在差别,我们需要合理地将任务划分到各个资源上,以充分利用它们各自特点,并且尽量减少任务之间通信开销。
其次,在任务划分之后,异构环境中的计算资源之间的通信成为一个重要问题。
由于异构资源之间的通信速度差异较大,通信开销可能成为整个分布式机器学习算法的瓶颈。
因此,我们需要设计高效的通信机制,减少通信开销,并且充分利用高速计算资源。
此外,在异构环境中进行模型训练也是一个具有挑战性的问题。
由于不同类型、性能差异较大的计算资源之间存在差别,我们需要设计适应性强、效果好的模型训练算法。
这样才能充分利用各个资源,并且获得较好的模型准确性。
针对上述挑战,研究者们提出了许多面向异构环境的分布式机器学习算法设计和优化方法。
首先,在任务划分方面,研究者们提出了多种任务划分策略。
例如,基于数据特征和计算资源特征进行任务划分、基于负载均衡进行任务划分等。
这些策略可以根据实际情况选择合适的方法,并且充分利用各个计算资源。
其次,在通信方面,研究者们提出了多种高效的通信机制。
例如,基于数据压缩和数据量化的通信机制,可以减少通信开销。
此外,基于异步通信和分布式共享内存的通信机制,可以提高通信效率。
这些方法可以根据实际情况选择合适的方法,并且减少整个分布式机器学习算法的通信开销。
PostgreSQL中的高可用性解决方案

PostgreSQL中的高可用性解决方案在现代的数据应用中,高可用性(High Availability,HA)是一个至关重要的因素。
在数据库领域,PostgreSQL提供了一些高可用性的解决方案,可以帮助用户实现数据的持续可用性和系统的可靠性。
本文将介绍一些常用的PostgreSQL高可用性解决方案。
1. 数据复制(Replication)数据复制是一种常见的高可用性解决方案,它通过将数据从主服务器复制到一个或多个备用服务器,实现数据的冗余存储和故障恢复能力。
PostgreSQL提供了多种数据复制方法,包括基于日志的物理复制(Physical Replication)和基于逻辑复制(Logical Replication)。
1.1 基于日志的物理复制基于日志的物理复制是PostgreSQL内置的一种数据复制方法,它通过复制主服务器上的事务日志(WAL),将变更的数据块物理复制到备用服务器。
这种方法可以实现快速的数据复制和故障切换,但对备用服务器的版本和配置要求较高。
1.2 基于逻辑复制基于逻辑复制是PostgreSQL 9.4及以上版本中引入的一种数据复制方法。
它通过解析和应用主服务器上的逻辑变更(例如INSERT、UPDATE、DELETE语句),将变更的数据逻辑复制到备用服务器。
这种方法相对灵活,可以实现不同版本和配置的备用服务器。
2. 流复制(Streaming Replication)流复制是PostgreSQL中一种基于日志的物理复制方法,它通过流式传输事务日志(WAL)来实现数据的持续复制和故障切换。
流复制要求主服务器和备用服务器之间有稳定的网络连接,并且备用服务器必须实时接收并应用主服务器上的更改。
2.1 同步流复制同步流复制是一种高可用性的方法,它确保主服务器上的事务在提交后,备用服务器立即应用并确认。
这种方法可以提供零数据丢失和最小的故障恢复时间,但对网络延迟和性能要求较高。
关于科技的好处和坏处的英语作文

关于科技的好处和坏处的英语作文Technology has become an integral part of our daily lives, revolutionizing the way we work, communicate, and interact with the world around us. As with any significant development, the impact of technology can be viewed from both positive and negative perspectives. In this essay, we will explore the potential benefits and drawbacks of technological advancements.One of the primary advantages of technology is its ability to enhance productivity and efficiency. In the workplace, technological tools such as computers, software, and automation have streamlined various tasks, allowing employees to accomplish more in less time. This increased productivity has led to cost savings, improved profitability, and a better allocation of resources. Additionally, the rise of remote work and teleconferencing technologies has enabled greater flexibility and work-life balance for many individuals, as they can now perform their duties from the comfort of their homes.Furthermore, technology has revolutionized the field of communication, connecting people across the globe instantaneously. Social media platforms, instant messaging apps, and video conferencing tools have made it easier than ever to stay in touchwith friends, family, and colleagues, regardless of geographical barriers. This connectivity has fostered a sense of global community, facilitating the exchange of ideas, cultural understanding, and the formation of new relationships. In the realm of education, technology has transformed the learning experience, providing students with access to a wealth of information and interactive educational resources. Online courses, virtual classrooms, and educational software have made learning more accessible and personalized, catering to diverse learning styles and needs.In the healthcare sector, technological advancements have led to significant improvements in medical care and patient outcomes. Innovations such as telemedicine, robotic surgery, and advanced diagnostic tools have enhanced the accuracy and efficiency of medical procedures, while also improving patient comfort and reducing recovery times. Additionally, the development of wearable devices and mobile health applications has empowered individuals to take a more active role in managing their own health, promoting preventive care and early intervention.However, the widespread adoption of technology is not without its drawbacks. One significant concern is the potential for job displacement due to automation and artificial intelligence. As machines and algorithms become increasingly capable of performing tasks traditionally done by humans, certain occupations may becomeobsolete or require significant restructuring. This shift can lead to unemployment, income inequality, and the need for comprehensive retraining and reskilling programs to help displaced workers transition to new roles.Another issue arising from the ubiquity of technology is the impact on mental health and well-being. The constant connectivity and information overload facilitated by digital devices can contribute to increased stress, anxiety, and social isolation. The temptation to constantly check social media and engage with online content can disrupt healthy sleep patterns, limit face-to-face interactions, and exacerbate feelings of FOMO (fear of missing out). Prolonged exposure to digital screens has also been linked to physical health problems, such as eye strain, neck and back pain, and decreased physical activity.Furthermore, the reliance on technology has raised concerns about data privacy and security. As more of our personal information and sensitive data are stored and transmitted digitally, the risk of cyber-attacks, data breaches, and identity theft has escalated. Cybercriminals and malicious actors can exploit vulnerabilities in digital systems, potentially compromising individuals' financial information, personal communications, and even national security.In addition to these concerns, the environmental impact oftechnology cannot be overlooked. The production, use, and disposal of electronic devices and infrastructure consume significant amounts of energy and natural resources, contributing to environmental degradation and climate change. The e-waste generated by outdated or discarded technology also poses a growing challenge, as many of these materials are difficult to recycle or dispose of safely.In conclusion, the impact of technology on our lives is multifaceted, with both benefits and drawbacks. While technological advancements have undoubtedly improved productivity, communication, education, and healthcare, they have also introduced new challenges related to job displacement, mental health, data privacy, and environmental sustainability. As we continue to embrace technological progress, it is crucial that we address these concerns and strive to harness the power of technology in a responsible and ethical manner, ensuring that its benefits are maximized while its drawbacks are mitigated. Only through a balanced and thoughtful approach can we fully realize the potential of technology to enhance our lives and create a more sustainable future.。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Restructuring Distributed Algorithms for Mobile Computing EnvironmentArindam Chakraborty,98071 chak@cse.iitk.ac.in Ritesh Kumar,99324 riteshk@cse.iitk.ac.inManish Singh Badwal,98200msbadwal@cse.iitk.ac.induring CS634Mobile Computing course,under the supervision ofDr.R.K.Ghoshrkg@cse.iitk.ac.inIndian Institute of TechnologyDepartment of Computer Science and EngineeringKanpur208016,INDIAAbstractWe present a formalization of a subclass of distributed algorithms(which are used more often in a mobile computing environment)and give principles or thumbrules which must be followed so that the distributed algorithm executes well in themobile computing environment.In this report wefirst start with the classification of standard distributed algorithmsthat are most frequently used in distributed systems and look at how the two-tierprinciple discussed in B.R.Badrinath and Arup Acharya’s paper on restructuringdistributed algorithms,ports to these situations,and what modifications need tobe made.Then we discuss the pros and cons of completely generic restructuring(without requiring to modify the algorithm itself)to mobile-aware solutions wherethe algorithm has to explicitly handle the efects of mobility.We then stress on the importance of design abstraction of resources in a mobile en-vironment so that a greater amount of concurrency can be handled in the resource.To that effect we propose a method to evaluate a’concurrency load’for any ab-straction and use it to tell which of the abstractions would be better in the mobilesituation and in this relation we enumerate two principles which must be followed.1IntroductionDistributed algorithms are algorithms which generally invole more than one host in its execution.These generally are designed to work in networked environments though for describing techniques generally an abstraction(like a graph)is adopted.Someyears earlier,i.e.before mobile computing,distributed algorithms used to be designed keeping static hosts in mind.These algorithms generally execute by sending messages to each other over the network or whatever the communication medium is,which takes care of the synchronization and communication part between the hosts involved in the algorithm.The assumptions that are generally taken are that1.The hosts are static and there is very little cost in locating a host.The cost ismore of sending the message.2.Because the hosts are static,the cost of sending messages to the hosts isfixedand don’t change with time or other factors.rge bandwidth availability is assumed.4.It is also assumed that the hosts are not resource poor.Thefixed hosts haveenough computation power,memory etc.5.The hosts are also not short of power supply.Thus it is assumed that they remainon during the whole algorithm execution and their inability to recieve a message because of a power failure is often a cause of the failure of the algorithm.However,these assumptions must be relaxed in a mobile computing environment be-cause of the following reasons.1.The cost of locating a mobile host is often significant.There are extensive lo-cation management techniques which handle this.At any cost we would like to keepfinding location of a mobile host again and again to a minimum.The cost is taken to be equivalent,if not more,than sending a message(after lookup).2.The mobile environment also has persistence of connections irrespective of themobility of the host.This can cause change of the costs of sending messages to hosts during the algorithm is executing.3.The bandwidth available is very scanty.4.The mobile hosts are resource poor.Also,the amount of resources that can bepresent on the mobile host has a large variation.5.The mobile hosts work on battery and hence to conserve power they frequentlyhave to turn off their network interfaces.Such a mode of execution is called ’doze’mode or powersave mode.This means that we cannot afford to’wake’up the mobile host at unexpected times frequently.All this means that it poses a great challenge to somehow port the existing distributed algorithms to the mobile environment.However,here are a few observations1.As the mobile host is resource poor it is infeasible to do computation on the MH.Thus distributed algorithms which fragment the problem into smaller parts and execute it independently on many machines to get benefit in computing power are ruled out.It is simply because the mobile host is not designed to do a lot2of number crunching.Also,this may also mean requirement of a fast means of comuunication between mobile hosts themselves which is not present.Thus,we would like to disregard distributed algorithms of the above nature.2.Another important class of distributive algorithms deal with synchronization ofactivities.There would not be heavy number crunching code running on the hosts but the host would be participating in operations on globally available resources which require synchronization.This class of algorithms would be ideally be suit-able for restructuring in a mobile environment.This is because the mobile host user would primarily use his mobile host to access services than as mentioned in thefirst point run services on his mobile.One of such projects is the“Wireless Coyote”[4].It is not that the distributed algorithms would not run in the mobile environment.It is only that they would be highly inefficient and costly due to the nature of the mobile computing environment.In fact work on restructuring distributed algorithms generally tend to keep the mobile host away from any computation.The distributed algorithm actually runs on the static hosts only with only the initiation of the algorithm and con-veying results being only place where moile hosts come in.Other than this the only difference is of synchronization between the mobile hosts which is handled by the fixed host acting as a proxy for the mobile host.This principle is well explained in B.R.Badrinath and Arup Acharya’s papers on restructuring distributed algorithms for mobile computing environments[1][2][3].We would like to give another formulation for distributed algorithms in a mobile computing envirnment.However,we would restrict ourselves those classes of algo-rithms which donot run distributed services but those which deal with synchronization issues in accessing a service from many hosts.A typical example of such a service may be a distributedfilesystem.2Issues involved in porting distributed algorithms to mobile environmentsLet us look at the issue we are faced with when restructuring our class of algorithms into a mobile computing environment.We basically have to take care of two things.Bandwidth and resourcesSynchronization2.1Bandwidth and resourcesWhenever we have an operation to be executed on a remote object(the obvious case in a mobile computing environment)we would have to send messages to the host which hosts the object.Our operations would be performed then by the remote host on our behalf(Though it is some times convenient to think of the host’logically’executing the operation directly on the remote host).Whenever we require to send messages we would require two things31.Figure out whom to send the message.This operation is exceptionally costly ina mobile computing environment and is handled by extensive location manage-ment techniques.2.Actually send the message.If the message was supposed to be sent to afixed host the above two activities are carried out by the MSS of the mobile host in thefixed network.This is a lot less costly than the case when the message is sent to another mobile host.This is because no location search is required in this case(unless the MH explicitly moves from the MSS’s cell in which case the MSS would have to search for the MH to send it the message back).Thus its best if we restrict sending messages to mobile hosts except that case when the MSS has to send one to one of its MHs.However this has important implication on the objects and operations model we are developing.As mobile hosts are not advised to send messages to another mobile hosts we indirectly are saying that a mobile host should not execute operations on an object on another mobile host.Basically it gives us a principle:”We should not have objects (which are remotely accessed)on mobile hosts.They must be present only onfixed hosts.”We may note that this is also in accordance with the two tier principle illustrated in B.R.Badrinath and Arup Acharya’s structuring of distributed algorithms[3].The very fact that a mobile host is poor in computing and power resources,has low band-width and high cost location search caused the two tier principle to say that as much as possible all computation work should be done onfixed hosts leaving the least for the mobile host.In our case an object is associated with something which requires com-puting power and bandwidth to exist and we are disallowing such things on the mobile host.The role of the mobile host comes is being involved in the thread of execution which executes operations on the object.2.2SynchronizationWhenever we have a centrally located resource which is accessed from a number of places there is contention.Let us call our centrally located resource as an object.Each sequence of operations that are being initiated from a specific place(a mobile host) can be called a’thread’of execution.Thus we many concurrently running threads of execution each of which are trying to run operations on an object.For the time being let us take no assumptions of where this object can be.It can be on afixed host or it may also reside on a mobile host.Whenever we have concurrent threads operating on the same object there is contention.The threads compete for gaining access to the object.As we donot want the threads to run operations on objects in an inconsistent state we would like to synchronize the operations on the object.We would later discuss what would be a formal way to model the synchronization primitives.43Bandwidth and ResourcesWe start by stating the two-tier principle and propounded by Badrinath and Acharya in their paper on restructuring distributed algorithms.To the extent possible,computation and communication costs of an algorithm is borne by the static portion of the network.This attempts to avoid locating a mobile par-ticipant and lowers the”search cost”of the algorithm;additionally,the number of operations performed at the mobile hosts and thereby,consumption of battery power, which is a critical resource for mobile hosts,is kept to a minimum.The general pattern of all distributed algorithms can be visualised as comprising a com-munication component and calculation component.Being a distributed execution,the calculation component is limited to the individual hosts and during these calculations it might require to communicate with its neighbours or other nodes,so as to exchange information regarding the state of its or other’s registers,the results of current compu-tations,contacting some host for ordering or maintenance tasks in the algorithm or to get initialization parameters for the next phase of computation and so on.Thus it is nat-ural to expect that a distributed system of hosts would show bursts of communication in between periods of local computation.This is the model wefind in the context of fixed hosts but once the possibility of mobile hosts comes into the picture,we are faced with the problems of”communication costs”,”location detection of mobile host”and ”scarcity of computational resources at mobile hosts”.To deal with the later problem, we have to try and schedule all the computation intensive parts of the algorithm to the fixed hosts,to as great an extent as possible.To address thefirst two issues,we will try to adapt the”search”,”inform”and”proxy”strategies introduced in Badrinath and Acharya’s paper in relation to restructuring a logical token ring network.These princi-ples are in fact more generally and can be used in various other classes of distributed algorithms,as we shall shortly describe.First we briefly look at what these strategies are:1.Search The Search strategy basically entails that each MSS(Mobile Service Sta-tion)is responsible for the MHs(Mobile Hosts)in its cell.So all the communi-cation primitives are executed by the MSS on behalf of the MH and the results of the communication are then communicated to the MH.However if an MH changes its location so that it moves to a different MSS jurisdiction then a search has to be done in the entire network to locate the current location of the MH.This requires broadcasting the location query for the MH to all thefixed nodes (MSSs)and then waiting for a reply from the MSS under which the MH is now located.rm The Inform strategy is similar to the Search,with difference that the mo-bile host is expected to inform the MSS of its movement from one cell to another.Thus when the MH moves from MSS1to MSS2,it informs MSS2of the identity of its previous MSS(in this case MSS1)and then MSS2informs MSS1of the new location for the MH.53.Proxy Proxy combines both the above strategies in the sense that the set of allMSSs are partitioned into various regions or sets and a static host proxy made responsible for the region.In the case of a wide area move(the proxy under which the mobile host is,changes),the MH informs the proxy of its location change,while in the case of a local area move(proxy doesnot change),normal search is used.The Search strategy works better if the mobile host shows high mobility,so that the uncertainty in its position is so high,that it is easier to search for it.On the other hand for a less mobile host Inform will perform better because extensive search would be too expensive.We now look at the different categories of distributed algorithms with example of each,and see what generic restructuring can be done for these categories.Non-coordinator based systems–Systems with all machines equivalent–Systems with exception machinesCoordinator based systems–Fixed coordinator systems–Moving coordinator systemsLet us look into each of these categories one by one,along with suitable examples.3.1Non-coordinator systems with all machines equivalentIn these systems all machines are absolutely equivalent in the sense that the amount of computational and communicational load shared by each machine is same.Such systems can pretty easily be modified to work excellently in a mobile computing en-vironment.We illustrate the method with Lamport’s Bakery algorithm for mutual exclusion as an example.In the Bakery algorithm,a process waiting to enter its critical section chooses a number.This number must be greater than all other numbers currently in use.There is a global shared array of current numbers for each process.The entering process checks all other processes sequentially,and waits for each one which has a lower number.Ties are possible;these are resolved using process IDs.However to look at the impact of executing this directly on the mobile hosts we donot have to look into the details of the algorithm execution,but only at the communication aspects of the algorithm.Note that since the computation load of each machine is equivalent hence there isn’t much we can improve in that respect.So in the algorithm,each machine has to access the registers of the other machines.The drawbacks of non-restructuring include1.High search cost:Since every message exchange is between mobile hosts henceevery message is likely to incur a search cost.This leads to a high search costwhich is proportional to the number of mobile hosts in the system(N).62.Battery consumption at mobile hosts will also be high.In each step the overallenergy consumption is again going to be proportional to the number of mobile hosts.3.Since the algorithm requires the participation of each mobile host in each host,hence it doesnot allow any host to disconnect or doze in an interrupted manner.4.Correctness of the algorithm requires that messages be delivered in Fifo orderand this places a burden on the underlying network to maintain a logical Fifo channel between any pair of mobile hosts.In order to improve the overheads of the bakery algorithm,we will have to shift the communication burden onto thefixed hosts.So instead of N mobile hosts executing the algorithm,it is the MSSs that will maintain the necessary data structures for the al-gorithm(request queue,request and reply messages)and thus secure mutual exclusion on behalf of the mobile hosts.The necessary modifications thus will be as follows:1.Time stamping is used only for messages exchanged between the MSSs(whichnow form the components of bakery algorithm)and not for messages exchanged between the mobile hosts.2.A mobile host initiates the algorithm by sending an initialization message to itslocal MSSwhich will now execute the algorithm on behalf of the mobile host.Thus the appropriate request,reply and release messages are marked with the id of the mobile host for which it is sent by the MSS.3.When the MSS secures mutual exclusion for the MH(using normal bakery al-gorithm execution),it informs the mobile host of the same.But since the mobile host might have changed its location,hence potentially a search will be required.4.The mobile host then accesses the critical section and informs the MSS that itsaccess is complete and hence a release message is sent to every other MSS.5.If the mobile host disconnects prior to the requested access to the critical sec-tion being received,then every disconnection has to be informed to the MSS,so that on receiving the grant for access,the MSS will instantly make the release response,so that other requests are not delayed.Since timestamping of messages is used and each MSS maintains a queue of pend-ing requests,hencefifo ordering of messages is easy to ensure.Also as the MSSs execute the algorithm without any modifications and messages for different MHs are distinguished by tagging the host ids to them,thus correctness of the algorithm is en-sured.Overall communication cost of this algorithm will be as follows:Initialization requires a,granting a request requires,and release of lock requires.The overall cost(alongwith the cost for executing the algorithm between MSSs)thus becomeswhere M is the number of MSSs(partcipating in the algorithm execution).7Note that comparing with the previous approach where the bakery algorithm was executed directly at the mobile hosts,since and,thus the overall communication cost is much less in the later case.Mutual exclusion is also achieved using a logical ring structure(hosts access the critical section only when they receive the token in its due course of traversal in the ring).This algorithm translates to distributed case in exactly the same manner as above, alongwith the same associated benefits in terms of communication cost savings.3.2Non-coordinated systems with exception machinesSuch systems are similar to the previous category,and differ only in the sense that the code executed by one machine(or a few of them)is different than that executed by most of the other machines,and thus these machines constitute the”exception”machines in that sense.An example of this category is dijkstra’s self stabilizing algorithm.Consider a system consisting of a set of nfinite state machines connected in the form of a ring,with a circulating privilege which denotes the ability of a machine to change its state.when a machine has the privilege,it is able to change its current state which is termed a move.Thus the system is self-stabilizing when,regardless of the initial state and privilege selected each time,the system always converges to a legal configuration in afinite number of steps.On the presence of multiple privileges in the system,the choice of whihc machine is entitled to make the move can be decided arbitrarily.A legal state of the system has the following properties:There must be atleast one privilege in the system(no deadlock).Every move from a legal state must again put the system into a legal state(clo-sure).During an infinite execution,each machine should enjoy the privilege an infinite number of times(no starvation).Given any two legal states,there is a series of moves that change one legal state to another(reachability).Let us now look at Dijkstra’s algorithm involving K states where where n is the total number machines.For any machine,we use the symbols S,L,R to denote its own state,the state of left neighbour,and the state of the right neighbour respectively.the exception machineif then.the other machinesif then.Similarly a better algorithm(also by Dijkstra)using3states and two exception ma-chines is as follows:the bottom machine,machine0if then.8the top machine,machine n-1if and then.the other machinesif thenif then.The details of how the self-stabilization works is however not very important so far as porting the algorithms to mobile environment is concerned.Instead we have to look at the communication that occurs between two machines.In both the algorithms cited and also other self-stabilization algorithms,the essen-tial communication perspective is to access the registers for the left and right neigh-bours.Thus clealry these class of algorithms are very similar to the previous class of algorithms and the presence of one or more exception machines really doesnot make much of a difference to the communication costs involved.Thus depending on the mo-bility of the hosts,either of SEARCH,INFORM or PROXY strategies can be used to adapt to the mobile environment.In fact since in this case only the neighbour’s values are needed,hence the overhead of wireless communication will be even less,as most’neighbouring’hosts will be under the same MSS except for two(at the edges).3.3Fixed coordinator based systemDistributed algorithms which involve a coordinator for running the algorithm properly induce a greater than normal communication overhead on the coordinator.Thefirst class of such algorithms is thefixed coordinator set of algorithms which involves one particular host being permanently assigned to be the coordinator in the set of machines or processes.Thus apart from the normal optmization possible for the mobile hosts,the communication pattern for the coordinator has to be specifically optimized,which will yield better dividends in terms of reducing the communication cost,because a large portion of the communication in a coordinator based system will be centered around the coordinator.An example of thefixed coordinator system is encountered in the case of total order atomic broadcast algorithms.The system here consists of N hosts,each of which par-ticipates in the process by broadcasting messages to the other hosts.After a broadcast is made,the hosts on receiving the message sends the messages with their timestamps to the coordinator thread.On receiving the relayed broadcasted message from all the processes,the coordinator sets the timestamp of the message to the maxima of the re-ceived timestamps.This is then broadcasted back to the hosts.The total ordering on the broadcasted messages is induced by this timestamp given by the coordinator(figure 1).So now in the case offixed coordinator algorithms,the coordinator is alwaysfixed to a particular host(in thefigure host3).In modifying such algorithms for execution in a mobile environment,we have to give special emphasis to the coordinator.The following modifications will be required:1.If possible,thefixed coordinator is executed on a static host,that is an MSS.9timehost 1host 3host 4host 5host 2Figure 1:Total Order Atomic Broadcast using fixed/moving coordinator.2.The other hosts will be mobile and the normal search,inform and proxy strategies can be applied depending on the mobility characterestics of the system.In the case where the algorithm is directly executed on the mobile hosts without any change,the total cost incurred for each broadcast will be,cost of broadcast (),cost of sending to the coordinator (),broadcast back of timestamped message ()leading to a total cost ofThis can be used slightly improved if the search results are cached (particularly for the coordinator)by each MSS:However on following the above strategy,the cost becomes cost of broadcast (),cost of sending to coordinator (),cost of broad-casting back the final timestamped message ()making it a total cost ofThus restructuring in the normal manner alongwith placing the coordinator on an MSS leads to great savings.3.4Moving coordinator based systemThe difference of a moving coordinator system from the afore-mentioned fixed se-quencer one is in the sense that the coordinator can now move between the various mobile hosts in the system.Thus who is the coordinator is a function of time as shown in figure 2.Thus in this case normal algorithm execution at mobile hosts will again take the same amount of complexity as in the previous analysis.However we can modify the system as follows:10Figure2:Conceptual model of a moving coordinator system,the sender,coordina-tor and receiver sets are the same,that is comprise of the same hosts,but are shown distinctly for the sake of clarity.1.The normal search,inform or proxy strategies are used for the all the nodes inthe system.2.As soon as a monile host becomes a coordinator,then the number of accesses toit will rise drastically in a short space of time,hence the MH informs its MSS of its change of status to coordinator,which is then broadcasted to all MSSs.Also the MH during the duration of its tenure as coordinator usses the inform strategy, while other hosts use the search strategy.Using these modifications,each step of the algorithm will now require cost of broad-cast(),cost of sending to coordinator(),cost of broadcasting back thefinal timestamped message()and the additional overhead associated with change of coordinator().Thus the total cost comes towhere a change of coordinator occurs every paring this with the normal unrestructured costwe see that the savings are significant.4Concluding remarks for bandwidth and resource op-timizationA distributed algorithm for static hosts can be ex-tended to cover MHs in a uniform manner as follows:a proxy is associated with a MH for the duration of the MH’s11lifetime;a proxy will be informed about the location of its MH(s)whenever such a MH changes its location,and will be responsible for receiving and sending messages to the MHs associated with it.Now,the distributed algorithm can be extended to the mobile environment by executing the algorithms at the proxies of the participating mobile hosts.This provides a two-layer structure in which one layer executes the algorithm over the set of static hosts(proxies)and the other layer handles host mobility, i.e.the interaction between a proxy and the MHs”under”it.In this case,with a fixed association between a MH and its proxy,a total separation of mobility from the algorithm is achieved.However,this is not always a desirable solution because a proxy has to be informed of every move by a MH;in case of”wide area moves”and for MHs that frequently change their cell,this leads to a high message traffic from the MH to its proxy and may be practically infeasible.Thus,we need to look for less static solutions in which the association between the MHs and proxies change,depending on the mobility of hosts.One way offlexibly associating a proxy with a MH is to explicitly incorporate the mobility of hosts into the structure of the algorithm itself.The search and inform strategies reflect this approach.The association between a MH and its proxy changes on everymove:the local MSS acts as a proxy to the MHs in its cell.Thus,a MH need not inform any non-local MSS of its current location.However,the obligations of a proxy may involve searching for a MH,and needs to be carefully defined for correctness of the algorithm.An intermediate approach between a lifelong asso-ciation of a proxy with a MH and assigning a new proxy on every move,is to consider a logical hierarchy offixedhosts, called”location servers”,such that the MHs are the leaves that attach to this hierarchy: MSSs are at level1in the hierarchy.The proxy for a MH is now defined to be a location-server that is d levels higher than a leaf.In this case,the association between a MH and its proxy remains invariant as long as the MH movesbetween locations that have a common d-level ancestor.A distributed algorithm designed for this setup will need to explicitly handle the effects of mobility,since the association between a MH and its proxy could change;however,compared to the approach where the association between a MH and its proxy is redefined on every move,the association does not change on every move in this approach.When the value of d is1,then this approach is equivalent to associating the local MSS as the proxy of a MH,with the association being redefined on every move;when d equals the number of levels in the hierarchy, then there is only one proxy for all MHs,that is a centralized and static solution.Note that a d=2reflects the Proxy strategy suggested by Badrinath and Acharya.5SynchronizationBefore we proceed let us restate our abstractions again.We have objects which are resources which are remotely accessed.We would not worry about’remotely’here but rather say that concurrent threads of execution execute operations on objects.The mobile host may initiate one or more such threads of execution.12。