星期三, 11月 11, 2009

创建和打包.NET程序集

Q1. 辨别有关程序集创建的正确描述。

单文件程序集把它们自己的所有代码、资源和元数据都包含在单个文件中
多文件程序集可以包含多个文件,但是只有一个清单
在多文件程序集中,清单必须在它自己的文件中
把不常使用的资源或代码分割为单独程序集的操作可以减少下载次数
Visual Studio .NET允许你创建单文件程序集和多文件程序集



Q2. 辨别创建和使用延迟签名程序集所需要的步骤的正确顺序。

生成密钥对、使用私钥签名程序集、打开签名验证、使用公钥进行部署
生成密钥对、提取公钥、添加AssemblyDelaySign属性、关闭签名验证、开发完成后使用私钥签名
关闭签名验证、添加AssemblyDelaySign属性、生成密钥对、开发完成后使用私钥签名



Q3. 你要在命令行中使用C#编译器生成可执行文件(DLL)。源文件名为myFile.cs,并且输出到myLibrary.dll中。选择获取该执行结果的命令。

csc myFile.cs
csc /out:myLibrary.dll myFile.cs
csc /t:library /out:myLibrary.dll myFile.cs
csc /out:dll /library:myLibrary myFile.cs



Q4. 你已经创建了一个公用/私有密钥对,还想使用私钥创建一个强命名程序集。下列哪些操作可以提供给你该结果?

把AssemblyKeyFile属性包含在任意一个源文件中
把AssemblyKeyFile属性包含在所有源文件中
使用带/keyfile选项的程序集生成工具
使用强名称工具生成该程序集,然后进行签名

星期二, 11月 10, 2009

.NET中的附属程序集和本地化

Q1. 辨别有关附属程序集创建的正确描述。

可以通过简单命名资源文件来指定区域性
它们包含资源但是没有可执行代码
必须一致地命名结果附属程序集
al/embed选项可使你把资源文件嵌入到程序集中
使用程序集生成工具创建它们


Q2. 查找资源程序集时,资源定位管理器将首先检查下列哪项内容?

检查程序集的子目录,查找父区域性资源文件
检查程序集的主目录,查找特定的匹配程序集
检查GAC,查找匹配程序集
检查GAC,查找匹配的父程序集


Q3. 假设你拥有一套本地化帮助文件资源。每个文件的名称都是HelpFile。美国英语资源文件的正确名称是什么?

HelpFile.resources.en-US
HelpFile.en.US.resources
HelpFile.en-US.resources
en-US.HelpFile.resources
只是HelpFile,因为它将存储在特定区域性目录中


Q4. 为了查找某区域的准确匹配程序集而检查完所有的位置后,资源定位管理器接下来将执行什么操作?

停止搜索并产生异常
查找默认区域性程序集
查找父区域性程序集

星期一, 11月 09, 2009

.NET程序集的绑定策略

1) 选择有关私有程序集的正确描述。

私有程序集可以被随时更新,且不会影响其他应用程序
私有程序集必须总具有一个版本号,但是在绑定时忽略版本号
私有程序集必须位于应用程序的主目录结构中
如果在本地目录结构中没有找到私有程序集,那么CLR将在GAC中探测私有程序集


2) 下列哪个选项准确定义了安全模式?

发行者允许管理员在其中重写默认绑定策略的配置
应用程序开发人员禁止发行者策略在其中重写应用程序策略的配置
管理员在其中完全控制程序集的所有绑定策略的配置
不能在其中重写默认绑定规则的配置


3) 辨别出有关默认绑定的正确描述。

管理员通过管理员策略可以完全控制所有的绑定规则
默认绑定可以在编译后重写,且被包含在程序集清单中
默认绑定可以在编译后重写,但是必须在部署前重写
默认绑定规则可以在三个不同的策略级别中重写
你可以在程序集清单中指定默认绑定规则不被重写


4) 下列哪个序列按照正确的评价顺序正确表示出策略级别?

管理员、应用程序、发行者
管理员、发行者、应用程序
应用程序、发行者、管理员
发行者、应用程序、管理员
发行者、管理员、应用程序

星期日, 11月 08, 2009

NET中的策略配置文件

1. 假设你想通过指定程序集加载程序可以搜索的子目录来帮助程序集加载。下列哪个选项可使你实现该操作?

计算机配置文件中的bindingRedirect元素
计算机配置文件中的codeBase元素
应用程序配置文件中的probing元素
发行者策略文件中的publisherPolicy元素


2. 假设你想指定可被一个新版本替换的依赖程序集的版本范围。在哪个XML元素中指定新旧版本?

dependentAssembly
codeBase
assemblyIdentity
bindingRedirect


3. 选择assemblyIdentity元素中的属性。

culture
name
publicKey
Tokenversion
xmlns



4. codeBase 元素在强名称程序集的版本和href属性中指定它的版本和位置。

星期六, 11月 07, 2009

使用.NET程序集的动态属性

(1) 辨别有关动态属性的正确描述。

