操作系统考前抱佛脚知识点整理.docx
- 文档编号:23893153
- 上传时间:2023-05-22
- 格式:DOCX
- 页数:24
- 大小:430.60KB
操作系统考前抱佛脚知识点整理.docx
《操作系统考前抱佛脚知识点整理.docx》由会员分享,可在线阅读,更多相关《操作系统考前抱佛脚知识点整理.docx(24页珍藏版)》请在冰豆网上搜索。
操作系统考前抱佛脚知识点整理
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
算法:
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 操作系统 考前 抱佛脚 知识点 整理
![提示](https://static.bdocx.com/images/bang_tan.gif)