ProcessesinUnix,Linux,andWindowsCS502OperatingSystems(SlidesincludematerialsfromOperatingSystemConcepts,7thed.
,bySilbershatz,Galvin,&GagneandfromModernOperatingSystems,2nded.
,byTanenbaum)GenericProcesses–ReviewProcessstate–informationmaintainedbyOSforrepresentingprocess,inPCBPSW,registers,conditioncodes,etc.
Memory,files,resources,etc.
Priority,blockingstatus,etc.
QueuesReadyQueueSemaphorequeuesOtherkindsofqueuesnotyetcovered(e.
g.
,fordisks,communicationresources,etc.
)GenericProcesses–Review(continued)InterruptsandtrapsSwitchingcontextsSavingstateofoneprocessLoadingstateofanotherprocessSchedulingDecidingwhichprocesstorun(orserve)nextMorenextweekInterprocessCommunicationLaterinthecourseReadingAssignmentChapter3ofSilbershatzEspecially:§3.
1–3.
3Process(withcapital"P")AProcessinUnix,Linux,orWindowscomprises:–anaddressspace–usuallyprotectedandvirtual–mappedintomemorythecodefortherunningprogramthedatafortherunningprogramanexecutionstackandstackpointer(SP)theprogramcounter(PC)asetofprocessorregisters–generalpurposeandstatusasetofsystemresourcesfiles,networkconnections,pipes,…privileges,(human)userassociation,……Processes–AddressSpace0x000000000xFFFFFFFFVirtualaddressspaceprogramcode(text)staticdataheap(dynamicallyallocated)stack(dynamicallyallocated)PCSPSeealsoSilbershatz,figure3.
1ProcessesintheOS–RepresentationTousers(andotherprocesses)aprocessisidentifiedbyitsProcessID(PID)IntheOS,processesarerepresentedbyentriesinaProcessTable(PT)PIDisindexto(orpointerto)aPTentryPTentry=ProcessControlBlock(PCB)PCBisalargedatastructurethatcontainsorpointstoallinfoabouttheprocessLinux-definedintask_struct–over70fieldsseeinclude/linux/sched.
hNT–definedinEPROCESS–about60fieldsProcessesintheOS–PCBTypicalPCBcontains:executionstatePC,SP&processorregisters–storedwhenprocessisnotinrunningstatememorymanagementinfoPrivilegesandownerinfoschedulingpriorityresourceinfoaccountinginfoProcess–startingandendingProcessesarecreated…WhenthesystembootsBytheactionsofanotherprocess(morelater)BytheactionsofauserBytheactionsofabatchmanagerProcessesterminate…Normally–exitVoluntarilyonanerrorInvoluntarilyonanerrorTerminated(killed)bytheactionsauseroraprocessProcesses–SwitchingWhenaprocessisrunning,itshardwarestateisintheCPU–PC,SP,processorregistersWhentheOSsuspendsrunningaprocess,itsavesthehardwarestateinthePCBContextswitchistheactofswitchingtheCPUfromoneprocesstoanothertimesharingsystemsmaydo100sor1000sofswitches/sectakes1-100microsecondsontoday'shardwareProcesses–StatesProcesshasanexecutionstateready:waitingtobeassignedtoCPUrunning:executingontheCPUwaiting:waitingforanevent,e.
g.
I/OProcesses–StateQueuesTheOSmaintainsacollectionofprocessstatequeuestypicallyonequeueforeachstate–e.
g.
,ready,waiting,…eachPCBisputontoaqueueaccordingtoitscurrentstateasaprocesschangesstate,itsPCBisunlinkedfromonequeue,andlinkedtoanotherProcessstateandthequeueschangeinresponsetoevents–interrupts,trapsProcesses–PrivilegesUsersaregivenprivilegesbythesystemadministratorPrivilegesdeterminewhatrightsauserhasforanobject.
Unix/Linux–Read|Write|eXecutebyuser,groupand"other"(i.
e.
,"world")WinNT–AccessControlListProcesses"inherit"privilegesfromuserProcesses–CreationUnix/LinuxCreateanew(child)process–fork();AllocatesnewPCBClonesthecallingprocess(almost)CopyofparentprocessaddressspaceCopiesresourcesinkernel(e.
g.
files)PlacesnewPCBonReadyqueueReturnfromfork()call0forchildchildPIDforparentExampleoffork()intmain(intargc,char**argv){char*name=argv[0];intchild_pid=fork();if(child_pid==0){printf("Childof%sseesPIDof%d\n"name,child_pid);return0;}else{printf("Iamtheparent%s.
Mychildis%d\n",name,child_pid);return0;forktestChildofforktestseesPIDof0Iamtheparentforktest.
Mychildis486StartingNewProgramsUnix&Linux:–intexec(char*prog,char**argv)CheckprivilegesandfiletypeLoadsprogram"prog"intoaddressspaceReplacingpreviouscontents!
Executionstartsatmain()Initializescontext–e.
g.
passesarguments*argvPlacePCBonreadyqueuePreserves,pipes,openfiles,privileges,etc.
ForkingaNewProgramfork()followedbyexec()CreatesanewprocessascloneofpreviousoneFirstthingthatclonedoesistoreplaceitselfwithnewprogramFork+Exec–shell-likeintmain(intargc,char**argv){char*argvNew[5];intpid;if((pid=fork())<0){printf("Forkerror\n");exit(1);}elseif(pid==0){/*childprocess*/argvNew[0]="/bin/ls";argvNew[1]="-l";argvNew[2]=NULL;if(execve(argvNew[0],argvNew,environ)<0){printf("Execveerror\n");exit(1);}}else{/*parent*/wait(pid);/*waitforthechildtofinish*/}}Processes–NewProgramsWindows/NT–combinesfork&execCreateProcess(10arguments)NotaparentchildrelationshipNote–privilegesrequiredtocreateanewprocessWindows,Unix,andLinux(traditional)ProcessesareinseparateaddressspacesBydefault,nosharedmemoryProcessesareunitofschedulingAprocessisready,waiting,orrunningProcessesareunitofresourceallocationFiles,I/O,memory,privileges,…Processesareusedfor(almost)everything!
ANoteonImplementationManyOSimplementationsinclude(partsof)kernelineveryaddressspaceProtectedEasytoaccessAllowskerneltoseeintoclientprocessesTransferringdataExaminingstate…Processes–AddressSpace0x000000000xFFFFFFFFVirtualaddressspacecode(text)staticdataheap(dynamicallyallocated)KernelCodeandDataPCSPUserSpacestack(dynamicallyallocated)KernelSpace32-bitLinux&WinXP–3G/1Guserspace/kernelspaceLinuxKernelImplementationKernelmayexecuteineitherProcesscontextvs.
InterruptcontextInProcesscontext,kernelhasaccesstoVirtualmemory,files,otherprocessresourcesMaysleep,takepagefaults,etc.
,onbehalfofprocessInInterruptcontext,noassumptionaboutwhatprocesswasexecuting(ifany)Noaccesstovirtualmemory,files,resourcesMaynotsleep,takepagefaults,etc.
ProcessesinOtherOperatingSystemsImplementationswilldifferSometimesasubsetofUnix/Linux/WindowsSometimesquitedifferentMayhavemorerestrictedsetofresourcesOften,specializeinreal-timeconstraintsQuestionsImplementationReadyqueuePCBPCBPCBPCBSemaphoreAcount=0PCBPCBSemaphoreBcount=2
硅云怎么样?硅云是一家专业的云服务商,硅云的主营产品包括域名和服务器,其中香港云服务器、香港云虚拟主机是非常受欢迎的产品。硅云香港可用区接入了中国电信CN2 GIA、中国联通直连、中国移动直连、HGC、NTT、COGENT、PCCW在内的数十家优质的全球顶级运营商,是为数不多的多线香港云服务商之一。目前,硅云香港云服务器,CN2+BGP线路,1核1G香港云主机仅188元/年起,域名无需备案,支持个...
野草云服务器怎么样?野草云是一家成立了9年的国人主机商家,隶属于香港 LucidaCloud Limited (HongKong Registration No. 2736053 / 香港網上查冊中心)。目前,野草云主要销售香港、美国的VPS、虚拟主机及独立服务器等产品,本站也给大家分享过多次他家的优惠了,目前商家开启了优惠活动,香港/美国洛杉矶CN2+BGP云服务器,1核1G仅38元/月起!点击...
Virmach对资源限制比较严格,建议查看TOS,自己做好限制,优点是稳定。 vCPU 内存 空间 流量 带宽 IPv4 价格 购买 1 512MB 15GB SSD 500GB 1Gbps 1 $7/VirMach:$7/年/512MB内存/15GB SSD空间/500GB流量/1Gbps端口/KVM/洛杉矶/西雅图/芝加哥/纽约等 发布于 5个月前 (01-05) VirMach,美国老牌、稳...
linuxwindows为你推荐
太空国家世界上第一个把人类送入太空的国家是西部妈妈网九芽妈妈网加盟费多少mathplayer如何学好理科陈嘉垣电视剧《反黑》里面,雷太太女儿扮演者是谁?嘀动网动网和爱动网各自的优势是什么?月神谭有没有什么好看的小说?拒绝言情小说!丑福晋男主角中毒眼瞎毁容,女主角被逼当丫鬟,应用自己的血做药引帮男主角解毒的言情小说www.228gg.comwww.a8tb.com这个网站该如何改善www.zjs.com.cn请问宅急送客服电话号码是多少?斗城网女追男有多易?喜欢你,可我不知道你喜不喜欢我!!平安夜希望有他陪我过
手机域名注册 备案未注册域名 安徽双线服务器租用 天津服务器租赁 最便宜虚拟主机 80vps 站群服务器 l5639 googleapps 10t等于多少g payoneer godaddy 回程路由 lamp配置 免费ftp空间申请 合肥鹏博士 ftp教程 gspeed php空间推荐 域名转接 更多