任何可移植可执行(PE)文件都可以存储和检索动态属性
在运行时中,Windows应用程序把它们的动态属性存储在app.config文件中
动态属性通常存储在XML配置文件的节中
Web应用程序自动重读被更改的配置文件项,且不需要重新启动或重新部署
只有在重新部署Web应用程序后配置文件项所做的更改才能生效


(2) 辨别有关动态属性的正确描述。

在设计阶段,Windows应用程序把它们的动态属性存储在app.config文件中
动态属性可以在任意数量的配置文件中显示
Web应用程序把它们的动态属性存储在Web.config文件中
Windows应用程序若要读取被更改的属性值配置项,则必须重新启动


(3) 动态属性存储在相关XML配置文件的哪个元素中?

<appsettings>
<assemblybinding>
<codebase>
<runtime>

星期五, 11月 06, 2009

CS3161 (A) OPERATING SYSTEM PRINCIPLES (DR. LIU WENYIN) (09CS3161_LW) - Answers to Tutorial 9 Questions

Q1 When does page fault occur ? Describe the action taken by the operating system when a page fault occurs.

A page fault occurs when an access to a page that has not been brought into main memory takes place (invalid page bit set in page table).
Page Fault Handling procedures,
(1)Scan the page table entry, the page is invalid – page fault occurs;
(2)O.S. generate TRAP interrupt;
(3)Locate the page with data in secondary storage;
(4)I/O requested to read the needed page into the available free frame;
(5)Upon completion of I/O, the process table and page table are updated as valid page and address in memory;
(6)The instruction is restarted.






Q2 (i) What is a page replacement ?(ii) What does the dirty bit mean ?


(i) Page replacement is the scheme (algorithm) to identify a victim page for replacement when all available frames (memory) are all currently used.
Page replacement operation involves selecting a frame (preferably not currently in use) as a victim for replacement; swap it out; swap in the desired page into the free frame; restart program.
Available page replacement scheme include FCFS, LFU, NRU.
(ii) A bit stored in the page table, if set, the page has been modified (dirty page), and must be written back to backing store before being use as a victim for page replacement to create a free frame in physical memory.
It is desirable try not to replace a dirty page, since it will take longer (with the write-back operation).




Q3 (i) What is Thrashing ?(ii) How does the system detect thrashing ?(iii) What can the system do to eliminate it ?


(i) Thrashing in a virtual memory system is a high page fault activities situation, where the system spends most of the time in page swapping than executing processes.
Thrashing is caused by under-allocation of the minimum number of pages required by a process, forcing it to continuously page fault.
(ii) The system can detect thrashing by elevating the level of CPU utilisation as compared to the level of multiprogramming.
The sudden drop in CPU utilisation while increasing the level of multiprogramming (increasing the number of processes) identifies the thrashing point.
(iii) Thrashing can be eliminated by reducing the level of multiprogramming, (that is to decrease the number of processes in the system).

星期二, 11月 03, 2009

CS3161 (A) OPERATING SYSTEM PRINCIPLES (DR. LIU WENYIN) (09CS3161_LW) - Answers to Tutorial 8 Questions

Q1 Explain the difference between internal and external fragmentation in memory management. Suggest ways to reduce or solve of both types of fragmentation.


Internal fragmentation is the area in a region or a page which is not used by the job occupied that region or page. This space is unavailable for use by the system until that job is finished or the region is released.

External fragmentation is a region which is unused and available, but it is too small for any of the waiting jobs.

To reduce or solve problems of fragmentation :
Internal fragmentation - reduce size of individual region / allocation unit.
External fragmentation - break down request into non-contiguous portions, compaction, swapping.



Q2 What is compaction ? Why use it ?


Movement of processes to eliminate small free memory partitions. Compaction is used to eliminate memory fragmentation (external) and to increase memory utilization.

It allows smaller memory partitions to form fewer bigger ones, thus allowing larger processes to run.





Q3 Given memory partition of 100K, 500K, 200K, 300K, and 600K (in order), how each of the First-fit, Best-fit, and Worst-fit algorithms place processes of 212K, 417K, 112K, and 426K (in order) ? Which algorithm makes the most efficient use of memory ?


(1) First-fit :
212K is put in 500K partition
417K is put in 600K partition
112K is put in 288K partition (new partition 288K = 500K - 212K)
426K must wait
(2) Best-fit :
212K is put in 300K partition
417K is put in 500K partition
112K is put in 200K partition
426K is put in 600K partition
(3) Worst-fit :
212K is put in 600K partition
417K is put in 500K partition
112K is put in 388K partition
426K must wait

In this example, the best-fit turns out to be the best algorithm.



Q4 (i) What is paging ?(ii) What is a frame ?(iii) What is contained in the page table ?(iv) How many frames are needed for each page ?(V)Draw the diagram to show how paging works.


(i) Splitting program up into a group of fixed-equal-sized partitions, allowing the parts to be non-contiguous in memory, during the execution of the process.
(ii) Fixed-size block of physical memory, each block must be of the same size as one page.
(iii) Page number, frame number, base address of each frame, presence, protection (permission), dirty bit.
(iv) One.

推薦此文