西安电子科技大学操作系统期末试题及答案解析.docx

上传人:b****5 文档编号:6803599 上传时间:2023-01-10 格式:DOCX 页数:11 大小:39.77KB
下载 相关 举报
西安电子科技大学操作系统期末试题及答案解析.docx_第1页
第1页 / 共11页
西安电子科技大学操作系统期末试题及答案解析.docx_第2页
第2页 / 共11页
西安电子科技大学操作系统期末试题及答案解析.docx_第3页
第3页 / 共11页
西安电子科技大学操作系统期末试题及答案解析.docx_第4页
第4页 / 共11页
西安电子科技大学操作系统期末试题及答案解析.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

西安电子科技大学操作系统期末试题及答案解析.docx

《西安电子科技大学操作系统期末试题及答案解析.docx》由会员分享,可在线阅读,更多相关《西安电子科技大学操作系统期末试题及答案解析.docx(11页珍藏版)》请在冰豆网上搜索。

西安电子科技大学操作系统期末试题及答案解析.docx

西安电子科技大学操作系统期末试题及答案解析

西安电子科技大学

考试时间120分钟

试题

题号

总分

分数

1.考试形式:

闭卷2.考试日期:

年月日3.本试卷共四大题,满分100分

班级学号姓名任课老师

Part1:

Selectoneanswer(AthroughD)foreachquestion(Total20,each2)

1.Acomputersystemconsistsof,systemprogramsandapplicationprograms.

A.ControlbusB.databus

C.AddressbusD.hardware

2.Thread(线程)canbeimplementedin.

A.KernelSpaceB.UserSpace

C.KernelSpaceorUserSpaceD.Noneoftheabove

3.InOS,shorttermschedule(调度)means.

A.JobschedulingB.Processscheduling

C.ThreadschedulingD.CPUscheduling

4.Whichoneofthefollowingitemisnotsharedbyallthreadsinaprocess?

.

A.AddressspaceB.Register

C.OpenfilesD.Accountinginformation

5.Inthepagedmemorymanagementsystem,theaddressiscomposedofpagenumberandtheoffsetwithinthepage.Intheaddressstructureshowninthefollowingfigure,.

311090

pagenumber

offset

A.pagesizeis512,2Mpagesatmost

B.pagesizeis1k,4Mpagesatmost

C.pagesizeis2k,8Mpagesatmost

D.pagesizeis4k,16Mpagesatmost

6.VirtualmemoryisbasedonThePrincipleofLocality.WhichofthefollowingstatementsaboutThePrincipleofLocalityiscorrect?

A.Programexecutescodesinorder

B.Programassesses(访问)memoryinanon-uniformmanner

C.Programaccessesalotofvariablescontinuously

D.Programaccessesarelativelysmallportionoftheaddressspaceatanyinstantoftime

7.InUNIXi-nodescheme,adirectoryentrycontainsonlytwofields:

the

filename(14bytes)andthenumberofthei-nodeforthatfile(2bytes).Theseparameters(参数)limitthenumberoffilesperfilesystemto

.

A.64kB.32k

C.16kD.4k

8.Thetimerequiredtoreadorwriteadiskblockisdetermined(决定)bythreefactors.Whichonedominates(主导,占优势)theothertwotimes?

.

A.SeektimeB.Rotationaldelaytime

C.DatatransfertimeD.Noneofabove

9.Thechmodcommand(命令)isusedtochangethepermission(许可)offileinLinux.Touseit,youspecifythedesiredpermissionsettingandthefileorfilesthatyouwishtomodify.Thepermissionsettingsareusuallyaseriesofbits.Whichofthefollowingbitspresentthatthefile’sownermayread,write,andexecutethefile,whileallothersmayonlyreadthefile?

.

A.755B.744C.644D.611

10.Themethodlistedbelowdoesn’tneedCPUtoparticipateinthetransferofdatablock.

A.Interrupt-DrivenI/OB.DMA

C.ProgrammedI/OD.Noneofabove

Part2:

FillBlanks(Total20,each2)

1.OperatingSystemisanextendedmachineand.

2.ParallelSystemsincludeSymmetric(对称)multiprocessingand.

3.Asemaphore(信号量)Sisanintegervariablethatisaccessedonlythroughtwostandardatomicoperations:

and.

4.Addressbindingofinstructionsanddatatomemoryaddressescanhappenatthreedifferentstages,Compiletime,Loadtimeand.

5.FourConditionsforDeadlock:

Holdandwait,Nopreemptionand.

6.Sector0ofthediskiscalledthe.

7.InLinux,thefilemetadata(元数据)isstoredin.

8.Thesecuritygoalsincludedataconfidentiality(机密性),dataintegrityand.

Part3:

EssayQuestions(Total20,each4)

1.Whatissystemcall?

Useanexampletoillustrate(举例说明)thestepsofsystemcall.

2.Pleasedescribethediagram(图)ofProcessState.

