14
1 Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8 OPERATING SYSTEMS DESIGN AND IMPLEMENTATION Third Edition ANDREW S. TANENBAUM ALBERT S. WOODHULL Chapter 2 Processes (part 3) Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8 Message Passing (1) Figure 2-17. The producer-consumer problem with N messages. . . .

Chapter 2 Processes (part 3) - Laboratoire de Recherce en ...falcou/teaching/l3/Ch2-Part 3.pdf · 1 Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall,

  • Upload
    vancong

  • View
    217

  • Download
    2

Embed Size (px)

Citation preview

Page 1: Chapter 2 Processes (part 3) - Laboratoire de Recherce en ...falcou/teaching/l3/Ch2-Part 3.pdf · 1 Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall,

1

Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

OPERATING SYSTEMSDESIGN AND IMPLEMENTATION

Third EditionANDREW S. TANENBAUMALBERT S. WOODHULL

Chapter 2Processes

(part 3)

Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

Message Passing (1)

Figure 2-17. The producer-consumer problem with N messages.

. . .

Page 2: Chapter 2 Processes (part 3) - Laboratoire de Recherce en ...falcou/teaching/l3/Ch2-Part 3.pdf · 1 Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall,

2

Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

Message Passing (2)

Figure 2-17. The producer-consumer problem with N messages.

. . .

Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

The Dining Philosophers Problem (1)

Figure 2-18. Lunch time in the Philosophy Department.

Page 3: Chapter 2 Processes (part 3) - Laboratoire de Recherce en ...falcou/teaching/l3/Ch2-Part 3.pdf · 1 Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall,

3

Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

The Dining Philosophers Problem (2)

Figure 2-19. A nonsolution to the dining philosophers problem.

Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

The Dining Philosophers Problem (3)

Figure 2-20. A solution to the dining philosophers problem.

. . .

Page 4: Chapter 2 Processes (part 3) - Laboratoire de Recherce en ...falcou/teaching/l3/Ch2-Part 3.pdf · 1 Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall,

4

Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

The Dining Philosophers Problem (4)

Figure 2-20. A solution to the dining philosophers problem.

. . .

. . .

Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

The Dining Philosophers Problem (5)

Figure 2-20. A solution to the dining philosophers problem.

. . .

Page 5: Chapter 2 Processes (part 3) - Laboratoire de Recherce en ...falcou/teaching/l3/Ch2-Part 3.pdf · 1 Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall,

5

Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

The Readers and Writers Problem (1)

Figure 2-21. A solution to the readers and writers problem. . . .

Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

The Readers and Writers Problem (2)

Figure 2-21. A solution to the readers and writers problem.

. . .

Page 6: Chapter 2 Processes (part 3) - Laboratoire de Recherce en ...falcou/teaching/l3/Ch2-Part 3.pdf · 1 Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall,

6

Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

The Internal Structure of MINIX

Figure 2-29. MINIX 3 is structured in four layers.Only processes in the bottom layer may use

privileged (kernel mode) instructions.

Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

MINIX 3 Startup

Figure 2-30. Some important MINIX 3 system components.Others such as an Ethernet driver and

the inet server may also be present.

Page 7: Chapter 2 Processes (part 3) - Laboratoire de Recherce en ...falcou/teaching/l3/Ch2-Part 3.pdf · 1 Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall,

7

Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

MINIX Memory (1)

Figure 2-31. Memory layout after MINIX 3 has been loadedfrom the disk into memory. The kernel, servers, and

drivers are independently compiled and linked programs,listed on the left. Sizes are approximate and not to scale.

top half

Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

MINIX Memory (2)

Figure 2-31. Memory layout after MINIX 3 has been loadedfrom the disk into memory. The kernel, servers, and

drivers are independently compiled and linked programs,listed on the left. Sizes are approximate and not to scale.

Page 8: Chapter 2 Processes (part 3) - Laboratoire de Recherce en ...falcou/teaching/l3/Ch2-Part 3.pdf · 1 Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall,

8

Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

MINIX Header File

Figure 2-32. Part of a master header which ensures inclusion ofheader files needed by all C source files. Note that two const.h

files, one from the include/ tree and one from the localdirectory, are referenced.

Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

Sizes of Types in MINIX

Figure 2-33. The size, in bits, of some types on16-bit and 32-bit systems.

Page 9: Chapter 2 Processes (part 3) - Laboratoire de Recherce en ...falcou/teaching/l3/Ch2-Part 3.pdf · 1 Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall,

9

Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

MINIX Message Types

Figure 2-34. The sevenmessage types used inMINIX 3. The sizes ofmessage elements willvary, depending upon thearchitecture of themachine; this diagramillustrates sizes on CPUswith 32-bit pointers, suchas those of Pentium familymembers.

Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

Bootstrapping MINIX (1)

Figure 2-36. Disk structures used for bootstrapping.(a) Unpartitioned disk. The first sector is the bootblock.

Page 10: Chapter 2 Processes (part 3) - Laboratoire de Recherce en ...falcou/teaching/l3/Ch2-Part 3.pdf · 1 Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall,

10

Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

Bootstrapping MINIX (2)

Figure 2-36. Disk structures used for bootstrapping.(b) Partitioned disk. The first sector is the master

boot record, also called masterboot.

Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

Boot Time in MINIX

Figure 2-37. Boot parameters passed to the kernel at boot time ina typical MINIX 3 system.

Page 11: Chapter 2 Processes (part 3) - Laboratoire de Recherce en ...falcou/teaching/l3/Ch2-Part 3.pdf · 1 Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall,

11

Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

System Initialization in MINIX

Figure 2-38. How alternative assembly languagesource files are selected.

Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

Interrupt Handling in MINIX (1)

Figure 2-39. Interrupt processing hardware on a 32-bit Intel PC.

Page 12: Chapter 2 Processes (part 3) - Laboratoire de Recherce en ...falcou/teaching/l3/Ch2-Part 3.pdf · 1 Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall,

12

Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

Interrupt Handling in MINIX (2)

Figure 2-40. (a) How a hardware interrupt is processed.

Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

Interrupt Handling in MINIX (3)

Figure 2-40. (b) How a system call is made.

Page 13: Chapter 2 Processes (part 3) - Laboratoire de Recherce en ...falcou/teaching/l3/Ch2-Part 3.pdf · 1 Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall,

13

Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

Restart

Figure 2-41. Restart is the common point reached after systemstartup, interrupts, or system calls. The most deserving process(which may be and often is a different process from the last oneinterrupted) runs next. Not shown in this diagram areinterrupts that occur while the kernel itself is running.

Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

Queueing

Figure 2-42. Queueing of processes trying to send to process 0.

Page 14: Chapter 2 Processes (part 3) - Laboratoire de Recherce en ...falcou/teaching/l3/Ch2-Part 3.pdf · 1 Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall,

14

Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

Scheduling in MINIX

Figure 2-43. The scheduler maintains sixteen queues, one perpriority level. Shown here is the initial queuing process as

MINIX 3 starts up.