分布式系统概念与设计(第三版)课后习题与答案Chapter5
计算机操作系统(第三版)完整课后习题答案

第一章1.设计现代OS的主要目标是什么?答:(1)有效性(2)方便性(3)可扩充性(4)开放性2.OS的作用可表现在哪几个方面?答:(1)OS作为用户与计算机硬件系统之间的接口(2)OS作为计算机系统资源的管理者(3)OS实现了对计算机资源的抽象3.为什么说OS实现了对计算机资源的抽象?答:OS首先在裸机上覆盖一层I/O设备管理软件,实现了对计算机硬件操作的第一层次抽象;在第一层软件上再覆盖文件管理软件,实现了对硬件资源操作的第二层次抽象。
OS 通过在计算机硬件上安装多层系统软件,增强了系统功能,隐藏了对硬件操作的细节,由它们共同实现了对计算机资源的抽象。
4.试说明推劢多道批处理系统形成和収展的主要劢力是什么?答:主要动力来源于四个方面的社会需求与技术发展:(1)不断提高计算机资源的利用率;(2)方便用户;(3)器件的不断更新换代;(4)计算机体系结构的不断发展。
5.何谓脱机I/O和联机I/O?答:脱机I/O 是指事先将装有用户程序和数据的纸带或卡片装入纸带输入机或卡片机,在外围机的控制下,把纸带或卡片上的数据或程序输入到磁带上。
该方式下的输入输出由外围机控制完成,是在脱离主机的情况下进行的。
而联机I/O方式是指程序和数据的输入输出都是在主机的直接控制下进行的。
6.试说明推劢分时系统形成和収展的主要劢力是什么?答:推动分时系统形成和发展的主要动力是更好地满足用户的需要。
主要表现在:CPU 的分时使用缩短了作业的平均周转时间;人机交互能力使用户能直接控制自己的作业;主机的共享使多用户能同时使用同一台计算机,独立地处理自己的作业。
7.实现分时系统的关键问题是什么?应如何解决?答:关键问题是当用户在自己的终端上键入命令时,系统应能及时接收并及时处理该命令,在用户能接受的时延内将结果返回给用户。
解决方法:针对及时接收问题,可以在系统中设臵多路卡,使主机能同时接收用户从各个终端上输入的数据;为每个终端配臵缓冲区,暂存用户键入的命令或数据。
分布式数据库参考资料参考答案

1、何为分布式数据库系统?一个分布式数据库系统有哪些特点?P4答案:分布式数据库系统通俗地说,是物理上分散而逻辑上集中的数据库系统。
分布式数据库系统使用计算机网络将地理位置分散而管理和控制又需要不同程度集中的多个逻辑单位连接起来,共同组成一个统一的数据库系统。
因此,分布式数据库系统可以看成是计算机网络与数据库系统的有机结合。
一个分布式数据库系统具有如下特点:物理分布性,即分布式数据库系统中的数据不是存储在一个站点上,而是分散存储在由计算机网络连接起来的多个站点上,而且这种分散存储对用户来说是感觉不到的。
逻辑整体性,分布式数据库系统中的数据物理上是分散在各个站点中,但这些分散的数据逻辑上却构成一个整体,它们被分布式数据库系统的所有用户共享,并由一个分布式数据库管理系统统一管理,它使得“分布”对用户来说是透明的。
站点自治性,也称为场地自治性,各站点上的数据由本地的DBMS管理,具有自治处理能力,完成本站点的应用,这是分布式数据库系统与多处理机系统的区别。
另外,由以上三个分布式数据库系统的基本特点还可以导出它的其它特点,即:数据分布透明性、集中与自治相结合的控制机制、存在适当的数据冗余度、事务管理的分布性。
2、简述分布式数据库系统的模式结构和各层模式的概念。
P12-P13分布式数据库是多层的,国内分为四层:全局外层:全局外模式,是全局应用的用户视图,所以也称全局试图。
它为全局概念模式的子集,表示全局应用所涉及的数据库部分。
全局概念层:全局概念模式、分片模式和分配模式全局概念模式描述分布式数据库中全局数据的逻辑结构和数据特性,与集中式数据库中的概念模式是集中式数据库的概念视图一样,全局概念模式是分布式数据库的全局概念视图。
分片模式用于说明如何放置数据库的分片部分。
分布式数据库可划分为许多逻辑片,定义片段、片段与概念模式之间的映射关系。
分配模式是根据选定的数据分布策略,定义各片段的物理存放站点。
局部概念层:局部概念模式是全局概念模式的子集。
计算机操作系统教程第三版答案