3.WhatisMonitor?

CanyouuseMonitortoimplementadatastructure?

4.WhatisTLB?

Whatroledoesitplayinmemorymanagement?

5.ThedifferenceofprogrammingI/Oandinterrupt-drivenI/O.

Part4:

IntegrateQuestions(Total40,each10)

1.Thecodebelowisanexampleprogramofproducer-consumer.Theproductproducenumbersfrom1toMAXandtheconsumerwillreadit.Pleasefillblanksinthecode

#include

#include

#defineMAX1000000000/*howmanynumberstoproduce*/

pthread_mutex_tthe_mutex;

pthread_cond_tcondc,condp;

intbuffer=0;/*bufferusedbetweenproducerandconsumer*/

void*producer(void*ptr)/*producedata*/

{

inti;

for(i=1;i<=MaX;i++){

pthread_mutex_lock(&the_mutex);

while(

pthread_cond_wait(&condp,&the_mutex);

buffer=i;

}

pthread_exit(0);

}

void*consumer(void*ptr)/*consumedata*/

{

inti,res;

for(i=1;i<=MAX;i++){

pthread_mutex_lock(&the_mutex);

while(

pthread_cond_wait(

&the_mutex);

res=buffer;

buffer=0;

pthread_cond_signal(&condp);

printf(“buffer=%d\n”,res);

}

pthread_exit(0);

}

intmain(intargc,char**argv)

{

pthread_tpro,con;

pthread_mutex_init(&the_mutex,0);

pthread_cond_init(&condc,0);

pthread_cond_init(&condp,0);

pthread_create(&con,0,consumer,0);

pthread_create(&pro,0,producer,0);

pthread_join(pro,0);

pthread_join(con,0);

pthread_cond_destroy(&condc);

pthread_cond_destroy(&condp);

pthread_mutex_destroy(&the_mutex);

}

2.Considerthefollowingsnapshotofasystem:

Resources

Processes

Allocation

ABCD

MaxNeed

ABCD

Available

ABCD

P0

P1

P2

P3

P4

1012

2000

1354

0632

0014

0012

1750

2356

0652

0656

1520

Answerthefollowingquestionsusingthebanker’salgorithm:

(1)WhatisthecontentofthematrixNeed?

(4points)

(2)Isthesysteminsafestate?

Why?

(3points)

(3)IfarequestfromprocessP1arrivesfor(0,4,2,0),cantherequestbegranted(允许)immediately?

(3points)

3.Diskrequestscomeintothediskdriverforcylinders10,22,20,2,40,6,and38,inthatorder.Inallcases,thearmisinitiallyatcylinder20.Aseektakes6msecpercylindermoved.Howmuchseektimesisneededfor

(1)FirstComeFirstServed(FCFS).(3points)

(2)ShortedSeekTimeFirst(SSTF).(3points)

(3)Elevatoralgorithm(SCAN,initiallymovingupward)(4points)

4.Considerasystemwherethevirtualmemorypagesizeis2K(2048bytes),andmainmemoryconsistsof4pageframes.Nowconsideraprocesswhichrequires8pagesofstorage.Atsomepointduringitsexecution,thepagetableisasshownbelow:

Virtualpage

Valid

Physicalpage

0

No

1

No

2

Yes

1

3

No

4

Yes

3

5

No

6

Yes

0

7

Yes

2

Answerthefollowingquestions:

(1)Listthevirtualaddressrangesforeachvirtualpage.(3points)

(2)Listthevirtualaddressrangesthatwillresultinapagefault.

(3points)

(3)Givethemainmemory(physical)addressesforeachofthefollowingvirtualaddresses(allnumbersdecimal):

(i)8500,(ii)1400,(iii)5000,(iv)2100.(4points)

Answers

Part1:

Selectoneanswer(AthroughD)foreachquestion

1.D

计算机系统由硬件和软件(系统程序+应用程序)组成。

2.C

线程实现的两种方式——用户空间和内核中

①在用户空间中实现线程

内核对线程包一无所知,从内核角度考虑,就是按正常的方式管理,即单线程进程(存在运行时系统)

②在内核中实现线程

在某个线程希望创建一个新线程或撤销一个已有线程时,它进行一个系统调用,这个系统调用通过对线程表的更新完成线程创建和撤销工作。

③混合实现

在此模型中,每个内核级线程有一个可以轮流使用的用户级线程集合。

3.D

三级调度:

①long-termschedule(长期调度,又称作业调度):

哪个程序被系统选中并创建进程运行它

②medium-termschedule(中期调度,又称内存调度):

决定是否将进程调入内存

③short-termschedule(短期调度,又称CPU调度):

哪个进程获得处理器资源(通常所说的调度)

4.B

一个进程中所有线程共享的内容(进程的属性):

每个线程独有的内容:

5.B

页面数(pagenumber)===4M

由页内偏移(offset)得,

页面大小(pagesize)===1K

6.D

答案:

程序在一段时间内访问相对小的一段地址空间

虚拟内存基于程序的局部性原理而设计的。

程序的局部性原理是指程序在执行时呈现出局部规律,即在一段时间内,整个程序的执行仅限于程序中的某一部分。

相应地,执行所访问的存储空间也局限于某个内存区域。

(根据程序的局部性理论,Denning提出了工作集理论)

7.A

UNIX的一个目录项包含了两个域,文件名(14个字节)和节点的编号(2个字节),这些参数决定了每个文件系统的文件数目为64K()

8.A

Timerequiredtoreadorwriteadiskblockdeterminedby3factors:

—Seektime(thetimetomovethearmtothepropercylinder)(寻道时间)

—Rotationaldelay(thetimeforthepropersectortorotateunderthehead)(旋转延迟)

—Actualdatatransfertime(实际数据传输时间)

Formostdisks,theseektimedominatestheothertwotimes.

9.B

chmod命令,改写文件的读写许可设置

语法为:

chmodabcfile

其中a,b,c各为一个数字,分别表示User,Group,Other的权限

r=4,w=2,x=1

所以,

a=4+2+1=7

b=4

c=4

10.B

I/O可以以三种不同方式实现:

①程序控制I/O(ProgrammedI/O)

让CPU做全部的工作。

CPU通过程序主动读取状态寄存器以了解接口情况,并完成相应的数据操作。

②中断驱动I/O(interrupt-drivenI/O)

当程序常规运行时,若外部有优先级更高的事件出现,则通过中断请求通知CPU,CPU再读取状态寄存器确定事件的种类,执行不同的分支处理。

③DMA(DirectMemoryAccess)

直接内存存取即数据传送的具体过程直接由硬件(DMA控制器)在内存和I/O之间完成,CPU只在开始时将控制权暂时交予DMA,直到数据传输结束。

 

Part2:

FillBlanks

1.aresourcemanager

2.asymmetricmultiprocessing(非对称多处理)

3.PV

4.executiontime

5.MutualexclusionCircularwait

6.MBR(MasterBootRecord)主引导记录

7.i-node

8.systemavailability

 

Part3:

EssayQuestions

1.操作系统的主要功能是为应用程序的运行创建良好的环境,为了达到这个目的,内核提供一系列具备预定功能的多内核函数,通过一组称为系统调用(systemcall)的接口呈现给用户。

系统调用把应用程序的请求传给内核,调用相应的的内核函数完成所需的处理,将处理结果返回给应用程序,如果没有系统调用和内核函数,用户将不能编写大型应用程序。

2.

1)Running运行态

2)Ready就绪态.,暂无CPU分配得它。

