操作系统考前抱佛脚知识点整理.docx

上传人:b****8 文档编号:23893153 上传时间:2023-05-22 格式:DOCX 页数:24 大小:430.60KB
下载 相关 举报
操作系统考前抱佛脚知识点整理.docx_第1页
第1页 / 共24页
操作系统考前抱佛脚知识点整理.docx_第2页
第2页 / 共24页
操作系统考前抱佛脚知识点整理.docx_第3页
第3页 / 共24页
操作系统考前抱佛脚知识点整理.docx_第4页
第4页 / 共24页
操作系统考前抱佛脚知识点整理.docx_第5页
第5页 / 共24页
点击查看更多>>
下载资源
资源描述

操作系统考前抱佛脚知识点整理.docx

《操作系统考前抱佛脚知识点整理.docx》由会员分享,可在线阅读,更多相关《操作系统考前抱佛脚知识点整理.docx(24页珍藏版)》请在冰豆网上搜索。

操作系统考前抱佛脚知识点整理.docx

操作系统考前抱佛脚知识点整理

Chapter1Introduction

1.WhatisOS?

Itisanextendedmachine

Itisaresourcemanager

2.OSConcepts

processes

addressSpaces&Files

protection&Shell

3.SystemCalls

Systemcallsprovidetheinterfacebetweenarunningprogramandtheoperatingsystem.

(1)Process

●UNIXexamples

●forksystemcallcreatesnewprocess.

●execvesystemcallusedafteraforktoreplacetheprocess’memoryspacewithanewprogram.

●waitpidsystemcallusedtomovetheparentprocessoffthereadyqueueuntiltheterminationofthechild.

exitsystemcallisusedwhenaprocessisfinishedexecuting.

例1:

例2:

/*forkprocesses*/

main()

{

inti,pid;

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

if((pid=fork())==0){

printf("Inchild%d.\n",i);

}

}

}

(2)File

(3)Directory

(4)Linking

(5)Mounting

Chapter2ProcessandThread

1.ProcessModel

Multiprogramming,concurrency

2.Process

●Definition进程,即是一个具有一定独立功能的程序关于某个数据集合的一次活动。

●Processvs.Program

(1)Program:

thecollectionofinstruction,staticconcept;

Process:

describeconcurrency,dynamicconcept

(2)Processincludeprogram,data,andPCB(ProcessControlBlock进程控制块)

(3)Process:

temporary;Program:

permanent

(4)Aprogramcanbetheexecutionprogramofmultipleprocess;

also,aprocesscancallmultipleprograms.

(5)Processcancreateotherprocessinit.

3.ProcessCreation

1.Systeminitialization(reboot)

2.Executionofaprocesscreationsystemcall(fork())

3.Userrequesttocreateanewprocess

Commandlineorclickanicon

4.Initiationofabatchjob批处理作业的初始化

4.ProcessTermination

1.Normalexit(voluntary)

2.Errorexit(voluntary)

3.Fatalerror(involuntary)严重错误

4.Killedbyanotherprocess(involuntary)

5.ProcessStates

6.ProcessControlBlock(PCB)

(processattribute)

Inkernel

7.Processcontextswitch

•SwitchCPUfromoneprocesstoanother

•Performedbyscheduler(chapter2.5)

•Itincludes:

–savePCBstateoftheoldprocess;

–loadPCBstateofthenewprocess;

–Flushmemorycache;

–Changememorymapping;

•Contextswitchisexpensive(1-1000microseconds)

–Nousefulworkisdone(pureoverhead)

–Canbecomeabottleneck

8.Thread

(1)Whatisthread?

lightweightprocess(LWP)

(2)Whyneedthreads?

Processspendmuchtimeandspace,restricttheconcurrency

●Responsiveness:

Multipleactivitiescanbedoneatsametime.Theycanspeeduptheapplication.

●ResourceSharing:

Threadssharethememoryandtheresourcesoftheprocesstowhichtheybelong.

●Economy:

Theyareeasytocreateanddestroy.

●UtilizationofMP(multiprocessor)Architectures:

TheyareusefulonmultipleCPUsystems.

(3)Threadvs.process

●Thread:

abasicunitofCPUutilization.

●Process:

abasicunitofresourceallocation.

●进程是资源分配的基本单位,所有与该进程有关的资源分配情况,如打印机、I/O缓冲队列等,均记录在进程控制块PCB中,进程也是分配主存的基本单位,它拥有一个完整的虚拟地址空间。

而线程与资源分配无关,它属于某一个进程,并与该进程内的其它线程一起共享进程的资源。

●不同的进程拥有不同的虚拟地址空间,而同一进程中的多个线程共享同一地址空间。

●进程调度的切换将涉及到有关资源指针的保存及进程地址空间的转换等问题。

而线程的切换将不涉及资源指针的保存和地址空间的变化。

所以,线程切换的开销要比进程切换的开销小得多。