第一章操作系统概述课后习题. 硬件将处理机划分为两种状态,即管态和目态,这样做给操作系统设计带来什么好处答:便于设计平安可靠的操作系统。
管态和目态是计算机硬件为保护操作系统免受用户程序的干扰和破坏而引入的两种状态。
通常操作系统在管态下运行,可以执行所有机器指令;而用户程序在目态下运行,只能执行非特权指令。
如果用户程序企图在目态下执行特权指令,将会引起保护性中断,由操作系统终止该程序的执行,从而保护了操作系统。
. 何为特权指令举例说明之。
如果允许用户执行特权指令,会带来什么后果?答:只能在管态下才能执行的指令称为特权指令。
如开关中断、置程序状态存放器等。
如果允许用户执行特权指令,它将不仅影响当前运行的程序,而且还有可能影响操作系统的正常运行,甚至整个系统。
. 中断向量在机器中的存储位置是由硬件确定的,还是由软件确定的答:中断向量在机器中的位置是由硬件确定的。
例如,在中,内存空间——为中断向量空间。
. 中断向量的内容是由操作系统程序确定的还是由用户程序确定的?答:中断向量的内容是由操作系统程序确定的。
向量的内容包括中断处理程序的入口地址和程序状态字〔中断处理程序运行环境〕,中断处理程序是由操作系统装入内存的,操作系统将根据装入的实际地址和该中断处理程序的运行环境来填写中断向量。
. 中断向量内的处理机状态位应当标明是管态还是目态为什么答:应当标明是管态。
该状态由系统初试化程序设置,这样才能保证中断发生后进入操作系统规定的中断处理程序。
. 中断和程序并发之间的关系是什么?答:中断是程序并发的必要条件。
如果没有中断,操作系统不能获得系统控制权,无法按调度算法对处机进展重新分配,一个程序将一直运行到完毕而不会被打断。
. 说明“栈〞和“堆〞的差异.答:栈是一块按后进先出〔〕规则访问的存储区域,用来实现中断嵌套和子程序调用的参数和返回断点。
而堆虽然是一块存储区域,但是对堆的访问是任意的,没有后进先出的要求,堆主要用来为动态变量分配存储空间。
分布式课后习题答案

分布式课后习题答案第⼀章分布式数据库系统概述1.1请⽤⾃⼰的语⾔定义下列分布式数据库系统中的术语:(1)局部数据:只提供本站点的局部应⽤所需要的数据。
全局数据:虽然物理上存储在个站点上,但是参与全局应⽤(2)全局/局部⽤户:局部⽤户:⼀个⽤户或⼀个应⽤如果只访问他注册的那个站点上的数据称为本地或局部⽤户或本地应⽤;全局⽤户:如果访问涉及两个或两个以上的站点中的数据,称为全局⽤户或全局应⽤。
全局/局部DBMS:1)LDBMS(Local DBMS):局部场地上的数据库管理系统,其功能是建⽴和管理局部数据库,提供场地⾃治能⼒,执⾏局部应⽤及全局查询的⼦查询。
(2)GDBMS(Global DBMS):全局数据库管理系统,主要功能是提供分布透明性,协调全局事物的执⾏,协调各局部DBMS 以完成全局应⽤,保证数据库的全局⼀致性,执⾏并发控制,实现更新同步,提供全局恢复功能等。
(3)全局外模式:全局应⽤的⽤户视图,也称全局视图。
从⼀个由各局部数据库组成的逻辑集合中抽取,即全局外模式是全局概念式的⼦集。
对全局⽤户⽽⾔,都可以认为在整个分布式数据库系统的各个站点上的所有数据库都如同在本站点上⼀样,只关⼼他们⾃⼰所使⽤的那部分数据(4)全局概念模式:描述分布式数据库中全局数据的逻辑结构和数据特性,是分布式数据库的全局概念视图。
采⽤关系模型的全局概念模式由⼀组全局关系的定义(如关系名、关系中的属性、每⼀属性的数据类型和长度等)和完整性定义(关系的主键、外键及完整性其他约束条件等)组成。
(5)分⽚模式:描述全局数据的逻辑划分。
每个全局关系可以通过选择和投影的关系操作被逻辑划分为若⼲⽚段。
分⽚模式描述数据分⽚或定义⽚段,以及全局关系与⽚段之间的映像。
这种映像是⼀对多的。
(6)分配模式:根据选定的数据分布策略,定义各⽚段的物理存放站点,即定义⽚段映像的类型,确定分布式数据库是冗余的还是⾮冗余的,以及冗余的程度。
如果⼀个⽚段分配在多个站点上,则⽚段的映像是⼀对多的,分布式数据库是冗余的,否则是不冗余的。
操作系统教程课后习题答案

