CHAPRE2:JOB、PROCESSANDTHREADLImei-anJOBPROCESSANDTHREAD1.JOB2.PROCESS3.TREAD1.JOBOSBARECOMPUTERUSERHowtodealtheSchedulabilitymultiprogrammingSystemVM(virtualmachine)JOB1,JOB2,JOB3……1.JOBCharacteristicsofmultiprogrammingOSMultiprocessing(多道性)Schedulability(调度性,异步性)Non-Reproducibility(不可再现性)1.JOBDISCUSSION1)Howtoavoidtheinteractionsofmanyjobsinthememoryofacomputer.2)What’swayscanusedtooperatethejobincomputer?1.JOBIntroduceJCB(JobControlBlock,adata-structure)intoJOBMANAGEMENTConsiderofthestructureanditemsofJCB(shouldconsidertheindependence,performance,scheduleinformationandsoon)1.JOBJobIdentifierJobNameUserAccount(用户帐户)InformationofSchedulingResourceRequirementJobStatusAddressofInputWellAddressofOutputWellAddressofJobTHESTRUCTUREOFJCB1.JOBTimeofLog-inTimeofJobstartTimeofJobFinishTimeofJobQuitResourcePerformanceDISCUSSIONWhydoestheJCBincludeaddressindex?WhydoestheJCBincludetimeindex?THESTRUCTUREOFJCB1.JOBDISCUSSIONHowmanystatusofjob?THESTATUSOFJCB1.JOBExecutingStateReadystateI/OStateTHESTATUSOFJCB1.JOBExecutingStateReadystateI/OStateTHECONTROLOFJCBExecutingStateI/OStateReadystateExecutingfinishedschedulingI/OrequestI/OrequestI/OfinishedJOBJOBisaprogramentityinmemorythathasaindependentlogicmeaningandcanoperateincomputerJOBJCB+PROGRAM+DATAJOBENTITY2.PROCESSCharacteristicsofTime-sharedOSMultipathing(多路性)Independence(独立性)Timeliness(及时性)Interactivity(交互性)2.PROCESSDISCUSSIONFromJCB,trytogetthestructureanditemsofPCB2.PROCESSProcessIdentifier;CurrentStatus;AddressofProgramandData;BillofResourceRequirement;PriorityCPUstatus(CPU现场保护区);MechanismofSynchronization(同步)andCommunication(通信)THESTRUCTUREOFPCB2.PROCESSNextPCBPointer;OtherMessages.DISCUSSIONWhereoftimeindex?Howtoensuretheindependenceoftheprocessesinonecomputer?BasethePCBstructure,howtoorganizeallPCBsinmemory?THESTRUCTUREOFPCB2.PROCESSLinkIndexPCB14PCB2PCB3PCB4PCB5PCB6PCB7PCB8PCB93087901执行指针就绪队列指针阻塞队列指针空闲队列指针…ORGANISINGOFPCBLINKQUEUEOFPCB执行指针就绪索引表PCB1PCB2PCB3PCB4PCB5PCB6PCB7阻塞索引表就绪表指针阻塞表指针INDEXOFPCBPROCESSPCB+PROGRAM+DATAPROCESSENTITYEntityofprocessPROCESSPROCESSistherunningprocessofaprocessentity.It’saindependentbasicunitofoperationandresourcerequestincomputer.Definitionofprocess2.PROCESSDISCUSSIONThemodelsofthejobsandprocessesincomputer.Howtoconstructthejobentity(作业实体)andprocessentity(进程实体)?Howmanystatustoaprocess?STATUSOFPROCESS2.PROCESSTwostatusmodelBASICSTATUSOFPROCESSExecutingNon-ExecutingFinishedScheduling2.PROCESSThreestatusmodelBASICSTATUSOFPROCESSExecutingReadyBlockSchedulingTimesliceExhaustI/ORequestI/OFinished2.PROCESSFirstextendedfivestatusmodelEXTENDEDSTATUSOFPROCESSExecutingReadyBlockSchedulingTimesliceExhaustI/ORequestI/OFinishedCreationPermissionTerminationProcessFinished2.PROCESSSecondextendedfivestatusmodelEXTENDEDSTATUSOFPROCESSIntroduceSuspendedModeinStatusofProcessExecutingStaticReadyActiveReadyStaticBlockActiveBlockSuspendedReleaseSuspendedActiveReleaseActiveSuspendedI/ORequestScheduling2.PROCESSExtendedsevenstatusmodelEXTENDEDSTATUSOFPROCESSSevenStatusModelofProcessExecutingStaticReadyActiveReadyStaticBlockActiveBlockSuspendedReleaseSuspendedActiveReleaseActiveSuspendedI/ORequestTerminationCreationProcessFinishedPermissionScheduling2.PROCESSEventsMakeProcessStatusTranslationCONTROLPROCESSSevenStatusModelofProcessExecutingStaticReadyActiveReadyStaticBlockActiveBlockSuspendedRelease(wakeup)SuspendedActiveRelease(wakeup)ActiveSuspendedI/ORequest(block)TerminationCreationProcessFinishedPermissionCreationTerminationScheduling2.PROCESSEventsMakeProcessStatusTranslationCreationandTermination;BlockandWakeup;SuspendedandActive;Scheduling.2.PROCESSCreationWhocancreateaprocess?ParentprocessUserlog-inJobschedulingHowtocreateaprocess?EmptyPCBrequestResourceallocationInitiatePCBInsertPCBtoreadyqueueCreationandTerminationProcesstree2.PROCESSTerminationWhocanterminateaprocess?ParentprocessUserquitnormalendandabnormalendHowtoterminateaprocess?SearchPCBChangethestatusoftheprocessReleaseresourceKeepaccountsCreationandTermination2.PROCESSBlockWhocanblockaprocess?Servicerequest(suchasI/Orequest)synchronization(suchaswaitingforadata)Howtoblockaprocess?CallforaPrimitive(原语suchasblockprimitive)ChangethestatusoftheprocessInserttheblockprocesstoblockqueueBlockandWakeup2.PROCESSWakeupWhocanwakeupaprocess?FinishedtheServicerequestorsynchronizationHowtowakeupaprocess?CallforaPrimitive(原语suchaswakeupprimitive)ChangethestatusoftheprocessInserttheblockprocesstoreadyqueueBlockandWakeup2.PROCESSSuspendedWhocansuspendedaprocess?UserrequestOSrequestHowtosuspendedaprocess?ChangethestatusoftheprocessPlacePCBinspecifiedarea(特定区域)SuspendedandActive2.PROCESSActiveWhocanactiveaprocess?UserrequestOSrequestHowtoactiveaprocess?Reconstructtheprocessentity(进程实体)ChangethestatusoftheprocessInserttheprocesstocorrespondingqueueSuspendedandActive2.PROCESSWhocanscheduleaprocess?SystemHowtoscheduleaprocess?Searchallreadyprocesses;Runningschedulingalgorithm