欢迎来到天天文库
浏览记录
ID:43515643
大小:570.03 KB
页数:57页
时间:2019-10-09
《lecture_7_Synchronization》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、SynchronizationZhaoFangOperatingSystems-forthecollegestudentsGoalsforTodayWhyConcurrency?Whyisthebackgroundofsynchronization?MoreonCriticalSectionNeedforsynchronizationExamplesofvalidsynchronizationWhyConcurrency?AllowsmultipleapplicationstorunatthesametimeMultipleapplicationsStruc
2、turesapplicationsOperatingsystemstructureAnalogy:jugglingBenefitsofConcurrencyAbilitytorunmultipleapplicationsatthesametimeBetterresourceutilizationBetteraverageresponsetimeBetterperformanceDrawbacksofConcurrencyApplicationsneedtobeprotectedfromoneanotherAdditionalcoordinationmecha
3、nismsamongapplicationsOverheadtoswitchamongapplicationsPotentialperformancedegradationwhenrunningtoomanyapplicationsMotivatingExample:TooMuchMilkTworobotsareprogrammedtomaintainthemilkinventoryatastore…Theyarenotawareofeachother’spresence…Robot:DumbRobot:DumberMotivatingExample:TooMuch
4、MilkDumbDumber4:00Lookintofridge:OutofmilkMotivatingExample:TooMuchMilkDumbDumber4:00Lookintofridge:Outofmilk4:05HeadforthewarehouseMotivatingExample:TooMuchMilkDumbDumber4:05Headforthewarehouse4:10Lookintofridge:OutofmilkMotivatingExample:TooMuchMilkDumbDumber4:10Lookintofridge:Outofmilk4
5、:15HeadforthewarehouseMotivatingExample:TooMuchMilkDumbDumber4:15Headforthewarehouse4:20ArrivewithmilkMotivatingExample:TooMuchMilkDumbDumber4:15Headforthewarehouse4:20ArrivewithmilkMotivatingExample:TooMuchMilkDumbDumber4:20Arrivewithmilk4:25GopartyMotivatingExample:TooMuchMilkDumbDumber4
6、:20Arrivewithmilk4:25Goparty4:30Arrivewithmilk:“Uhoh…”DefinitionsSynchronization:useatomicoperationstoensurecooperationamongthreadsMutualexclusion:ensureonethreadcandosomethingwithouttheinterferenceofotherthreadsCriticalsection:apieceofcodethatonlyonethreadcanexecuteatatimeMoreDefinitio
7、nsAlockpreventsathreadfromdoingsomethingForexample:fixthemilkproblembyputtingakeyontherefrigeratorCorrectnessPropertiesNeedtobecarefulaboutcorrectnessofconcurrentprograms,sincenon-deterministicWhatarethecorrectnesspropertiesforthe“Toomuchmilk”problem???Ne
此文档下载收益归作者所有
点击更多查看相关文章~~