欢迎来到天天文库
浏览记录
ID:59470629
大小:409.50 KB
页数:53页
时间:2020-09-14
《操作系统并发性互斥和同步ppt课件.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Concurrency:MutualExclusionandSynchronizationChapter51ConcurrencyOverviewThecentralthemesofoperatingsystemdesignareallconcernedwiththemanagementofprocessesandthreads:MultiprogrammingMultiprocessingDistributedprocessingFundamentaltooperatingsystemdesignisconcurrency(并发)TheBasicrequirementfo
2、rsupportofconcurrencyistheabilitytoenforcemutualexclusion(互斥)2ConcurrencyContexts(并发上下文)Concurrencyarisesinthreedifferentcontexts:MultipleapplicationsMultiprogrammingStructuredapplicationApplicationcanbeasetofconcurrentprocessesorthreadsOperating-systemstructureOperatingsystemisasetofproce
3、ssesorthreads3DesignIssuesofConcurrencyCommunicationamongprocessesSharingandcompeting(竞争)ofresourcesSynchronizationoftheactivitiesofmultipleprocessesAllocationofprocessortimetoprocesses4PrinciplesofConcurrencyInterleavingOverlappingBasiccharacteristicofmultiprogrammingsystems:relativespeed
4、ofexecutionofprocessescannotbepredicted5DifficultiesofConcurrencySharingofglobalresourcesForexample:GlobalvariableOperatingsystemmanagingtheallocationofresourcesoptimallyForexample:I/OchannelDifficulttolocateprogrammingerrorsProgramresultsarenotdeterministicandreproducible(再现)6ASimpleExamp
5、levoidecho(){chin=getchar();chout=chin;putchar(chout);}ProcessP1ProcessP2..chin=getchar();..chin=getchar();chout=chin;chout=chin;putchar(chout);..putchar(chout);..7RaceCondition(竞争条件)Whenmultipleprocessesorthreadsaccesssharedresourcesothatthefinalresultdependsontheorderofexecutionofinstruc
6、tionsinthemultipleprocessesMurphyLawIfSomethingcangowrong,itwill.SolutiontoRaceCondition:ControlaccesstothesharedresourceMutualExclusion(互斥)8ProcessInteractionThreepossibledegreesofawarenessamongprocesses:ProcessesunawareofeachotherCompetitionProcessesindirectlyawareofeachotherCooperationP
7、rocessdirectlyawareofeachotherCooperation9CompetitionAmongProcessesforResourcesCriticalsections(临界区)PortionoftheprogramthataccesssharedresourceOnlyoneprogramatatimeisallowedinitscriticalsectionExampleonlyoneprocessatatimeisallowedtosendcommandtotheprinterEnfor
此文档下载收益归作者所有