首页 2JOB PROCESS AND THREAD

2JOB PROCESS AND THREAD

举报
开通vip

2JOB PROCESS AND THREADCHAPRE2:JOB、PROCESSANDTHREADLImei-anJOBPROCESSANDTHREAD 1.JOB 2.PROCESS 3.TREAD1.JOBOSBARECOMPUTERUSERHowtodealtheSchedulabilitymultiprogrammingSystemVM(virtualmachine)JOB1,JOB2,JOB3……1.JOB CharacteristicsofmultiprogrammingOS Multiprocessing(多道性)...

2JOB PROCESS AND THREAD
CHAPRE2:JOB、PROCESSANDTHREADLImei-anJOBPROCESSANDTHREAD 1.JOB 2.PROCESS 3.TREAD1.JOBOSBARECOMPUTERUSERHowtodealtheSchedulabilitymultiprogrammingSystemVM(virtualmachine)JOB1,JOB2,JOB3……1.JOB CharacteristicsofmultiprogrammingOS Multiprocessing(多道性) Schedulability(调度性,异步性) Non-Reproducibility(不可再现性)1.JOB DISCUSSION 1)Howtoavoidtheinteractionsofmanyjobsinthememoryofacomputer. 2)What’swayscanusedtooperatethejobincomputer?1.JOB IntroduceJCB(JobControlBlock,adata-structure)intoJOBMANAGEMENT ConsiderofthestructureanditemsofJCB (shouldconsidertheindependence,performance,scheduleinformationandsoon)1.JOB JobIdentifier JobName UserAccount(用户帐户) InformationofScheduling ResourceRequirement JobStatus AddressofInputWell AddressofOutputWell AddressofJob THESTRUCTUREOFJCB1.JOB TimeofLog-in TimeofJobstart TimeofJobFinish TimeofJobQuit ResourcePerformance DISCUSSION WhydoestheJCBincludeaddressindex? WhydoestheJCBincludetimeindex? THESTRUCTUREOFJCB1.JOB DISCUSSION Howmanystatusofjob? THESTATUSOFJCB1.JOB ExecutingState Readystate I/OState THESTATUSOFJCB1.JOB ExecutingState Readystate I/OState THECONTROLOFJCBExecutingStateI/OStateReadystateExecutingfinishedschedulingI/OrequestI/OrequestI/OfinishedJOB JOBisaprogramentityinmemorythathasaindependentlogicmeaningandcanoperateincomputerJOB JCB +PROGRAM +DATAJOBENTITY2.PROCESS CharacteristicsofTime-sharedOSMultipathing(多路性)Independence(独立性)Timeliness(及时性)Interactivity(交互性)2.PROCESS DISCUSSION FromJCB,trytogetthestructureanditemsofPCB2.PROCESS ProcessIdentifier; CurrentStatus; AddressofProgramandData; BillofResourceRequirement; Priority CPUstatus(CPU现场保护区); MechanismofSynchronization(同步)andCommunication(通信) THESTRUCTUREOFPCB2.PROCESS NextPCBPointer; OtherMessages. DISCUSSION Whereoftimeindex? Howtoensuretheindependenceoftheprocessesinonecomputer? BasethePCBstructure,howtoorganizeallPCBsinmemory? THESTRUCTUREOFPCB2.PROCESS Link IndexORGANISINGOFPCBLINKQUEUEOFPCBINDEXOFPCBPROCESS PCB +PROGRAM +DATAPROCESSENTITYEntityofprocessPROCESS PROCESSistherunningprocessofaprocessentity.It’saindependentbasicunitofoperationandresourcerequestincomputer.Definitionofprocess2.PROCESS DISCUSSION Themodelsofthejobsandprocessesincomputer. Howtoconstructthejobentity(作业实体)andprocessentity(进程实体)? Howmanystatustoaprocess?STATUSOFPROCESS2.PROCESS TwostatusmodelBASICSTATUSOFPROCESSExecutingNon-ExecutingFinishedScheduling2.PROCESS ThreestatusmodelBASICSTATUSOFPROCESSExecutingReadyBlockSchedulingTimesliceExhaustI/ORequestI/OFinished2.PROCESS FirstextendedfivestatusmodelEXTENDEDSTATUSOFPROCESSExecutingReadyBlockSchedulingTimesliceExhaustI/ORequestI/OFinishedCreationPermissionTerminationProcessFinished2.PROCESS SecondextendedfivestatusmodelEXTENDEDSTATUSOFPROCESSIntroduceSuspendedModeinStatusofProcessExecutingStaticReadyActiveReadyStaticBlockActiveBlockSuspendedReleaseSuspendedActiveReleaseActiveSuspendedI/ORequestScheduling2.PROCESS ExtendedsevenstatusmodelEXTENDEDSTATUSOFPROCESSSevenStatusModelofProcessExecutingStaticReadyActiveReadyStaticBlockActiveBlockSuspendedReleaseSuspendedActiveReleaseActiveSuspendedI/ORequestTerminationCreationProcessFinishedPermissionScheduling2.PROCESS EventsMakeProcessStatusTranslationCONTROLPROCESSSevenStatusModelofProcessExecutingStaticReadyActiveReadyStaticBlockActiveBlockSuspendedRelease(wakeup)SuspendedActiveRelease(wakeup)ActiveSuspendedI/ORequest(block)TerminationCreationProcessFinishedPermissionCreationTerminationScheduling2.PROCESS EventsMakeProcessStatusTranslation CreationandTermination; BlockandWakeup; SuspendedandActive; Scheduling.2.PROCESS Creation Whocancreateaprocess? Parentprocess Userlog-in Jobscheduling Howtocreateaprocess? EmptyPCBrequest Resourceallocation InitiatePCB InsertPCBtoreadyqueueCreationandTerminationProcesstree2.PROCESS Termination Whocanterminateaprocess? Parentprocess Userquit normalendandabnormalend Howtoterminateaprocess? SearchPCB Changethestatusoftheprocess Releaseresource KeepaccountsCreationandTermination2.PROCESS Block Whocanblockaprocess? Servicerequest(suchasI/Orequest) synchronization(suchaswaitingforadata) Howtoblockaprocess? CallforaPrimitive(原语suchasblockprimitive) Changethestatusoftheprocess InserttheblockprocesstoblockqueueBlockandWakeup2.PROCESS Wakeup Whocanwakeupaprocess? FinishedtheServicerequestorsynchronization Howtowakeupaprocess? CallforaPrimitive(原语suchaswakeupprimitive) Changethestatusoftheprocess InserttheblockprocesstoreadyqueueBlockandWakeup2.PROCESS Suspended Whocansuspendedaprocess? Userrequest OSrequest Howtosuspendedaprocess? Changethestatusoftheprocess PlacePCBinspecifiedarea(特定区域)SuspendedandActive2.PROCESS Active Whocanactiveaprocess? Userrequest OSrequest Howtoactiveaprocess? Reconstructtheprocessentity(进程实体) Changethestatusoftheprocess InserttheprocesstocorrespondingqueueSuspendedandActive2.PROCESS Whocanscheduleaprocess? System Howtoscheduleaprocess? Searchallreadyprocesses; RunningschedulingalgorithmtodeterminewhichprocessshouldbedispatchedCPU; Changethestatusofthisprocess; DispatchCPUtothisprocess.Scheduling2.PROCESS SchedulingandSchedulingalgorithm Schedulingistodeterminetheorderofusingacertainresourcebasedonsomestrategy(策略) Schedulingalgorithmisthemethodorstrategyusedtodeterminetheorderofusingacertainresource modesofdispatchingCPU PreemptiveMode Non-PreemptiveMode Scheduling2.PROCESS Classificationofscheduling Jobscheduling Processscheduling Staticprocessscheduling(Activestaticprocess,激活挂起进程,中程调度)Scheduling2.PROCESS Jobscheduling CallJobschedulingaslong-distanceschedulingorhigh-levelscheduling Jobschedulingschedulejobfromexternalstoragetomemory,thencreateaprocessforthisjobandinsertthisprocesstothereadyqueue.Scheduling-Jobscheduling2.PROCESS Algorithmofjobscheduling Thetimeindexofjobscheduling (1)Turnaroundtime(周转时间) turnaroundtime=timeofquit-timeoflog-in Waitingtimeinexternalstorage Waitingtimeinreadyqueue Executingtime WaitingtimeofI/OScheduling-Jobscheduling2.PROCESS Algorithmofjobscheduling Thetimeindexofjobscheduling Example Ajobarrivestimeis5,entermemorytimeis8;firststarttoexecutingtimeis15,finishedtimeis18;secondstarttoexecutingtimeis30,finishedtimeis31,finishedtimeofI/Ois36;thirdstarttoexecutingtimeis45,finishedtimeis46,finishedtimeofI/Ois54,quit.Solvetheturnaroundtime Scheduling-Jobscheduling2.PROCESS Algorithmofjobscheduling Thetimeindexofjobscheduling (2)Averageturnaroundtime(平均周转时间) Example Acomputerstarttooperateat9:00AM,andendoperationat12:00AM.Inallthistime,2326jobshavebeenfinished.SolvetheAverageturnaroundtime.Scheduling-Jobscheduling2.PROCESS Algorithmofjobscheduling Thetimeindexofjobscheduling (3)Systemservicetime(系统服务时间) CallthetimecostoftheCPUexecutingajobasthesystemservicetimeofthisjob (4)Weightedaverageturnaroundtime(带权平均周转时间) AssumeTistheturnaroundtimeofajob,TSisthesystemservicetimeofthisjob. DefineW=T/TSistheweightedturnaroundtimeofthisjob Iftherearenjobs,define ItistheaverageweightedturnaroundtimeofthesenjobsScheduling-Jobscheduling2.PROCESS Algorithmofjobscheduling FCFS(FIFO)algorithm:FirstComeFirstService TheCPUusedorderbasedonthearrivesequenceScheduling-Jobscheduling 进程 到达时间 服务时间 开始执行时间 完成时间 周转时间 带权周转时间 平均周转时间 A 0 1 B 1 100 C 2 1 平均带权周转时间 D 3 100 E 7 402.PROCESS Algorithmofjobscheduling FCFS(FIFO)algorithm:firstcomefirstservice TheCPUusedorderbasedonthearrivesequenceScheduling-Jobscheduling 进程 到达时间 服务时间 开始执行时间 完成时间 周转时间 带权周转时间 平均周转时间 A 0 1 0 1 1 1 127 B 1 100 1 101 100 1 C 2 1 101 102 100 100 平均带权周转时间 D 3 100 102 202 199 1.99 21.97 E 7 40 202 242 235 5.882.PROCESS Algorithmofjobscheduling FCFS(FIFO)algorithm ExerciseScheduling-Jobscheduling 进程 到达时间 服务时间 开始执行时间 完成时间 周转时间 带权周转时间 平均周转时间 A 0 6 B 3 9 C 5 20 平均带权周转时间 D 6 30 E 8 1202.PROCESSScheduling-Jobscheduling 进程 到达时间 服务时间 开始执行时间 完成时间 周转时间 带权周转时间 平均周转时间 A 0 6 0 6 6 1 56.8 B 3 9 6 15 12 1.33 C 5 20 15 35 30 1.5 平均带权周转时间 D 6 30 35 65 59 1.97 1.46 E 8 120 65 185 177 1.482.PROCESS Algorithmofjobscheduling SJFalgorithm:ShortestJobFirst TheCPUusedorderbasedonthesystemservicetime ExampleScheduling-Jobscheduling2.PROCESS Algorithmofjobscheduling SJFalgorithm:ShortestJobFirst TheCPUusedorderbasedonthesystemservicetime ExampleScheduling-Jobscheduling 进程 到达时间 服务时间 开始执行时间 完成时间 周转时间 带权周转时间 平均周转时间 A 0 1 0 1 1 1 115 B 1 100 1 101 100 1 C 2 1 101 102 100 100 平均带权周转时间 D 3 100 142 242 239 2.39 21.55 E 7 40 102 142 135 3.382.PROCESS Algorithmofjobscheduling SJFalgorithm:shortestjobfirst TheCPUusedorderbasedonthesystemservicetime ExerciseScheduling-Jobscheduling 进程 到达时间 服务时间 开始执行时间 完成时间 周转时间 带权周转时间 平均周转时间 A 0 6 B 3 120 C 5 30 平均带权周转时间 D 6 20 E 8 92.PROCESSScheduling-Jobscheduling 进程 到达时间 服务时间 开始执行时间 完成时间 周转时间 带权周转时间 平均周转时间 A 0 6 0 6 6 1 59 B 3 120 65 185 182 1.52 C 5 30 35 65 60 2 平均带权周转时间 D 6 20 6 26 20 1 1.7 E 8 9 26 35 27 32.PROCESSScheduling-processscheduling Processscheduling ProcessschedulingistodeterminewhichprocessinreadyqueuewillgetCPUanddispatchCPUtothisprocess. Callprocessschedulingasshort-distanceschedulingorlow-levelscheduling2.PROCESSScheduling-processscheduling Processschedulingalgorithm Priority It’sanumber.Thisnumberisdeterminedbysystemandwillbethebasisofprocessscheduling Thebasisofdeterminingtheprioritylistasfallow: Thetypeofprocess Resourcerequirementofprocess Userdemand Classthepriorityofprocessintotwotypes: Staticpriority Dynamicpriority 2.PROCESSScheduling-processscheduling Processschedulingalgorithm (1)Highestpriorityfirstalgorithm(HPF) 1)Highresponseratiofirstalgorithm(HRRF) Definewaitingtime+servicetimeasresponsetime Defineresponseratioas(responsetime)/(servicetime)2.PROCESS Highresponseratiofirstalgorithm(HRRF)Example2.PROCESSScheduling-processschedulingExercise 进程 到达时间 服务时间 开始执行时间 完成时间 周转时间 带权周转时间 平均周转时间 A 0 6 B 3 120 C 5 30 平均带权周转时间 D 6 20 E 8 92.PROCESSScheduling-processscheduling 进程 到达时间 服务时间 执行顺序 开始执行时间 完成时间 周转时间 带权周转时间 平均周转时间 A 0 6 1 0 6 6 1 63 B 3 120 5 65 185 182 1.51 C 5 30 2 6 36 31 1.03 平均带权周转时间 D 6 20 4 45 65 59 2.95 2.12 E 8 9 3 36 45 37 4.112.PROCESSScheduling-processscheduling Processschedulingalgorithm 2)Roundtime-slicealgorithm(HPF) 3)Multi-levelfeedbackqueuealgorithm 2.PROCESSScheduling-processscheduling Processschedulingalgorithm (2)Real-Timeschedulingalgorithm(RTSA) 1)Earliest-DeadlineFirst(EDF)(最早开始截止时间优先) Giventhelaststartdeadline2.PROCESSScheduling-processschedulingExercise2.PROCESSScheduling-processscheduling 进程 到达时间 服务时间 开始截止时间 开始时间 结束时间 周转时间 带权周转时间 平均周转时间 A 0 10 5 0 10 10 1 19.25 B 3 12 12 10 22 19 1.58 平均带权周转时间 C 9 11 33 29 40 31 2.82 1.96 D 12 7 23 22 29 17 2.432.PROCESSScheduling-processscheduling Processschedulingalgorithm 2)LeastLaxityFirst(LLF)(最低松弛度优先算法) Giventhelastfinisheddeadline2.PROCESS2)LeastLaxityFirst(LLF)(最低松弛度优先算法)Example DISCUSSION Isitcorrectoftheabovegraph?Scheduling-processscheduling2.PROCESS2)LeastLaxityFirst(LLF)(最低松弛度优先算法) Thecorrectgraph2.PROCESSExerciseScheduling-processscheduling2.PROCESSScheduling-processschedulingExercise 进程 到达时间 服务时间 最晚完成截止时间 最晚开始截止时间 松弛度 开始时间 结束时间 周转时间 带权周转时间 平均周转时间 A 0 10 15 5 5 0 10 10 1 15.4 B 3 12 30 18 8 10 22 19 1.58 带权平均周转时间 C 9 11 50 39 10 29 40 31 2.82 1.57 D 12 7 42 35 13 22 29 17 2.432.PROCESSScheduling-staticprocessscheduling Staticprocessscheduling Staticprocessschedulingistodeterminewhichsuspendedprocessinexternalstoragewillbeactive CallStaticprocessschedulingasmiddle-distanceschedulingormiddle-levelscheduling2.PROCESS Themodelofschedulingqueue Onlyprocessscheduling(correspondingthethreestatusmodelofprocess)Scheduling-processscheduling2.PROCESS Themodelofschedulingqueue Includedprocessschedulingandjobscheduling(correspondingthefirstfivestatusmodelofprocess)Scheduling-processscheduling2.PROCESS Themodelofschedulingqueue Includedprocessschedulingandjobschedulingandmiddledistancescheduling(correspondingthesevenstatusmodelofprocess)Scheduling-processscheduling2.PROCESSExample jobinputa,b;x=a+b;ouputx Inter-processcommunicationprocess1 inputa,b process2 x=a+b process3 ouputx process1process2process3a,bx2.PROCESSInter-processcommunicationprocess1process2process3a,bx Thetypesofinter-processcommunication (1)memory-shared(共享存储区) 1)datastructureshared variable-shared Suchasprocess1andprocess2sharingvariableaandb union-shared2.PROCESSInter-processcommunication Thetypesofinter-processcommunication (1)Memory-shared 2)Memoryareashared Memoryblockshared Memorypageshared2.PROCESSInter-processcommunication Thetypesofinter-processcommunication (2)File-shared(externalmemoryshared):pipe(管道)2.PROCESSInter-processcommunication Thetypesofinter-processcommunication (3)Bufferedqueueinnetworkshared:message(消息通信与…thingking)senderreceiverput(item)get(item)bufferedqueuenetworkmessage3.THREAD ReasonofintroducingthreadinOS Processesoccupymoreresourcebutnotuse; Thetimeandspacecostofprocessswitchingarelarge. Howtotranslateprocesstothread Separatethepropertiesofprocessesastheunitofrequestingresourceandrunning; Translateprocesstoaunitofrequestingresource,letthreadasaunitofrunning Processbecomesacontainer(容器)ofthreadsThreadconcept3.THREADThreadModel (a)Threeprocesseseachwithonethread (b)Oneprocesswiththreethreads3.THREADThreadModel(TCB) Itemssharedbyallthreadsinaprocess Itemsprivatetoeachthread3.THREADStatusofThreadreadyrunningblockI/OrequestI/OfinishedschedulingTimesliceover3.THREADThreadModelEachthreadhasitsownstackAuser-levelthreadspackageImplementingThreadsinUserSpace3.THREADAllmanagementoperationsforthreadsconstructsabase,allthreadsandmanagementoperationinthisbaserunninginuserspaceAkernelthreads-managedbythekernelImplementingThreadsintheKernel3.THREADAllmanagementoperationsforthreadsisrunninginkernelspace3.THREADmixedthread-multiplexinguser-levelthreadsontokernel-levelthreadsHybridImplementationsOnekernelthreadmanageoneormoreuserthread
本文档为【2JOB PROCESS AND THREAD】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_704284
暂无简介~
格式:ppt
大小:2MB
软件:PowerPoint
页数:0
分类:文化娱乐
上传时间:2018-09-18
浏览量:5