欢迎来到天天文库
浏览记录
ID:59472921
大小:1.15 MB
页数:84页
时间:2020-09-14
《四川大学操作系统课件.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Chapter5MutualExclusion(互斥)andSynchronization(同步)OperatingSystems1Agenda5.1PrinciplesofConcurrency5.2MutualExclusion:HardwareSupport5.3Semaphores5.4Monitors5.5MessagePassing5.6Readers/WritersProblem5.7Summary2ConcurrencyConcurrencyarisesinthreedifferentcontexts:Multipleapplications(多应用程序)Multipro
2、grammingStructuredapplication(结构化应用程序)SomeapplicationcanbedesignedasasetofconcurrentprocessesOperating-systemstructure(操作系统结构)Operatingsystemisasetofprocessesorthreads3Concurrency临界区死锁活锁互斥竞争条件饥饿45.1PrinciplesofConcurrency5.1.1ASimpleExample5.1.2RaceCondition5.1.3OperatingSystemConcerns5.1.4Proces
3、sInteraction5.1.5RequirementsforMutualExclusion5DifficultiesofConcurrencySharingofglobalresourcesOperatingsystemmanagingtheallocationofresourcesoptimallyDifficulttolocateprogrammingerrors6ASimpleExamplecharchin,chout;voidecho(){chin=getchar();chout=chin;putchar(chout);}7ASimpleExample(Uniprocesso
4、r)ProcessP1ProcessP2..chin=getchar();.chout=chin;.chin=getchar();chout=chin;putchar(chout);putchar(chout);...8ASimpleExample(Multiprocessor)ProcessP1ProcessP2..chin=getchar();..chin=getchar();chout=chin;chout=chin;putchar(chout);..putchar(chout);..95.1PrinciplesofConcurrency5.1.1ASimpleExample5.1
5、.2RaceCondition5.1.3OperatingSystemConcerns5.1.4ProcessInteraction5.1.5RequirementsforMutualExclusion10RaceCondition(竞争条件)Araceconditionoccurswhenmultipleprocessesorthreadsreadandwritedataitemssothatthefinalresultdependsontheorderofexecutionofinstructionsinthemultipleprocessesorthread.(竞争条件发生在当多个
6、进程或者线程在读写数据时,其最终结果依赖于多个进程或者线程的指令执行顺序)115.1PrinciplesofConcurrency5.1.1ASimpleExample5.1.2RaceCondition5.1.3OperatingSystemConcerns5.1.4ProcessInteraction5.1.5RequirementsforMutualExclusion12OperatingSystemConcernsKeeptrackofvariousprocesses(throughPCB)AllocateanddeallocateresourcesProcessortimeMe
7、moryFilesI/OdevicesProtectdataandresourcesOutputofprocessmustbeindependentofthespeedofexecutionofotherconcurrentprocesses135.1PrinciplesofConcurrency5.1.1ASimpleExample5.1.2RaceCondition5.1.3OperatingSystemConcerns5.1.
此文档下载收益归作者所有