1、上机操作题模拟试卷 18及答案与解析 一、基本操作题 1 设置屏幕保护程序,可在不使用计算机时保护显示屏幕不受损坏,请简要叙述设置屏幕保护程序的操作方法。 二、简单应用题 2 有一个矩阵 Var A: array1100 , 1100 of integer :以行为先进行存储。有一个虚存系统,物理内存共有三页,其中一页用来存放程序,其余两页用于存放数据。假设程序已经在内存中占一页,其余两页空闲。 程序 A: for i:=1 t0 100 do for j=1 to 100 do Ai, j:=0; 程序 B: for j:=1 to 100 do for i:=1 to 100 do Ai,
2、 j:=0; 若每页可存放 200个整数,程序 A和程序 B的执行过程各会发生多少次缺页 ?试问:若每页只能存放 100个整数呢 ?以上说明了什么问题。 三、综合应用题 3 有一南北向的单行车道,在车道 A、 B两端以外一段距离处有减速标志和自动计数系统, A、 B两处设有信号灯,信号灯的管理要求如下:绿灯行,红灯停, A、 B两端红绿灯同时变换,一方红变绿时另一方绿变红。绿灯保持到同一方向进入的车辆全部驶入 AB段,当 AB之间无车辆行驶时,允许到达 A端 (或 B端 )的车辆驶入AB段,但只准某一方向的车辆进入;当一方最后一辆车进入 AB段后,双向亮红灯让车辆全部通过 (假设 2min),
3、然后让己在等待的任何一方向的车辆驶入。试用PV操作管理 AB路段车辆的行驶。 上机操作题模拟试卷 18答案与解析 一、基本操作题 1 【正确答案】 设置屏幕保护程序的操作步骤如下: 右击桌面任意空白处,在弹出的快捷菜单中选择 “属性 ”命令,或单击 “开始 ”按钮,选择 “控制面板 ”命令,在弹出的 “控制面板 ”对话框中双击 “显示 ”图标。 打开 “显示属性 ”对话框,选择 “屏幕保护程序 ”选项卡。 在该选项卡的 “屏幕保护程序 ”选项组中的下拉列表中选择一种屏幕保护程序,在选项卡中的显示器中即可看到该屏幕保护程序的显示效果。 单击 “设置 ”按钮,可对该屏幕保护程序进行设置;单击 “预
4、览 ”按钮,可预览该屏幕保护程序的效果,移动鼠标或按键盘中的任意键即可结束屏幕保护程序;在 “等待 ”文本框中可输入或调节微调按钮,设置计算机多长时间无人使用则启动该屏幕保护程序。 【知识模块】 上机 操作题 二、简单应用题 2 【正确答案】 考虑本题所给条件:每个主存块的大小可以存放 200个数组元素,有两个内存块可以用来存放数组信息,数组中的元素按行编址。 对于程序 A,数组访问顺序是: A1, 1, A1, 2, A1, 3, , A1, 99, A1, 100 A2, 1, A2, 2, A2, 3, , A2, 99, A2, 100 A100, 1, A100, 2, A100,
5、3, , A100, 99, A100, 100 显然,数组的存储顺序与访问顺序一致,每访问两行数组遇到一次缺页中断,如果采用 LRU页面调度算法,会产生 50次缺页中断。 对于程序 B,数组的访问顺序是: A1, 1, A2, 1, A3, 1, , A99, 1, A100, 1 A1, 2, A2, 2, A3, 2, , A99, 2, A100, 2 A1, 100, A2, 100, A3, 100, , A99, 100, A100, 100 显然,数组的存储顺序 (按行的顺序 )与访问顺序 (按列的顺序 )不一致,每访问两个数组元素遇到一次缺页中断。如果采用 LRU页面调度算法
6、,会产生 5000次缺页中断。若每页只能存放 100个整数,对于程序 A,数组的存储顺序与访问顺序一致,每访问一行数组遇到一次缺页中断。如果采用 LRU页面调度算法,会产生100次缺页中断。对于程序 B,数组的顺序 (按行的顺序 )与访问顺序 (按列的顺序 )不一致,每访问一个数组元素遇到一次缺页中断。如果采用 LRU页面调度算法,会产生 10000次缺页中断。 以上结果说明:页面越大,缺页 中断次数越少;页面越小,缺页中断次数越多。 【知识模块】 上机操作题 三、综合应用题 3 【正确答案】 本题可参考读者写者问题,相当于两组读者使用一个共享文件的互斥问题。对共享资源 AB路段设一个信号量
7、s,对 A、 B两端的共享计数器 ca和cb应设两个信号量 sa和 sb。所设计的程序段如下: Begin s,sa,ab:semaphore; ca,cb:integer; s:=1; sa:=1; sb:=1; Cobegin Process car-ai; (i=1, 2, Begin p(sa); Ca:=ca+1; if ca=1 then p(s); V(sa); 使信号灯 A端绿, B端红,车辆从 A端驶入 AB段 p(sa); ea:=ca-1; if ca=0 then Begin A, B两端都亮红灯 2分钟 V(s); End End process car-bj; j=1,2 Begin p(sb); cb:=cb+1; if cb=1 then p(s); V(s); 使信号灯 B端绿 , A端红;车辆从 B端驶入 AB段 p(sb); cb:=cb-1; if cb=0 then Begin A, B两端都亮红灯 2分钟 V(s); End End Coend End 【知识模块】 上机操作题