●进程的调度与切换都是由操作系统内核完成,而线程则既可由操作系统内核完成,也可由用户程序进行。

●进程可以动态创建进程。

被进程创建的线程也可以创建其它线程。

●进程有创建、执行、消亡的生命周期。

线程也有类似的生命周期。

(4)TCB线程控制块TCB用来说明线程存在的标识、记录线程属性和调度信息

(5)Implementation

Threemechanism机制

●Implementingthreadsinuserspace

●Implementingthreadsinkernelspace

●HybridImplementations

●Pop-upthreads

9.Inter-ProcessCommunication(IPC)

›ProcessSynchronization进程同步andMutualExclusion互斥

›CriticalResource临界资源,CriticalRegion/Section

一次仅允许一个进程访问的资源称为临界资源

Thepartoftheprogramwherethecriticalresourceisaccessediscalledcriticalregionorcriticalsection

vPossibleSolutions

DisablingInterrupts

LockVariables

StrictAlternation

Peterson’ssolution

TSL

SleepandWakeup

›Semaphore信号量andPVoperations

usesemaphoresintwodifferentways:

mutualexclusion(mutex);

processsynchronization(full,empty).

mutex设初始值为1,down(mutex)进入临界区,up(mutex)离开临界区

empty空槽数目,full满槽数目

1)信号量的物理含义

S.count>0表示有S.count个资源可用

S.count=0表示无资源可用

S.count<0则|S.count|表示S等待队列中的进程个数

P(S):

表示申请一个资源

V(S):

表示释放一个资源。

信号量的初值应该大于等于0

2)P,V操作必须成对出现,有一个P操作就一定有一个V操作

›当为互斥操作时,它们同处于同一进程;

当为同步操作时,则不在同一进程中出现。

›如果P(S1)和P(S2)两个操作在一起,那么P操作的顺序至关重要,一个同步P操作与一个互斥P操作在一起时同步P操作在互斥P操作前;

›而两个V操作的顺序无关紧要。

›Monitors管程,whyusemonitor?

wait操作必须在signal之前,否则该信号会永远丢失

›Messagepassing

›UsingsemaphoretosolveClassicalIPCproblems

vDining-PhilosophersProblem

vReadersandWritersProblem

10.ProcessScheduling

›Schedulingopportunity(whentoschedule)

vAnewprocessiscreated

vTherunningprocessexits

vTherunningprocessisblocked

vI/Ointerrupt(someprocesseswillbeready)

vClockinterrupt(every10milliseconds)

›Schedulingalgorithm

vBatchsystems批处理

›First-ComeFirst-Served(FCFS)

›ShortJobFirst(SJF)短作业优先

只有在所有的作业都可以同时运行的情形下,SJF才是最优化的

vInteractivesystem

›RoundRobin(RR)轮转调度

›PriorityScheduling

›MultiQueue&Multi-levelFeedback多级队列

Chapter6Deadlock

1.ResourceType

›PreemptableResources

›Non-preemptableResources

2.DeadlockDefinition

Asetofprocessesisdeadlockedifeachprocessinthesetiswaitingforaneventthatonlyanotherprocessinthesetcancause.

3.FourConditionsforDeadlock(资源死锁的4个条件)

›Mutualexclusioncondition

›Holdandwaitcondition占有和等待

›Nopreemptioncondition不可占有

›Circularwaitcondition环路等待

4.DeadlockModeling

›ResourceAllocationGraph

○是进程□是资源

□→○资源到进程已占用

○→□进程到资源已阻塞

vIfgraphcontainsnocyclesnodeadlock.

vIfgraphcontainsacycle

›ifonlyoneinstanceperresourcetype,thendeadlock.

›ifseveralinstancesperresourcetype,possibilityofdeadlock.

5.MethodsforHandlingDeadlocks

›TheOstrichAlgorithm

Pretend假装thereisnoproblem

›Detection

vOneresourceofeachtype:

resourceallocationgraphalgorithm

v

Multipleresourcesofeachtype:

matrix-basedalgorithm

算法:

Ri

›Recovery

vThroughpreemption抢占

vThroughrollback回滚(可提高软件可靠性)

vThroughkillingprocess

›Avoidance

vSafestate(系统能够保证所有进程都能完成)

›Ifasystemisinsafestatenodeadlocks.

›Ifasystemisinunsafestatepossibilityofdeadlock.

vBanker’salgorithm

›Prevention

vAttackingoneoftheconditionsfordeadlock

Chapter3MemoryManagement

1.StorageHierarchy

a)AfewMBsoffast,expensive,volatilecachememory

b)AfewGBsofmedium-speed,mediumprice,volatilemainmemory(RAM)

c)AfewTBsofslow,cheap,nonvolatilediskstorage

2.MemoryManagementSchema

(1)NoMemoryAbstraction

vEveryprogramsimplysawthephysicalmemory

vItisnotpossibletoruntwoprogramsinmemoryatthesametime.

