Upload
vancong
View
217
Download
2
Embed Size (px)
Citation preview
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.
. . .
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.
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.
. . .
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.
. . .
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.
. . .
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.
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.
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.
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.
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.
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.
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.
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.
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.