操作系统1.什么是计算机系统?计算机系统是怎么构成的?了解PC的组成情况,说明:1)硬件组织的基本结构,画出硬件配置图;2)主要系统软件和应用软件(若有的话)他们的作用。
答:计算机系统就是按照人的要求接收和存储信息,自动进行数据处理和计算,并输出结果信息的系统。
计算机系统由硬件子系统和软件子系统组成。
计算机系统的构成包括:如图1.2计算机硬件系统的构成:如图1.42.从功能以及程序涉设计的角度说明计算机系统中软件系统是如何构成的?答:分为系统软件,支撑软件和应用软件三层。
3.什么是操作系统?请举例说明操作系统在计算机系统中的重要地位。
答:操作系统是计算机系统中的一个系统软件,是一些程序模块的集合。
它们能以尽量有效、合理的方式组织和管理计算机的软硬件资源,合理的组织计算机的工作流程,控制程序的执行并向用户提供各种服务功能,使得用户能够灵活、方便、有效的使用计算机,使整个计算机系统能安全高效地运行4.请举一个实际的例子来说明操作系统的功能。
答:你能用用操作系统管理很多资源5.为什么说“操作系统是控制硬件的软件”的说法不确切?答:操作系统不仅能够控制硬件,也可以控制各种软件资源。
6.操作系统的基本特征是什么?说明他们之间的关系。
答:1.并发性2.共享性3.随机性7.试从独立性,并发性和交互性和实时性四个方面来比较批处理系统,分时系统以及实时系统。
答:分时系统:并发性是指同时有多个用户共同使用一个计算机,宏观上看是多个人同时使用一个CPU,微观上是多个人在不同时刻轮流使用CPU.独占性,是指用户感觉不到计算机为他们服务,就好像整个系统为他所独占。
交互性:是指用户根据系统响应结果进一步提出新要求,用户直接干预每一步。
实时性:是指系统对用户提出的请求及时响应。
8.引入多道程序设计技术的起因和目的是什么?多道程序系统的特征是什么?答:多道程序设计的基本思想在内存中保持多个作业,主机可以交替的方式同时处理多个作业,一般来说任何一道作业的运行总是要交替的使用处理器和外设子案9.多道程序设计的度是指在任一给定时刻,单个CPU所能支持的进程数目最大值。
分布式课后习题答案