(2)AddressSpace

vProtection&Relocation:

baseandlimitregister

(3)Swapping

(4)MemoryManagement:

Bitmap,LinkedList

LinkedList:

空闲区(H)进程(P)两个数字:

第一个是开始的地方,第二个是长度

(5)PartitionAllocation(StoragePlacementStrategies):

Firstfit,Nextfit,Bestfit,Worstfit,Quickfit

3.VirtualMemory

›Principal

›Implementation:

Paging分页,Segmentation分段

4.Paging

›Pagetables

Thepurposeofthepagetableistomapvirtualpagesontopageframes

虚拟地址——页面

物理内存——页框(pageframe)

输入的16位的虚拟地址被分为4位的页号和12位的偏移量,4位(高位部分)的页号可以表示16个页面,12位(低位部分)的偏移可以为一页内的全部4096个字节编址。

Pagetableentry页表项

vTLB(TranslationLook-asideBuffer)转换检测缓冲区

反复读取的页表项

vMulti-levelpagetables

(1)Multi-levelpagetablesAdvantage:

reducethetablesize.

don'tkeeppagetablesinmemorythatarenotneeded.

(2)Example:

32bitmachine虚拟地址with4kpagesize页面长度

4K—>212所以偏移量为12位(Offset)

所以页号为(32-12)=20位—>被分为10bitsPT1域、10bitsPT2域

vInvertedpagetables

每个页框(物理内存)有一个页表项,而不是每一个虚拟页面

›AddressTranslationScheme

›PageFault缺页中断

程序访问了一个未映射的页面

vPageReplacementAlgorithm(SecondChance是对FIFO的改进,Clock是对SecondChance的另一种实现,Aging近似于LRU并且更有效的实现,最好的两种算法是Aging、WSClock)

vOptimal(实际不能用)

vFIFO

vSecondChance

vClock

vNRU最近未使用(R访问定期清零、M修改,一共分四种情况)

vLRU最近最少使用(访问页框k时,把行置为1,列置为0,行的和最小的就是最近最少使用的)

vNFU最不常使用

vAging(位数有限)

vWorkingSet(开销大)

t秒实际运行时间中所访问的页面集合(其中,生存时间=当前实际时间-上次时间)

若(R==1)设置上次使用时间为当前实际时间

若(R==0且生存时间>t)移出这个页面

若(R==0且生存时间<=t)记住最小时间

vWSClock工作集时钟算法

5.DesignIssuesforPagingSystems

›ReplacementScope(全局置换通常比局部置换好)

vLocalReplacement局部置换

vGlobalReplacement全局置换

›PageSize

太大:

最后一页平均一般是空的页面大internalfragmentation内部碎片大,使更多没有用的程序保留在内存中

太小:

需要更多页面页表,装入页面寄存器花费的时间越长

s/p是每个进程大约需要的页数

›SeparateInstructionandDataSpaces

›SharedPages

6.Segmentation分段:

AddressTranslation

Allowseachtabletogroworshrink,independently

7.Segmentationwithpaging:

AddressTranslation

Chapter4FileSystem

1.FileandFileSystem

›File:

Anamedcollectionofrelatedinformationthatisrecordedonsecondarystorage.

›FileSystem:

Amethodforstoringandorganizingfilesandthedatatheycontaintomakeiteasytofindandaccessthem.

2.BasicFunctionsofFileSystem

›Presentlogical(abstract)viewoffilesanddirectories

Hidecomplexityofhardwaredevices

›Facilitateefficientuseofstoragedevices

Optimizeaccess,e.g.,todisk

›Supportsharing

Provideprotection

3.FilesTypes

›Regularfile普通文件(ASCII,Binary)andDirectory目录文件

›CharacterandBlockspecialfile(UNIX)字符特殊文件和块特殊文件

4.FileStructure

vThreekindsoffiles

›bytesequence字节序列(最大灵活性)

›recordsequence记录序列(固定长度)

›tree(Recordsnotnecessarilythesamelength,Recordscontainkeys,Treesortedonkey)

5.FileAccess:

SequentialandRandomaccess

6.DirectoryStructure

›One-leveldirectorysystem

hasonedirectory(root)containingallthefiles

›Two-leveldirectorysystem

hasarootdirectoryanduserdirectories.

›Hierarchicaldirectorysystem层次目录系统

hasarootdirectoryandarbitrarynumberofsubdirectories.

7.PathName:

AbsoluteandRelativepathname(路径名第一个字符是分隔符,则这个路径就是绝对路径)

8.FileImplementation

›ContiguousAllocation连续分配

vAdvantages

›Simpletoimplement(Needonlystartingsector&lengthoffile)

›Readperformanceisexcellent读操作性能好(suitsforsequentialaccessanddirectaccess)

vDisadvantages

›Diskfragmentation磁盘碎片

›Them

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

当前位置:首页 > PPT模板 > 其它模板

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

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