WHAT IS AN OPERATING SYSTEM? 1.2 HISTORY OF OPERATING SYSTEMS 1.3 THE OPERATING SYSTEM ZOO 1.4 COMPUTER HARDWARE REVIEW 1.5 OPERATING SYSTEM CONCEPTS 1.6 SYSTEM CALLS 1.7 OPERATING SYSTEM STRUCTURE 1.8 RESEARCH ON OPERATING SYSTEMS 1.9 OUTLINE OF THE REST OF THIS BOOK 1.10 METRIC UNITS 1.11 SUMMARY
Trang 112 OPERATING SYSTEM DESIGN
12.1 THE NATURE OF THE DESIGN PROBLEM
12.2 INTERFACE DESIGN
12.3 IMPLEMENTATION
12.4 PERFORMANCE
12.5 PROJECT MANAGEMENT
12.6 TRENDS IN OPERATING SYSTEM DESIGN
12.7 SUMMARY
Trang 2main( ) main( )
do3something( ); while (get3message(&msg)) {
do3something3else( ); case 1: ;
}
Fig 12-1 (a) Algorithmic code (b) Event-driven code.
Trang 3Interrupt handling, context switching, MMU
Hide the low-level hardware
Virtual memory
Threads, thread scheduling, thread synchronization
1
2
3
4
5
6
System call handler 7
Layer
Driver 2
Fig 12-2 One possible design for a modern layered operating sys-tem.
Trang 4Chap-12 Chap-11 Chap-10
External name: /usr/ast/books/mos2/Chap-12
Directory: /usr/ast/books/mos2 I-node table
1 2 3 4 5 6 7
2 38 114
Internal name: 2
Fig 12-3 Directories are used to map external names onto internal names.
Trang 5found = 0;
for (p = &proc3table[0]; p < &proc3table[PROC3TABLE3SIZE]; p++) {
if (p->proc3pid == pid) {
found = 1;
break;
}
}
Fig 12-4 Code for searching the process table for a given PID.
Trang 6#include "config.h" #include "config.h"
#if (CPU == PENTIUM) #endif
/*Pentium initialization here.*/
typedef long Register;
#if (CPU == ULTRASPARC) #endif
/*UltraSPARC initialization here.*/
}
Fig 12-5 (a) CPU-dependent conditional compilation (b) Word-length dependent conditional compilation.
Trang 7#define BYTE3SIZE 8 /* A byte contains 8 bits */
int bit3count(int byte)
int i, count = 0;
for (i = 0; i < BYTE3SIZE; i++) /*loop over the bits in a byte*/
if ((byte >> i) & 1) count++; /*if this bit is a 1, add to count*/
return(count); /*return sum*/
}
(a)
/*Macro to add up the bits in a byte and return the sum.*/
#define bit3count(b) (b&1) + ((b>>1)&1) + ((b>>2)&1) + ((b>>3)&1) + \
((b>>4)&1) + ((b>>5)&1) + ((b>>6)&1) + ((b>>7)&1)
(b)
/*Macro to look up the bit count in a table.*/
char bits[256] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, };
#define bit3count(b) (int) bits[b]
(c)
Fig 12-6 (a) A procedure for counting bits in a byte (b) A macro
to count the bits.
Trang 83,8,13 3,8,13
3,8,13 3,8,13
26,4,9 90,2,6
4,19,20 4,6,9
4,6,9 10,30,8 5,8,1 22,2,0
10,11,5 4,2,17 88,4,3 66,4,43
11 10
1
6 7 8
5
0
9
2 3 4
8 Bits
(a)
22,2,0 26,4,9
5,8,1
10,30,8 4,6,9 4,19,20 90,2,6 66,4,43
88,4,3
4,2,17 10,11,5 3,8,13
Fig 12-7 (a) Part of an uncompressed image with 24 bits per pixel (b) The same part compressed with GIF, with 8 bits per pixel (c) The color palette.
Trang 922222222222222222222222222222222222
22222222222222222222222222222222222
22222222222222222222222222222222222
22222222222222222222222222222222222
22222222222222222222222222222222222
22222222222222222222222222222222222
22222222222222222222222222222222222
Fig 12-8 Part of the i-node cache for Fig 6-39.
Trang 10Title Duties
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222
Chief programmer Performs the architectural design and writes the code
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222
Copilot Helps the chief programmer and serves as a sounding board
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222
Administrator Manages the people, budget, space, equipment, reporting, etc
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222
Editor Edits the documentation, which must be written by the chief programmer
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222
Secretaries The administrator and editor each need a secretary
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222
Program clerk Maintains the code and documentation archives
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222
Toolsmith Provides any tools the chief programmer needs
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222
Tester Tests the chief programmer’s code
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222
Language lawyer Part timer who can advise the chief programmer on the language
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222
Fig 12-9 Mills’ proposal for populating a 10-person chief
programmer team.
Trang 11Test modules
C
Code
Test system
(a)
Deploy
Dummy procedure 1
(b)
Plan
Dummy procedure 2
Dummy procedure 3
Main program
Fig 12-10 (a) Traditional software design progresses in stages (b) Alternative design produces a working system (that does
nothing) starting on day 1.