© 2010 pearson addison-wesley. all rights reserved. addison wesley is an imprint of chapter 15:...

22
© 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 15: Multiprocessing Using Processes and Threads Problem Solving & Program Design in C Sixth Edition By Jeri R. Hanly & Elliot B. Koffman

Upload: zachary-sade

Post on 01-Apr-2015

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: © 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 15: Multiprocessing Using Processes and Threads Problem Solving

© 2010 Pearson Addison-Wesley. All rights reserved.

Addison Wesley is an imprint of

Chapter 15:Multiprocessing Using Processes and Threads

Problem Solving & Program Design in C

Sixth Edition

By Jeri R. Hanly &

Elliot B. Koffman

Page 2: © 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 15: Multiprocessing Using Processes and Threads Problem Solving

1-2

1-2

© 2010 Pearson Addison-Wesley. All rights reserved.

Figure 15.1 Three Modes of Processing

Page 3: © 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 15: Multiprocessing Using Processes and Threads Problem Solving

1-3

1-3

© 2010 Pearson Addison-Wesley. All rights reserved.

Figure 15.2 Preemptive Multitasking

Page 4: © 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 15: Multiprocessing Using Processes and Threads Problem Solving

1-4

1-4

© 2010 Pearson Addison-Wesley. All rights reserved.

Figure 15.3 Context Switching from P1 to P2 to P1

Page 5: © 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 15: Multiprocessing Using Processes and Threads Problem Solving

1-5

1-5

© 2010 Pearson Addison-Wesley. All rights reserved.

Figure 15.4 Interprocess Communications Using Half-duplex Pipes

Page 6: © 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 15: Multiprocessing Using Processes and Threads Problem Solving

1-6

1-6

© 2010 Pearson Addison-Wesley. All rights reserved.

Figure 15.5 Program to Launch Another Program (parent.c)

continued

Page 7: © 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 15: Multiprocessing Using Processes and Threads Problem Solving

1-7

1-7

© 2010 Pearson Addison-Wesley. All rights reserved.

Figure 15.5 Program to Launch Another Program (parent.c) (cont’d)

continued

Page 8: © 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 15: Multiprocessing Using Processes and Threads Problem Solving

1-8

1-8

© 2010 Pearson Addison-Wesley. All rights reserved.

Figure 15.5 Program to Launch Another Program (parent.c) (cont’d)

Page 9: © 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 15: Multiprocessing Using Processes and Threads Problem Solving

1-9

1-9

© 2010 Pearson Addison-Wesley. All rights reserved.

Figure 15.6 Program to Be Launched from the Program in Figure 15.5 (child.c)

Page 10: © 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 15: Multiprocessing Using Processes and Threads Problem Solving

1-10

1-10

© 2010 Pearson Addison-Wesley. All rights reserved.

Figure 15.7 Memory Resources for a Process with Three Threads

Page 11: © 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 15: Multiprocessing Using Processes and Threads Problem Solving

1-11

1-11

© 2010 Pearson Addison-Wesley. All rights reserved.

Figure 15.8 Program That Creates a Thread and Updates a Shared Resource (thread.c)

continued

Page 12: © 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 15: Multiprocessing Using Processes and Threads Problem Solving

1-12

1-12

© 2010 Pearson Addison-Wesley. All rights reserved.

Figure 15.8 Program That Creates a Thread and Updates a Shared Resource (thread.c) (cont’d)

continued

Page 13: © 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 15: Multiprocessing Using Processes and Threads Problem Solving

1-13

1-13

© 2010 Pearson Addison-Wesley. All rights reserved.

Figure 15.8 Program That Creates a Thread and Updates a Shared Resource (thread.c) (cont’d)

Page 14: © 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 15: Multiprocessing Using Processes and Threads Problem Solving

1-14

1-14

© 2010 Pearson Addison-Wesley. All rights reserved.

Figure 15.9 Program for Modeling the Delivery and Dispensing of Gasoline (caseused.c)

continued

Page 15: © 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 15: Multiprocessing Using Processes and Threads Problem Solving

1-15

1-15

© 2010 Pearson Addison-Wesley. All rights reserved.

Figure 15.9 Program for Modeling the Delivery and Dispensing of Gasoline (casuesed.c) (cont’d)

continued

Page 16: © 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 15: Multiprocessing Using Processes and Threads Problem Solving

1-16

1-16

© 2010 Pearson Addison-Wesley. All rights reserved.

Figure 15.9 Program for Modeling the Delivery and Dispensing of Gasoline (casuesed.c) (cont’d)

continued

Page 17: © 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 15: Multiprocessing Using Processes and Threads Problem Solving

1-17

1-17

© 2010 Pearson Addison-Wesley. All rights reserved.

Figure 15.9 Program for Modeling the Delivery and Dispensing of Gasoline (casuesed.c) (cont’d)

continued

Page 18: © 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 15: Multiprocessing Using Processes and Threads Problem Solving

1-18

1-18

© 2010 Pearson Addison-Wesley. All rights reserved.

Figure 15.9 Program for Modeling the Delivery and Dispensing of Gasoline (casuesed.c) (cont’d)

continued

Page 19: © 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 15: Multiprocessing Using Processes and Threads Problem Solving

1-19

1-19

© 2010 Pearson Addison-Wesley. All rights reserved.

Figure 15.9 Program for Modeling the Delivery and Dispensing of Gasoline (casuesed.c) (cont’d)

continued

Page 20: © 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 15: Multiprocessing Using Processes and Threads Problem Solving

1-20

1-20

© 2010 Pearson Addison-Wesley. All rights reserved.

Figure 15.9 Program for Modeling the Delivery and Dispensing of Gasoline (casuesed.c) (cont’d)

continued

Page 21: © 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 15: Multiprocessing Using Processes and Threads Problem Solving

1-21

1-21

© 2010 Pearson Addison-Wesley. All rights reserved.

Figure 15.9 Program for Modeling the Delivery and Dispensing of Gasoline (casuesed.c) (cont’d)

continued

Page 22: © 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 15: Multiprocessing Using Processes and Threads Problem Solving

1-22

1-22

© 2010 Pearson Addison-Wesley. All rights reserved.

Figure 15.9 Program for Modeling the Delivery and Dispensing of Gasoline (casuesed.c) (cont’d)