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
近日华纳云商家正式上线了美国服务器产品,这次美国机房上线的产品包括美国云服务器、美国独立服务器、美国高防御服务器以及美国高防云服务器等产品,新产品上线华纳云推出了史上优惠力度最高的特价优惠活动,美国云服务器低至3折,1核心1G内存5Mbps带宽低至24元/月,20G ddos高防御服务器低至688元/月,年付周期再送2个月、两年送4个月、三年送6个月,终身续费同价,有需要的朋友可以关注一下。华纳云...
百纵科技:美国高防服务器,洛杉矶C3机房 独家接入zenlayer清洗 带金盾硬防,CPU全系列E52670、E52680v3 DDR4内存 三星固态盘阵列!带宽接入了cn2/bgp线路,速度快,无需备案,非常适合国内外用户群体的外贸、搭建网站等用途。C3机房,双程CN2线路,默认200G高防,3+1(高防IP),不限流量,季付送带宽美国洛杉矶C3机房套餐处理器内存硬盘IP数带宽线路防御价格/月套...
2021年6月底,raksmart开发出来的新产品“cloud-云服务器”正式上线对外售卖,当前只有美国硅谷机房(或许以后会有其他数据中心加入)可供选择。或许你会问raksmart云服务器怎么样啊、raksm云服务器好不好、网络速度快不好之类的废话(不实测的话),本着主机测评趟雷、大家受益的原则,先开一个给大家测评一下!官方网站:https://www.raksmart.com云服务器的说明:底层...
linuxwindows为你推荐
怎么查询商标怎样查询商标有没有被注册方法有哪些?微信回应封杀钉钉微信发过来的钉钉链接打不开?老虎数码1200万相素的数码相机都有哪些款?大概价钱是多少?百度关键词分析百度竞价关键词分析需要从哪些数据入手?www.522av.com现在怎样在手机上看AVjavmoo.comjavbus上不去.怎么办kb123.net连网方式:wap和net到底有什么不一样的www.henhenlu.com有一个两位数,十位数字是个位数字的二分之一,将十位数字与个位数字对调,新的两位数比原来大36,这个两位数www.toutoulu.com老板强大的外包装还是被快递弄断了www.dm8.cc有没有最新的日本动漫网站?
国内vps 域名服务器的作用 lamp安装 西安电信测速 enom hostgator 美元争夺战 rackspace 网站保姆 京东商城双十一活动 网站cdn加速 爱奇艺vip免费试用7天 广州服务器 t云 33456 根服务器 厦门电信 云营销系统 贵阳电信 阿里云手机官网 更多