第 2 章 进程控制与同步

Click here to load reader

Upload: oriole

Post on 23-Jan-2016

203 views

Category:

Documents


1 download

DESCRIPTION

操作系统原理与 Windows 2003 实践教程. 第 2 章 进程控制与同步. 第二章 进程控制与同步. 2.1 进程的引入 2.2 进程的状态和组成 2.3 进程控制 2.4 进程的同步 2.5 经典进程同步问题 2.6 进程通信 2.7 线程的概念 2.8 进程管理 2.9 本章小结. 2.1 进程的引入. 2.1.1  程序的顺序执行及其特征 2.1.2  程序的并发执行及其特征 2.1.3  进程的定义及特征. 程序的顺序执行. 单道程序的运行顺序执行可以表示下图 - PowerPoint PPT Presentation

TRANSCRIPT

  • 2 Windows 2003

  • 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9

  • 2.1 2.1.12.1.22.1.3

  • CPUCPU

  • 2.2 2.2.12.2.2

  • RunningCPUCPUReadyCPUCPUBlocked/Waited

  • N

  • PCB PCB

  • PCBPCBPCB

  • PCBCPU

  • PCB

    PCBPCBPCBPCBPCBPCB

  • PCB

  • 2.3 2.3.12.3.22.3.3

  • PCBPCBPCBPCB

  • PCBPCBPCBPCB

  • 2.4 2.4.12.4.2PV2.4.3PV2.4.4PV

  • PVsqsqPCB struct semaphore { int value; pointer_PCB queue; }

  • PCB

  • PP(S){ S.value = S.value -1 ; if (S.value < 0) { PCBS.queue; }

  • VV(S){ S.value = S.value +1; if (S.value < = 0) { S.queue }}

  • PV mutex1 RCSPmutexVmutexsemaphore mutex=1Process i:main(){P(mutex);CS1;V(mutex);}

  • 2-1PAPBRPVPAPBR

  • mutex1

    PAPmutexRVmutexPBPmutexRVmutex

  • mutexmutex1mutex0mutex1

  • N

  • 2-1PVN

  • PV

  • 2-2P1P2P3

  • S2S3P1VS2VS3P2PS2P3PS3

  • 2-2

  • S1S2P1VS1P2VS2P3PS1PS2

  • 2-3

  • 5S2S3S4S5S60

  • 2-3CPIOP2-12

  • empty=1full=0emptyfull

  • CPWhile(1){PemptyVfullIOPWhile(1){PfullVempty

  • 2-4

  • empty1empty2full1full2empty1full1Buffer1empty1=1full10empty2full2Buffer2empty2=1full2=0

  • PAWhile(1){Pempty1Buffer1Vfull1

  • PBWhile(1){Pfull1Pempty2Buffer1Buffer2Vfull2Pempty1

  • PCWhile(1){Pfull2Buffer2Vempty2

  • empty1empty2full1full2empty1=1full10empty2=1full2=0PAWhile(1){Pempty1Buffer1Vfull1

    PBWhile(1){Pfull1Pempty2Buffer1Buffer2Vfull2Pempty1PCWhile(1){Pfull2Buffer2Vempty2

  • 2.5 2.5.12.5.22.5.3

  • P1P2PmQ1Q2Qnn

  • mutex1 emptyn full0 inout0

  • W1readcount0mutexreadcount1

  • S1

  • Philosopher[i]While(1){P(i)P((i+1) mod 5)EatV(i)V((i+1) mod 5)Think}

  • PhilosopheriWhile (1) {P (mutex)count ++if (count>=4)P(W)V (mutex)P (fork[i]) P(fork[(i+1) % 5])

    V (fork[i])V(fork[(i+1) % 5])P (mutex)count--if (count==3) V(W)V (mutex)}

  • 2.6 2.6.12.6.22.6.3

  • PV

  • pipe

  • 2.7 2.7.12.7.22.7.32.7.4

  • Windows 2000

  • 2.8 2.8.1Windows 20032.8.2 Windows 20032.8.3 Windows 20032.8.4 Windows 20032.8.5 Windows 2003

  • 1. ABCD2. ABCD3. ABCD

  • 4. A BCD5. ABCD6. ABCD

  • 7. ABCD8. ABCD9. PVABCD

  • 10. PVS21A0B1C2D311. ABCD12. VABCD

  • 13. ABCD14. ABCD

  • 15. ABCD16. ABCD