第一章分布式数据库系统概述请用自己的语言定义下列分布式数据库系统中的术语:(1)全局/局部数据:(详见课本第9页所谓的局部数据是指……;所谓的全局数据是指……)(2)全局/局部用户(应用):(3)全局/局部DBMS:(4)全局/局部DB:(5)全局外模式:(详见课本第13页)由全局用户视图组成,是全局概念模式的子集。
(6)全局概念模式:(详见课本第13页)定义分布式数据库系统中所有数据的整体逻辑结构,是全局应用的公共数据视图。
(7)分片模式:(详见课本第13页)是全局数据整体逻辑结构分割后的局部逻辑结构,是DDBS 的全局数据的逻辑划分视图.(8)分配模式:(详见课本第13页)用于根据选定的数据总体分配方案,定义各片段的物理存放地点.(9)局部概念模式:(详见课本第13-14页)是全局概念模式被分片和分配到局部场地上的映像的逻辑结构及特征的描述,是全局概念模式的子集。
其逻辑结构与局部DBMS所支持的数据模型有关,当全局数据模型与局部数据模型不同时,局部概念模式还应包括数据模型转换的描述。
(10)局部内模式:描述局部概念模式涉及的数据在局部DBMS中的物理结构及物理存储细节,完全与非分布式系统相同。
1.2采用分布式数据库系统的主要原因是什么?(P1)1.3分布式数据库系统可分为哪些类?(课件第1章。
课本P6,7,8)1.4什么是分布式数据库系统?它具有哪些主要特点?怎么样区别分布式数据库系统与只提供远程数据访问功能的网络数据库系统?(分布式数据库系统的定义、特点详见课件第1.课本P6)1.5分布式DBMS具有哪些集中式DBMS不具备的功能?(课件第1章。
课本P15)用自己的语言解析“什么时候需要进行数据分片和数据复制”?(课本第10,11页)式数据库系统中,为什么要对数据进行分片?什么是关系的片段?关系的片段有哪些主要类型?(课本第9-10页。
数据分片是指数据存放单位不是全部关系,而是关系的一个片段。
分布式系统原理与范型课后习题答案

分布式系统原理与范型课后习题答案专业专心专注第一章绪论1、中间件在分布式系统中扮演什么角色,答:中间件主要是为了增强分布式系统的透明性(这正是网络操作系统所缺乏的),换言之,中间件的目标是分布式系统的单系统视图。
2、解释(分布)透明性的含义,并且给出各种类型透明性的例子。
答:分布透明性是一种现象,即一个系统的分布情况对于用户和应用来说是隐藏的。
包括:访问透明、位置透明、移植透明、重定位透明、复制透明、并发透明、故障透明和持久性透明。
3、在分布式系统中,为什么有时难以隐藏故障的发生以及故障恢复过程,答:通常,要探测一个服务器是停止服务还是该服务器的反应变慢这些情况是不可能的。
因此,一个系统可能在服务响应变慢的时候报告该服务已经停止了。
4、为什么有时候要求最大程度地实现透明性并不好,答:最大程度地实现透明性可能导致相当大的性能损失,从而导致用户无法接受。
5、什么是开放的分布式系统,开放性带来哪些好处,答:开放的分布式系统根据明确定义的规则来提供服务。
开放系统能够很容易地与其它系统协作,同时也允许应用移植到同一个系统的不同实现中。
6、请对可扩展系统的含义做出准确描述答:一个系统的可扩展包含下面几个方面:组件的数量、几何尺寸、管理域的数量与尺寸,前提是这个系统可以在上面几个方面进行增加而不会导致不可接受的性能损失。
7、可以通过应用多种技术来取得可扩展性。
请说出这些技术。
答:可扩展性可以通过分布式、复制和缓存来获得。
8、多处理器系统与多计算机系统有什么不同,答:在多处理器系统中,多个CPU访问共享的主存储器。
在多计算机系统中没有共享存储器,CPU之间只能通过消息传递来进行通信。
9、在多计算机系统中的256个CPU组成了一个16 X 16的网格方阵。
在最坏的情况下,消息的延迟时间有多长(以跳(hop)的形式给出,跳是结点之间的逻辑距离),答:假设路由是最优的,最长的路由是从网格方阵的一个角落到对角的角落。
那么这个路由的长度是30跳。
分布式数据库系统部分课后题答案

分布式数据库系统部分课后习题答案
ASG9 ENO E2 PNO P2 RESP Analyst DUR 6
ASG10 ENO E2 PNO P1 RESP Analyst DUR 24
5.3 EMP TITLE PAY 的连接图如下: PAY1 TITLE SAL PAY2 TITLE SAL
EMP1
ENO ENAME TITLE
EMP2
ENO ENAME TITLE
EMP3
ENO ENAME TITLE
EMP4
ENO ENAME TITLE
这个图显然不是一个简单图。 我们可以通过将 PAY 关系根据 EMP 关系的分片进行诱导分片,即 PAY1 = PAY EMP1; PAY2 = PAY EMP2; PAY3 = PAY EMP3; PAY4 = PAY EMP4; 或 将 EMP 关系根据 PAY 关系的分片进行诱导分片(推荐此方案) ,即 EMP1 = EMP PAY1; EMP2 = EMP PAY2;
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Chapter 5Exercise Solutions5.1The Election interface provides two remote methods:vote: with two parameters through which the client supplies the name of a candidate (a string) and the‘voter’s number’ (an integer used to ensure each user votes once only). The voter’s numbers areallocated sparsely from the range of integers to make them hard to guess.result: with two parameters through which the server supplies the client with the name of a candidateand the number of votes for that candidate.Which of the parameters of these two procedures are input and which are output parameters?5.1 Ans.vote: input parameters: name of candidate, voter’s number;result: output parameters: name of candidate, number of votes5.2Discuss the invocation semantics that can be achieved when the request-reply protocol isimplemented over a TCP/IP connection, which guarantees that data is delivered in the order sent,without loss or duplication. Take into account all of the conditions causing a connection to bebroken.5.2 Ans.A process is informed that a connection is broken:•when one of the processes exits or closes the connection.•when the network is congested or fails altogetherTherefore a client process cannot distinguish between network failure and failure of the server.Provided that the connection continues to exist, no messages are lost, therefore, every request will receive a corresponding reply, in which case the client knows that the method was executed exactly once.However, if the server process crashes, the client will be informed that the connection is broken and the client will know that the method was executed either once (if the server crashed after executing it) or not at all (if the server crashed before executing it).But, if the network fails the client will also be informed that the connection is broken. This may have happened either during the transmission of the request message or during the transmission of the reply message. As before the method was executed either once or not at all.Therefore we have at-most-once call semantics.5.3Define the interface to the Election service in CORBA IDL and Java RMI. Note that CORBA IDLprovides the type long for 32 bit integers. Compare the methods in the two languages forspecifying input and output arguments.5.3 Ans.CORBA IDL:interface Election {void vote(in string name, in long number);void result(out string name, out long votes);};Java RMIWe need to define a class for the result e.g.class Result {String name;int votes;}The interface is:import java.rmi.*;public interface Election extends Remote{void vote(String name, int number) throws RemoteException;Result result () throws RemoteException;};This example shows that the specification of input arguments is similar in CORBA IDL and Java RMI.This example shows that if a method returns more than one result, Java RMI is less convenient than CORBA IDL because all output arguments must be packed together into an instance of a class.5.4The Election service must ensure that a vote is recorded whenever any user thinks they have casta vote.Discuss the effect of maybe call semantics on the Election service.Would at-least-once call semantics be acceptable for the Election service or would yourecommend at-most-once call semantics?5.4 Ans.Maybe call semantics is obviously inadequate for vote! Ex 5.1 specifies that the voter’s number is used to ensure that the user only votes once. This means that the server keeps a record of who has voted. Therefore at-least-once semantics is alright, because any repeated attempts to vote are foiled by the server.5.5 A request-reply protocol is implemented over a communication service with omission failures toprovide at-least-once RMI invocation semantics. In the first case the implementor assumes anasynchronous distributed system. In the second case the implementor assumes that the maximumtime for the communication and the execution of a remote method is T. In what way does the latterassumption simplify the implementation?5.5 Ans.In the first case, the implementor assumes that if the client observes an omission failure it cannot tell whether it is due to loss of the request or reply message, to the server having crashed or having taken longer than usual.Therefore when the request is re-transmitted the client may receive late replies to the original request. The implementation must deal with this.In the second case, an omission failure observed by the client cannot be due to the server taking too long.Therefore when the request is re-transmitted after time T, it is certain that a late reply will not come from the server. There is no need to deal with late replies5.6Outline an implementation for the Election service that ensures that its records remain consistentwhen it is accessed concurrently by multiple clients.5.6 Ans.Suppose that each vote in the form {String vote, int number} is appended to a data structure such as a Java Vector. Before this is done, the voter number in the request message must be checked against every voterecorded in the Vector. Note that an array indexed by voter’s number is not a practical implementation as the numbers are allocated sparsely.The operations to access and update a Vector are synchronized, making concurrent access safe.Alternatively use any form of synchronization to ensure that multiple clients’ access and update operations do not conflict with one another.5.7The Election service must ensure that all votes are safely stored even when the server processcrashes. Explain how this can be achieved with reference to the implementation outline in youranswer to Exercise 5.6.5.7 Ans.The state of the server must be recorded in persistent storage so that it can be recovered when the server is restarted. It is essential that every successful vote is recorded in persistent storage before the client request is acknowledged.A simple method is to serialize the Vector of votes to a file after each vote is cast.A more efficient method would append the serialized votes incrementally to a file.Recovery will consist of de-serializing the file and recreating a new vector.5.8Show how to use Java reflection to construct the client proxy class for the Election interface. Givethe details of the implementation of one of the methods in this class, which should call the methoddoOperation with the following signature:byte [] doOperation (RemoteObjectRef o, Method m, byte[] arguments);Hint: an instance variable of the proxy class should hold a remote object reference (see Exercise 4.12).5.8 Ans.Use classes Class and Method. Use type RemoteObjectRef as type of instance variable. The class Class has method getMethod whose arguments give class name and an array of parameter types. The proxy’s vote method, should have the same parameters as the vote in the remote interface - that is: two parameters of type String and int. Get the object representing the vote method from the class Election and pass it as the second argument of doOperation. The two arguments of vote are converted to an array of byte and passed as the third argument of doOperation.import ng.reflect;class VoteProxy {RemoteObjectRef ref;private static Method voteMethod;private static Method resultMethod;static {try {voteMethod = Election.class.getMethod ("vote", new Class[]{ng.String.class,int.class}));resultMethod = Election.class.getMethod ("result", new Class[] {}));}catch(NoSuchMethodException){}}public void vote (String arg1, int arg2) throws RemoteException {try {byte args [] = // convert arguments arg1 and arg2 to an array of bytesbyte result = DoOperation(ref, voteMethod, args);return ;} catch (...) {}}5.9Show how to generate a client proxy class using a language such as C++ that does not supportreflection, for example from the CORBA interface definition given in your answer to Exercise 5.3.Give the details of the implementation of one of the methods in this class, which should call themethod doOperation defined in Figure 4.12.5.9 Ans.Each proxy method is generated from the signature of the method in the IDL interface,e.g.void vote(in string name, in long number);An equivalent stub method in the client language e.g. C++ is produced e.g.void vote(const char *vote, int number)Each method in the interface is given a number e.g. vote = 1, result = 2.use char args[length of string + size of int] and marshall two arguments into this array and call doOperation as follows:char * result = DoOperation(ref, 1, args);we still assume that ref is an instance variable of the proxy class. A marshalling method is generated for each argument type used.5.10Explain how to use Java reflection to construct a generic dispatcher. Give Java code for adispatcher whose signature is:public void dispatch(Object target, Method aMethod, byte[] args)The arguments supply the target object, the method to be invoked and the arguments for thatmethod in an array of bytes.5.10 Ans.Use the class Method. To invoke a method supply the object to be invoked and an array of Object containing the arguments. The arguments supplied in an array of bytes must be converted to an array of Object.public void dispatch(Object target, Method aMethod, byte[] args)throws RemoteException {Object[] arguments = // extract arguments from array of bytestry{aMethod.invoke(target, arguments);catch(...){}}5.11Exercise 5.8 required the client to convert Object arguments into an array of bytes before invokingdoOperation and Exercise 5.10 required the dispatcher to convert an array of bytes into an arrayof Object s before invoking the method. Discuss the implementation of a new version ofdoOperation with the following signature:Object [] doOperation (RemoteObjectRef o, Method m, Object[] arguments);which uses the ObjectOutputStream and ObjectInputStream classes to stream the request and replymessages between client and server over a TCP connection. How would these changes affect thedesign of the dispatcher?5.11 Ans.The method DoOperation sends the invocation to the target’s remote object reference by setting up a TCP connection (as shown in Figures 4.5 and 4.6) to the host and port specified in ref. It opens an ObjectOutputStream and uses writeObject to marshal ref, the method, m and the arguments by serializing them to an ObjectOutputStream. For the results, it opens an ObjectIntputStream and uses readObject to get the results from the stream.At the server end, the dispatcher is given a connection to the client and opens an ObjectIntputStream and uses readObject to get the arguments sent by the client. Its signature will be:public void dispatch(Object target, Method aMethod)5.12 A client makes remote procedure calls to a server. The client takes 5 milliseconds to compute thearguments for each request, and the server takes 10 milliseconds to process each request. The localoperating system processing time for each send or receive operation is 0.5 milliseconds, and thenetwork time to transmit each request or reply message is 3 milliseconds. Marshalling orunmarshalling takes 0.5 milliseconds per message.Calculate the time taken by the client to generate and return from two requests:(i)if it is single-threaded, and(ii)if it has two threads that can make requests concurrently on a single processor.You can ignore context-switching times. Is there a need for asynchronous RPC if client and serverprocesses are threaded?5.12 Ans.i) time per call = calc. args + marshal args + OS send time + message transmission +OS receive time + unmarshall args + execute server procedure+ marshall results + OS send time + message transmission +OS receive time + unmarshal args= 5 + 4*marshal/unmarshal + 4*OS send/receive + 2*message transmission + execute server procedure = 5+ 4*0.5 + 4*0.5 + +2*3 + 10 ms = 5+2+2+6+10 =25ms.Time for two calls = 50 ms.ii) threaded calls:client does calc. args + marshal args + OS send time (call 1) = 5+.5=.5 = 6then calc args + marshal args + OS send time (call 2) = 6= 12 ms then waits for reply from first callserver gets first call aftermessage transmission + OS receive time + unmarshal args = 6+ 3+.5+.5= 10 ms, takes 10+1 to execute, marshal, send at 21 msserver receives 2nd call before this, but works on it after 21 ms taking10+1, sends it at 32 ms from startclient receives it 3+1 = 4 ms later i.e. at 36 ms(message transmission + OS receive time + unmarshal args) laterTime for 2 calls = 36 ms.5.13Design a remote object table that can support distributed garbage collection as well as translatingbetween local and remote object references. Give an example involving several remote objects andproxies at various sites to illustrate the use of the table. Show what happens when an invocationcauses a new proxy to be created. Then show what happens when one of the proxies becomesunreachable.5.13 Ans..local reference remote reference holdersThe table will have three columns containing the local reference and the remote reference of a remote object and the virtual machines that currently have proxies for that remote object. There will be one row in the table for each remote object exported at the site and one row for each proxy held at the site.To illustrate its use, suppose that there are 3 sites with the following exported remote objects:S1: A1, A2, A3S2: B1, B2;S3: C1;and that proxies for A1 are held at S2 and S3; a proxy for B1 is held at S3.Then the tables hold the following information:.at S1at S2at S3local remote holders local remote holders local remote holdersa1A1S2, S3b1B1S3c1C1a2A2b2B2a1A1proxya3A3a1A1proxy b1B1proxy Now suppose that C1(at S3) invokes a method in B1 causing it to return a reference to B2. The table at S2 adds the holder S3 to the entry for B2 and the table at S3 adds a new entry for the proxy of B2.Suppose that the proxy for A1 at S3 becomes unreachable. S3 sends a message to S1 and the holder S3 is removed from A1. The proxy for A1 is removed from the table at S3.5.14 A simpler version of the distributed garbage collection algorithm described in Section 5.2.6 justinvokes addRef at the site where a remote object lives whenever a proxy is created and removeRefwhenever a proxy is deleted. Outline all the possible effects of communication and process failureson the algorithm. Suggest how to overcome each of these effects, but without using leases.5.14 Ans.AddRef message lost - the owning site doesn’t know about the client’s proxy and may delete the remote object when it is still needed. (The client does not allow for this failure).RemoveRef message lost - the owning site doesn’t know the remote object has one less user. It may continue to keep the remote object when it is no longer needed.Process holding a proxy crashes - owning site may continue to keep the remote object when it is no longer needed.Site owning a remote object crashes. Will not affects garbage collection algorithmLoss of addRef is discussed in the Section 5.2.6.When a removeRef fails, the client can repeat the call until either it succeeds or the owner’s failure has been detected.One solution to a proxy holder crashing is for the owning sites to set failure detectors on holding sites and then remove holders after they are known to have failed.5.15Discuss how to use events and notifications as described in the Jini distributed event specificationin the context of the shared whiteboard application. The RemoteEvent class is defined as followsin Arnold et al. [1999].public class RemoteEvent extends java.util.EventObject {public RemoteEvent(Object source, long eventID,long seqNum, MarshalledObject handback)public Object getSource () {…}public long getID() {…}public long getSequenceNumber() {…}public MarshalledObject getRegistrationObject() {…}}The first argument of the constructor is a remote object. Notifications inform listeners that an eventhas occurred but the listeners are responsible for obtaining further details.5.15 Ans.Event identifier,. evID s. Decided by the EventGenerator. Simplest solution is just to have one type of event -the addition of a new GraphicalObject. Other event types could for example refer to deletion of a GraphicalObject.Clients need to be notified of the remote object reference of each new GraphicalObject that is added to the server. Suppose that an object in the server is the EventGenerator. It could implement the EventGenerator interface and provide the register operation, or it could be done more simplye.g. addListener(RemoteEventListener listener, long evID)// add this listener to a vector of listenersThis would be better if Leases were used to avoid dealing with lost clients.The newShape method of shapeListServant (Figure 5.14) could be the event generator. It will notify all of the EventListeners that have registered with it, each time a new GraphicalObject is added. e.g.RemoteEvent event = new RemoteEvent(this, ADD_EVENT, version, null)for all listeners in the vectorlistener.notify(event)Each client creates an RemoteEventListener for receiving notifications of events and then registers interest in events with the server, passing the EventListener as argument.class MyListener implements RemoteEventListener {public MyListener() throws RemoteException[}public void notify(RemoteEvent event) throws UnknownEventException,RemoteException {Object source = getSource();long id = event.getID();long version = event.getSequenceNumber();// get the newly created GraphicalObject from the server}}Then to become a listener (add the following to the client program shown in Figure 5.15):sList.addListener(new MyListener(), ADD_EVENT);The client getting the newGraphicalObject needs to be able to get it directly from the version number, rather than by getting the list of Shapes and then getting the GraphicalObject. The interface to ShapeList could be amended to allow this.5.16Suggest a design for a notification mailbox service which is intended to store notifications onbehalf of multiple subscribers, allowing subscribers to specify when they require notifications tobe delivered. Explain how subscribers that are not always active can make use of the service youdescribe. How will the service deal with subscribers that crash while they have delivery turned on?5.16 Ans.The Mailbox service will provide an interface allowing a client to register interest in another object. The client will need to know the RemoteEventListener provided by the Mailbox service so that notifications may be passed from event generators to the RemoteEventListener and then on to the client. The client will also need a means of interacting with the Mailbox service so as to turn delivery on and off. Therefore define register as follows:Registration register() ...The result is a reference to a remote object whose methods enable the client to get a reference to a RemoteEventListener and to turn delivery on and off.To use the Mailbox service, the client registers with it and receives a Registration object, which it saves in a file. It registers the RemoteEventListener provided by the Mailbox service with all of the EventGenerators whose events it wants to have notification of. If the client crashes, it can restore the Registration object when it restarts. Whenever it wants to receive events it turns delivery on and when it does not want them it turns delivery off.The design should make it possible to specify a lease for each subscriber.5.17Explain how a forwarding observer may be used to enhance the reliability and performance ofobjects of interest in an event service.5.17 Ans.Reliability:The forwarding observer can retry notifications that fail at intervals of time.If the forwarding observer is on the same computer as the object of interest, then the two could not fail independently.Performance:The forwarding observer can optimize multicast protocols to subscribers.In Jini it could deal with renewing leases.5.18Suggest ways in which observers can be used to improve the reliability or performance of yoursolution to Exercise 5.13.5.18 Ans.The server can be relieved of saving information about all of the clients’ interests by creating a forwarding agent on the same computer. the forwarding agent could use a multicast protocol to send notifications to the clients. IP multicast would do since it is not crucial that every notification be received. A missed version number can be rectified as soon as another one is received.。