3)Blocked阻塞态,等待输入

3.管程是一个由过程、变量和数据结构等组成的一个集合,它们组成一个特殊的模块或软件包。

进程可在任何需要的时候调用管程中的过程,但它们不能在管程之外声明的过程中直接访问管程内的数据结构。

任一时刻管程中只能有一个活跃进程,这一特性使管程能有效地完成互斥。

4.TLB即TranslationLookasideBuffer(转换检测缓冲区),是一个小型的硬件设备将虚拟地址直接映射到物理地址,不必再访问列表。

它通常存在在MMU中,包含少量的表项,每个表项记录了一个页面的相关信息,包括虚拟页号、页面的修改位、保护码(读/写/执行权限)和该页所对应的物理页框。

它是一个内存管理单元用于改进虚拟地址到物理地址转换速度的缓存。

5.①程序控制I/O(ProgrammedI

让CPU做全部的工作。

CPU通过程序主动读取状态寄存器以了解接口情况,并完成相应的数据操作。

②中断驱动I/O(interrupt-drivenI/O)

在等待设备就绪的时候允许CPU做其他的事情。

当程序常规运行时,若外部有优先级更高的事件出现,则通过中断请求通知CPU,CPU再读取状态寄存器确定事件的种类,执行不同的分支处理。

 

Part4:

IntegrateQuestions

1.①buffer!

=0

②pthread_cond_signal(&condc);

③pthread_mutex_unlock(&the_mutex);

④buffer==0

⑤&condc

⑥pthread_mutex_unlock(&the_mutex);

2.

(1)(=MAXNeed-Allocation)

(2)此时系统状态是不安全的。

因为:

不存在使所有进程都顺序执行的序列。

A=(1520)

P0markedA=(1520)

P3markedA=(1540)

进程执行顺序:

P0,P3,但是剩余资源不能满足其他进程的需求

(3)允许。

因为

存在使进程都顺序执行的序列:

P0,P3,P1,P2,P4

A=(1520)

P0markedA=(1520)

P3markedA=(1540)

P1markedA=(1870)

P2markedA=(2872)

P4markedA=(214114)

3.

(1)FCFS

柱面访问序列:

(20),10,22,20,2,40,6,3

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 语文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1