Tải bản đầy đủ (.pdf) (11 trang)

A computer system consists of hardware, system programs, and application programs figs 12

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (332.77 KB, 11 trang )

12
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
main( ) main( )
{{
int ; mess t msg;
init( ); init( );
do something( ); while (get message(&msg)) {
read( ); switch (msg.type) {
do something else( ); case 1: ;
write( ); case 2: ;
keep going( ); case 3: ;
exit(0); }
}}
}
(a) (b)
Fig. 12-1. (a) Algorithmic code. (b) Event-driven code.
Interrupt handling, context switching, MMU
Hide the low-level hardware
Virtual memory
Threads, thread scheduling, thread synchronization
1
2
3
4


5
Driver 1 Driver n

File system 1

File system m
6
System call handler
7
Layer
Driver 2
Fig. 12-2. One possible design for a modern layered operating sys-
tem.
Chap-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.
found = 0;
for (p = &proc table[0]; p < &proc table[PROC TABLE SIZE]; p++) {
if (p->proc pid == pid) {
found = 1;
break;
}
}
Fig. 12-4. Code for searching the process table for a given PID.
#include "config.h" #include "config.h"
init( ) #if (WORD LENGTH == 32)
{ typedef int Register;
#if (CPU == PENTIUM) #endif
/
*
Pentium initialization here.
*
/
#endif #if (WORD LENGTH == 64)
typedef long Register;
#if (CPU == ULTRASPARC) #endif
/
*
UltraSPARC initialization here.
*
/
#endif Register R0, R1, R2, R3;
(a) (b)
}

Fig. 12-5. (a) CPU-dependent conditional compilation. (b) Word-
length dependent conditional compilation.
#define BYTE SIZE 8 /* A byte contains 8 bits */
int bit count(int byte)
{/
*
Count the bits in a byte.
*
/
int i, count = 0;
for (i = 0; i < BYTE SIZE; 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 bit count(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 bit count(b) (int) bits[b]
(c)
Fig. 12-6. (a) A procedure for counting bits in a byte. (b) A macro
to count the bits.
3,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
7
7
77
26
34
4 5 10 0
89211
11
10

1
6
7
8
5
0
9
2
3
4
8 Bits
24 Bits
24 Bits
(b)
(c)
(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.
Path I-node number
/usr 6
/usr/ast 26
/usr/ast/mbox 60
/usr/ast/books 92
/usr/bal 45
/usr/bal/paper.ps 85
Fig. 12-8. Part of the i-node cache for Fig. 6-39.
Title Duties
Chief programmer Performs the architectural design and writes the code
Copilot Helps the chief programmer and serves as a sounding board
Administrator Manages the people, budget, space, equipment, reporting, etc.
Editor Edits the documentation, which must be written by the chief programmer
Secretaries The administrator and editor each need a secretary
Program clerk Maintains the code and documentation archives
Toolsmith Provides any tools the chief programmer needs
Tester Tests the chief programmer’s code
Language lawyer Part timer who can advise the chief programmer on the language
Fig. 12-9. Mills’ proposal for populating a 10-person chief
programmer team.
CC
Test
modules
CCode
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.

×