您好,欢迎访问三七文档
当前位置:首页 > 高等教育 > 大学课件 > 《计算机操作系统教程》第三版答案作者左万历+周长林
1.?2.?3.?INTEL80x86CPU0x000000x003ff4.5.??6.7.FIFO8.?(1)(2)9.?12310?11.???(1);(2);(3);(4);(5);(6);(2)Windowsmp3Word(3)(4)(5)(6)12.???13.,14.?15.:(1)(2)(microkernel),:(1)(2)(3)(4)1.??2.??3.CC4.UNIXSystemV(processcontext)5.:(1)(Run):;(2)(Ready):;(3)(Wait):(Suspended)(Blocked)(Sleep)I/O;;I/O;I/O6.CPU7.TCBTCBPCBTCBPCTCB8.9.(1)(2)(3)(4)TCBTCB(1)(2)(1)(2)TCBCPUCPU10.?11..12.?1.:(1)(2)(3):SVCnSVC(SuperVisorCall);nn:SVCn:(1,2,,,m);n2.?cpu3.4.,PSWPC?PSWPC5.??PSWPCPSWPC6.???IBMPC000~03FF7.?PSW8.,?(1)(2)9.?10.,?11.?12.,??13.?(1)I/O(2)(3)(4)(1)I/O(2)(3)(4)14.???(1)(2)(3)(4)(5)(1)(3)(2)(4)(5)15.?16.:(1);(2).I/OI/O17.T1P1T2P2P1P2,T1T2??T1P1T2P2P1P2T1T2T1T2,T1T2T1T218.PSWPC?PSWPC1PSWPCPSWPC2PCPSWPCPSWPSW19.?20.,??CPU21.??RRCPUUNIX22.,,.??CPU23.(1);(2);(3)(1)(2);(3)24..1225(1)(2)(3)(4)PSWPC(1)(2)(3)PC26.?,.27.EDFRMSGanttTiCiA3010B4015C505EDFGanttA1B1C1A2B2C2A3B3A4C3101551015510151050102530405560708095105110120RMS1.?intn=0;main(){AB}A{while(1){n++;}};B(){while(1){printf(n);n=0;}};ABABnBAAB0AnB2.,,,?.3.??CPUCPUCPUCPU4.?(1):(2):TS(3)125.CPUCPUCPUCPU6.(test_and_set)7.8.CR1SV1,CR2SV2,P1CR1,P2CR2??SV1SV2P1CR1,P2CR29.Lamport?n()n-1()10.PV:regiondosemaphoremutex=1;,p(mutex);v(mutex);,11.V?12.S1S2,PV???(1)P(S1),P(S2)(2)P(S1),V(S2)(3)V(S1),P(S2)(4)V(S1),V(S2)(5)P(S1),P(S1)(6)P(S2),V(S2)(7)V(S1),P(S1)(8)V(S2),V(S2)(1),(2),(3),(4)5678PVPV13.PVsemaphoremutex_in=1;semaphoremutex_out=1;semaphoreproduct=0;intin=0out=0;while(1){P(mutex_in);buffer[in]=in++;v(mutex_in);V(product);}while(1){P(product);P(mutex_out);=buffer[out];out++;V(mutex_out);}14.AB,,AB:-MABNMN.PVAB.ABANBABMA,BB,A.Semaphoremutex=1sa=Nsb=M;A:B:while(1){while(1){p(sa);p(sb);p(mutex);p(mutex);ABV(mutex);V(mutex);V(sb);V(sa);}}15.PV:(1);(2)semaphores1=0,s2=0;while(1){while(1){p(s1);;v(s1);p(s2);v(s2);}}16.ABC,R,,.:(1),R;(2),R,R;(3),R,R.PV.intfree=1;//semaphoremutex=1;semaphoreqa=qb=qc=0;//intcounta=countb=countc=0;//AP(mutex);if(free==1){free=0;V(mutex);}else{counta++;V(mutex);P(qa);}Aif(countb0){countb--;V(qb);}else{if(countc0){countc--;V(qc);}else{if(counta0){counta--V(qa);}else{free=1;}}}ABC17.N(N3);:1do{;;}while(1)2do{;;}while(1)3do{;;;}while(1)PVPV1323/123semaphoreempty=N;semaphorewheel=0;semaphoreframe=0;1do{;P(empty);;V(frame);}while(1)2do{;P(empty);;V(wheel);}while(1)3do{P(frame);;V(empty);P(wheel);P(wheel);;V(empty);V(empty);;}while(1)1322231N-2N-1semaphores1=N-2;semaphores2=N-1;1do{;P(s1);P(empty);;V(frame);}while(1)2do{;P(s2);P(empty);;V(wheel);}while(1)3do{P(frame);;V(empty);V(s1);P(wheel);P(wheel);;V(empty);V(empty);V(s2);V(s2);;}while(1)Semaphores1=N-2s2=N-1mutex=1;intin1=0in2=N-1;intbuf[N];1do{;P(s1);P(empty);P(mutex);Buf[in1]=in1=in1+1;V(mutex);V(frame);}while(1)2do{;P(s2);P(empty);P(mutex);Buf[in2]=in2=in2-1;V(mutex);V(wheel);}while(1)3do{P(frame);P(mutex);Temp1=Buf[in1-1]in1=in1-1;V(mutex);V(empty);V(s1);P(wheel);P(wheel);P(mutex);Temp2=Buf[in2+1];in2=in2+1;Temp3=Buf[in2+1];In2=in2+1;V(mutex);V(empty);V(empty);V(s2);V(s2);;}while(1)18.()PVsemaphoreload=2;semaphorenorth=1;semaphoresouth=1;tosouth(){P(load);P(north);;;V(north);P(south);;V(south);V(load);}tonorth(){P(load);P(south);;V(south);P(north);;V(north);V(load);}19.3015PVsemaphoreempty=30;//30semaphorefull=0;//semaphorebuckets=5;//5semaphoremutex_well=1;//semaphoremutex_bigjar=1;//semaphoremutex_bucket=1;//young_monk(){while(1){P(empty);P(buckets);P(mutex_bucket);V(mutex_bucket);gotothewell;P(mutex_well);getwater;V(mutex_well);gotothetemple;P(mutex_bigjar);purethewaterintothebigold_monk(){while(){P(full);P(buckets);P(mutex_bucket);getabucket;V(mutex_bucket);P(mutex_bigjar);getwater;V(mutex_bigjar);V(buckets);V(empty);}}jar;V(mutex_bigjar);V(buckets);V(full);}}20.515nPV:(1)require(pidpri):pid1n;pri;15;(2)return(prnt):prnt15#defineN5Intflag[N+1];//flag[0],//flagi1=i=N01PCB*queue=NULL;//semaphoremutex_flag=1;//flagsemaphoremutex_queue=1;//intrequire(intpid,intpriority){P(mutex_flag);if(flag[0]0){flag[0]--;for(inti=1;iN+1;i++)if(flag==1){flag=0;break;}V(mutex_flag);returni;}else{V(mutex_flag);p(mutex_queue);pidqueueV(mutex_queue);}}return(intprint){P(mutex_flag);if(queue==NULL){flag[0]++;flag[print]=1;V(mutex_flag);}else{V(mutex_flag);p(mutex_queue);printqueuequeueV(mutex_queue);}}26./,:semaphorer_w_w,mutex,s;(1)intcount;(0)P(s);P(mutex);count++;if(count==1)P(r_w_w);V(mutex);V(s);{}P(mutex);count--;If(count==0)V(r_w_w);V(mutex);P(s);P(r_w_w);{}V(r_w_w);V(s);ss1.,,.(1);(2);(3);(4).1(2)p1,p2p1r1r2p2r2r1(3)(4)2.pkrk,rkrkp1,p2,p3,,pn,p1rk1rk1p2p2rk2rk2p3,,;pnrknrknp13.(fair)(unfair)(starvation)(starvetodeath)4.?(1)()(2)()(3)(4)(policy)FCFS5.?.p1195.56.??(NP)7.,ABCD..(1)EABSCWD(2)SBCEAWDCBAD1234s1,s2,s3,s41semaphores1=1,s2=1,s3=1,s4=1;WP(s1);//P(s4);D;C;V(s4);C;V(s1);EP(s2);B;P(s3)A;V(S2)P(s4)D;V(s3)D;V(s4);SP(s1);C;P(s2)B;V(S1)P(s3)A;V(s2)A;V(s3);8.,M,N,,M+N.Alloc(1)+Alloc(2)+,+Alloc(N)=M(Alloc(i)i)Need(1)+Need(2)+,Need(N)NNeed(i)i)M+N9.AllocationNeedAvailableABCDABCDABCDP0:003200121623P1:10001750P2:13542356P3:03320652P4:00140656(1)(2)P2Request[2]=(1,2,2,2),11Work=AvailableFinish=false2i:Finish[i]=
本文标题:《计算机操作系统教程》第三版答案作者左万历+周长林
链接地址:https://www.777doc.com/doc-8695630 .html