You are on page 1of 10

w

terM iFWf,wfzr=rri';;;',t ;:; rug . r tIt/iiliA'lgb,;; ,.;, '5+1:,9am taP 5$,;.,.#+'0 it:. gr:ffi t's,nnd 1liC t,mx iffl!rr.
The Magic Garden
Explained
The Internals of
UNIXIAI System V Release 4
An Open Systems Design
The autbor. and ..."d II"';r 1".,.1 dr"rls ill ""'parinS Ihi. Th... iud",l.
tbe r_ch. IUld testing of tbe tbeori"". "Igmilh",. and programs 10 determine Iheir
Tbe alltbon and publisber make 110 warranty of any kilHI. expreueJ or implied. wilb rega,,1 10 Ibe
documeatation contained in tbis book. The authon ,,"<1 ,,"Miaber .1",11 not be made lilll.l, in "fly
event for incidental or consequenlial dalUlIg"" in conn",:I;on witb, or ",i.ing out of, the furni.bin"
perioJ'lJlance, or use of thi. documentation.
Thi. book conl"ins cOI'yright<"<i material of Novell. IlIc., which i. being reprodu", .. 1 wilb
penniuion. The aut hoi'll th.... k Novell. Inc. for Kiv;ng II.elll permi ion 10 woe this m"leri,,1.
The authors wish 10 sl"te tbat Ihi. b<.ok i. pr... " .. I",1 with inll'!Dtioo of di""mi"alillg
knowledge to prof..sionals and ..,.....lemi(:II who .. " interest in lloi. aubj<'Ct. 11 r<'("....'"t.
neilher the view. nor lhe commercial inl.,r ..l. of Ihe or"' .. ";.... tion in wbi,:b they .... e employed.
BSD a trademark of Univenily of California. Berkdey
DEC i. Ii registered trademark of Digilal Equipme.nt Coq",r"lion.
MIPS i. a registered Irademark or MIPS Te<:hnologi ..... Inc.
NeWS a MfIIi-ialecf'!{1 tra.deuuuk of Sun Mi.'roLlloyat"..tn8. Inc
Openlook i. a trademark of UNIX Syolem I,,,b<,,atori,,,,, h .. .
SunOl i. a rer;i,tered trademark of Sun MiCl'Olly8lems. Inc.
UniFo_ i. a trademark of linirorum.
UNIX'ia a re,iotered Ir&demark licensed exclusively by X/Open Co., Ltd.
X Windo'!' is". registered Irademark of the M ..."",:busettslnstitule of Technology.
XENIX".t.nd MSDOS are registered Irademarks of Microsoft. Inc.
The Magic Garden
Explained
The Internals of
System V Release 4
An Open Systems Design
Berny Goodheart
'l'u1Iflem I)ly
Sydll('Y, A
James Cox
Tandem U(l.
Slod.:lcy Pat"..:, Unil( d l\'illgdo1ll
[3IBLlO I Fe)..
II
,... ... , .., .. "".....
4 f """"
1::-. ..



i\. . "{ .'
'i :::::\.. ,,-:..-....
PRENTICE HAll
ae C'E(I<.,.'8$,
New York london Toronto Sydney Tokyo Singapore
@ 1994 by Prentice lIall of AUKtmlia Pt.y Ltd
All rights reserved. No parI. of publicat.io" "'''y he reproduced,
stored in a retrieval syst.em, or t.ra"slJIiUe,1 ill allY form or hy a"y
means, electronic, mechanical, pholocopyi"!',, or otherwise,
without the wriUen permission of t.he puhlist,,r.
Acquisitions Editor: Andn'w Bi""ie
Production Editor: Fiona Marcar
Cover design: The Modern Art Production Group, Prahran, VIC; from an
original painting "The Magic Garde,," by James H. Evans.
Printed in Australia by Star Printery Ply Limited
3 4 5 98 97 96 95 94
ISBN 0130981389
National Library of Australia
Cataloguing-in-Publication Data
Goodheart, Berny
The magic garden explained: til(' i"lnnals of UNIX SYRtem V Relea. ... ' 1.
Bibliography.
Includes index.
ISBN 0 13 098138 9.
1. UNIX (Computer file). I. Cox, Jalll.'8 .11. Titte.
005.43
Li brary of Congress
Cataloging-in-Publicatioll Data
Goodheart, Ilerny
The magic garden explained: the internals of UNIX Syst.em V
Release 4, an open-systems design / Berny (;oodheart &. James Cox.
p. cm.
Includ!.'S bihliographicaJ references and index.
ISBN 0-13-098138-9
1. Operating systems (Computers) 2. UNIX Syst.em V (Computer file)
I. Cox, James .II. Title.
QA76.76.063G6633 1993 93-23385
005.(,3--dc20 CIP
Prentice HaJl, Inc., Englewood eli/b, New lent'y
Prentice HaJl Canada, Inc., Toronto
Prentice HaJl Hispanoamericana, S.A., Merico
Prentice JlaJl of India Privat.e Ltd, Nelli lJd"i
Prentice lIall Internat.ional, Inc., Lont/"n
Prentice JlaJl of Japan, Inc., Tokyo
Prentice HaJl of Sout.heast Asia Pty Ltd, Sin9np",."
Editora Prentice Hall do Brasil Ltda, Ilio .It' }'III,iro
it
PRENTICE HALL
A division of Simon &. Schust.er
MAGIC
One might wonder what The MAGIC GRr\PII has in common wilh
UNIX. Have the aUlhors lost their minds'!
magi.: 1: an n:/roaor'dinary potl'rr' 01' znJlurnrr .,rrmlJlgly Jrom a
supernalural sourl'f. 2: any natural llOlIIcr or art ser7llzng to hllve
miraculous result.,. 3: control oJ natural Jorcrs by the dIrect arilOn oJ
objerts, materials, or word. con. idard "uper1lalurally potent. 4: the
eliXIr oJ liJe.
garden 1: an oprn rnvironment Jurnlshed with tables and chaIrs and
serving reJrcshmfflt., - See fJEEIl. 2: a rich wdl-culllvaled regIOn.
3: vandy oJ cat thlll is technically kno1l'n 10 Jancier...
UNIX is magical since, like a garden, it keeps growing and sprouting new
hybrids each spring if nothing but nature itself can destroy it.
Note from tAt author.: Yr . , wt have lod our Hr Jortwarnrd: you willlO!f your. (00,
"u t ~ e ",mpm "W . one;
FOREWORD
John R. Masbey
Just over twenty years ago (1973), I started work at Bell Lahoratories, arriving in the
Programmer's Workbench department the same week as our new Digital PDP
11/45. This magnificent 24R-Kbyte minicomputer ran an early version of the UNIX
operating system, and although it often strained a oit under the load of 16 (and later
24) users, it was still a fine eKperience. We had MKB of code, and tAKB of data per
program, and access to a variety of 3OO-oaud printing terminals. Of course, this
"UNIX machine" was often viewed askance hy Digital's Customer Engineers, as well
as by some of our mainframe-oriented compatriots, who often douhted the use of
smaller computers, especially ones with oddly-named operating systems.
In those years, there existed but a few dozen of UNIX systems, and a " r c l e a ~ e "
was accomplished by driving up to Murray Hill, NJ, logging onto the "research"
machine, and making a tape of anything new that looked interesting. Since
documentation consisted of the Manual and a fcw short memoranda, learning most
often depended on reading code, which fortunately was elegant, short, and
accessihle.
In those twenty years, many things have chimged. For example, this Foreword is
being written on a Silicon Graphics workstation more than 100X faster than that
POP-Il/45, with 64MB of memory, and [ don't even have to share it with anyone.
Still, much of its code is still written in C, and it certainly runs a version of the
UNIX system.
At least one more thing has not changed. There has long been a somewhat
mysterious connection between the UNIX system and the folks Down Under. For
whatever reason, there were often Australian computer scientists around Bell Lahs,
or doing interesting things with the UNIX system very far away. A bit later came
John Lions' wonderful booklets explaining the innards of the UNIX system.
"The Magic Garden EKplained" carries on that fine tradition in at least two
ways. First, at least one of the authors is Auslralian. Second, it provides a detailed
and comprehensive look al the innards of an important and popular version of the
UNIX system, in this case UNIX System V Release 4.
Of course, current UNIX systems are far more complex than in the early days,
and it takes a greal deal more time and effort In make the innards understandahk.
vii
-
' twwn "tPm=P'fWar 'ri'wr,.,iSilIWatr'fM tatun fj rs ?run T
viii The Magic. Garden Explained
1 enjoyed reading this book. and even afler Iwenly years, I still learned plenty from
it. You will, too.
John R. Mashey
Silicon Graphics
Mountain View, CA
November 1993
; mum_I
CONTEN1S
;....
.....
Foreword vii
Contents ix
Preface ro
Acknowledgments XXVII
Part 1 Overview
Chapter 1 BACKGROUND AND HISTORY 3
1.1 Genealogical history of UNIX 3
1.1.1 Before UNIX 3
1.1.2 The Epoch 3
1.1.3 First edition 5
1.1.4 Research UNIX 5
1.1.5 The first port of UNIX 6
1.1.6 Seventh Edition X
1.1.7 Berkeley UNIX (BSO) 9
1.1.8 AT&T UNIX System III & Microsoft XENIX 9
1.1.9 AT&T UNIX System V 10
1.1.10 AT&T UNIX System V Release 2 10
1.1.11 AT&T UNIX System V Release 3 11
1.2 Politics and the battle for standards 12
1.2.1 The user's dilemma 12
1.2.2 SVID 12
1.2.3 POSIX 13
1.2.4 X/Open
13
1.3 AT&T UNIX System V Release 4 15
1.3.1 UNIX International 15
1.3.2 Univel UnixWare IX
1.3.3 Novell UNIX System V Release 4 18
1.3.4 Summary
19
Chapter 2 CONCEPTS AND FACILITIES
20
2.1 Introduction
20
2.2 Philosophy
20
2.2.1 The user interface
21
ix
, ,.4.
<",.,..J;' j"ena_rmct. nnt Vrhht"ri
x The Magic Garden Explained
2.2.2 The user's credentials
2.2.3 The privileged user
2.2.4 User programs and commands
2.3 The UNIX kernel
2.3.1 Kernel software organintlion
2.3.2 Kernel source code organi74tion
2.4 The UNIX file system
2.4.1 File system structure
2.4.2 Mountable file systems
2.4.3 Storage devices for file systems
2.4.4 File system interface
2.4.5 File system types
2.5 Files
2.5.1 Regular files
2.5.2 Directories
2.5.3 Special files
2.5.4 Links
2.5.5 Symbolic links
2.5.6 Named pipes
2.5.7 Memory mapped files
2.5.8 File removal
2.5.9 File names
2.6 Descriptor management
2.6.1 File and record locking
2.7 I/O redirection
2.8 Resource limitations
2.9 Quotas
2.10 Security
2.10.1 Process execution rights
2.10.2 File protection
2.11 Devices
2.11.1 Device drivers
2.11.2 User process interface
2.12 System initiali:r.ation
2.13 Networking & communication snvices
2.13.1
2.13.2
2.13.3
2.13.4
2.13.5
2.13.6
2.13.7
2.13.8
"m {rWfR!t'I Tcrn'n}lz
STREAMS
TCP/IP
Transport level interface (TU)
Remote procedure call (RPC)
External data representation (XDR)
Sockets
STREAMS-based pipes
UlJCP
2.14 File sharing
2.14.1 Networked file system (NFS)
2.14.2 Remote file sharing (RF'S)
'WZ
2.15
22
22
2.16
23
2.17
24
25
26
27
Part 2
29
Chapter 3
30
3.1
31
CONTENTS XI
u'ser access
2.15.1 Service acces.'I facility (SAf')
Extended Fundamental Types (EFT)
Exercises
113
6}
M
65
UNIX Internals 67
MEMORY MANAGEMENT SUBSYSTEM 69
Introduction to the memory suhsystem 69
3.1.1 Virtual memory 69
:'1
3.1.2 Structure of a page 71
33
3.1.3 Associative memory cache 71
J4
3.2 Demand paging 74
35
3.2.1 Page stealing 76
35
3.3 Segmentation and regions 78
36
3.4 The hardware independent layer HO
37
38
38
39
39
39
40
41
42
44
45
3.4.1
3.4.2
3.4.3
3.4.4
3.4.5
3.4.6
3.4.7
3.4.8
3.4.9
3.4.10
Structure of physical memory 80
Initializing the page system 81
The page structure 83
Page list management H4
vnode pages 85
Anonymous pages 85
The structure H()
The $('g structure &l
The ""-'p'n data structure H7
The anon structure I<l'
3.5 Paging system procedures
45
3.6 Hardware dependent layer
45
4(i
3.6.1 Segment operations
3.6.2 HAT layer data structures
47
3.6.3 HAT layer support functions
47
3.7 Demand paging
47
3.7.1 Exception handling
48
3.7.2 Low-level routines
51
3.7.3 The paql'/ault() function
51
3.7.4 The utlbmis., function
53
3.7.5 Page fault examples
56
3.8 Page out and swapping
57
3.8.1 Page stealing variables
57
3.8.2 The page out process
58
3.8.3 The swapper process
59
3.8.4 Swap space management
59
3.9 Nonpaged memory allocation
60
3.9.1 Memory allocation strategies
62
3.9.2 kmem_aUoe() and k:m emJr't" e( )
63

H9
92
93
96
102
105
105
106

1117
108
110
111
112
115
117
119
121
122
,--;;:;;;;1;;:;:-;;;;0
xii The Magic Garden Explained
3.10
3.11
Chapter 4
4.1
4.2
4.3
4.4
4.5
4.6
3.9.3 and
3.9.4 rmalloc{ ) and rmfru{)
Memory related system calls
3.10.1 Stack growth, brk and
3.10.2 memcntl and plock
3.10.3 mprotut and mlflcorc
Exercises
PROCESS MANAGEMENT SUBSYSTEM
Introduction to the proces.... management subsystem
4.1.1 Concurrency
4.1.2 Flow or execution
The process image
4.2.1
4.2.2
4.2.3
4.2.4
4.2.5
4.2.6
4.2.7
Format or an executahle on disk
Proces.... memory model
Context or a process
The 11.,er-arra
Process imilge in ItS,,!, address space
Process image in 811-'/('111 address space
Processor registers
The structure or a proces..'i
4.3.1 The user structure
4.3.2 The proc structure
Process states
4.4.1 Functional state
4.4.2 Execution state
Context switching
Process scheduling
4.6.1
4.6.2
4.6.3
4.6.4
4.6.5
4.6.6
4.6.7
4.6.8
4.6.9
4.6.10
4.6.11
4.6.12
4.6.13
4.6.14
4.6.15
4.6.16
4.6.17
Priority classes
Process time-slice
Priority cia...", independent variahles
Priority dispatch
Priority class independent runctions
Priority class groups
Priority cia...", dispatch parameter tahles
System-class
Real-time class
Time-shared class
Class dependent interrace
Clas..'i dependent runctions
Sleeping processes
Algorithm slcep{ )
Stopped processes
Algorithm lI'akpproc._{)
Algorithm setrun()
User-level context switching
127
128
129
132
134
138
139
141
141
142
142
141
143
145
145
146
146
147
150
153
153
154
155
155
157
159
160
160
161
161
162
16.'\
166
168
169
169
171
174
175
180
183
188
]88
]90
191
CONTENTS xiii
I'll
1'}2
195
I\)6
197
199
200
200
201
202
204
206
4.11 User, process, process group and session rclalionshills 241
4.11.1 Parents, children and sihlings 241
4.11.2 Process identification (PID) 243
4.11.3 Process groups and joh control 245
4.11.4 Sessions 248
4.11.5 Process credentials 249
4.12 Process creation
252
4.12.1 Algorithm forkl() 253
4.12.2 Algorithm newproc{ ) 253
4.13 Program execution 258
4.13.1 Algorithm er.ece{ ) 259
4.13.2 Program flow or execution 261
4.13.3 Dumping core 262
4.8 The ...ystem dock
4.IU
4.8.2
4.8.3
4.8.4
4.8.5
4.8.6
4.8.7
4.8.8
4.8.9
4.9.1
4.9.2
4.9.3
4.9.4
4.9.5
4.9.6
4.9.7
4.9.8
4.9.9
4.10 Signals
4.10.1
4.10.2
4.10.3
4.10.4
4.10.5
4.10.6
4.10.7
4.10.8
4.10.9
4.10.10
Clock interrupt service roul ine
Priming the clock
Callout tables
Alarm calls
Process execution-time statistics
System-wide statistics
System-wide process accounting
Enrorcing CPU resource limits
Profiling
4.8.10 Keeping time
4.8.11 High resolution interval timers
4.9 Process execution modes
Transrerring to kernf'irrlOde
Interrupt, trap and exception handling
Saving and restoring the environment
System call traps
The ,'y"enf(} tahle
Exception traps
Interrupts
Returning to 11.,rr-ffiOilc in )
longpnp{) and setjmp{)
Signal posting
Algorithm sigtoproc{ )
Handling signals
System calls ror signals
Algorithm sSlg{ )
Getting signal information
Execution errors and signals
Signal procc.';sing
Algorithm plilg( )
System calls ror posting si!!:nals
209
210
212
213
214
21.')
216
210
21H
22()
221
221
225
225
226
2:13
233
235
236
238
24(J
4.7
.... " ,_I
~
xiv The Magic Garden Explained
4.13.4 Algorithm ('UH( )
4.14 Shared libraries
4.14.1 Statically-linked-libraries
4.14.2 Statically-linkedsharedlihraries
4.14.3 Dynamically-linkcd-shared-libraries
4.15 Process termination
4.15.1 Transition phases of process termination
4.15.2 Algorithm eXlt(}
4.15.3 Waiting for a process
4.15.4 Algorithm !l!aitld()
4.15.5 Algorithm /,wp,'oc( )
4.]6 Process suspension
4.17 System operation
4.17.1 System initialization
4.17.2 System shutdown and rehoot
4.18 Exercises
Chapter 5 1/0 SUBSYSTEM
5.1 Introduction
5.2 The new buffer cache
5.2.1 Overview of the new buffer cache
5.2.2 New buffer cache data structures
5.2.3 Functions in the new buffer cache
5.3 The old buffer cache
5.3.1 Overview of .he old huffer cache
5.3.2 Old buffer cache data structures
5.3.3 Buffer allocation and freeing
5.3.4 Buffer mapping: Imlllfl( ) operations
5.3.5 Reading and writing buffers
5.4 File I/O support functions
5.4.1 Page 1/0 low level functions
5.5 Read and write file 1/0
5.5.1 Data structures for read and write
5.5.2 The "I'ad and 1111'Itl' system calls
5.5.3 The ,'cadv and 1m'itl'tI system calls
5.6 Device driver!'>
5.6.1 Special files
5.6.2 Driver runctions
5.6.3 Device driver data structures
5.6.4 Device driver ol,cn function
5.6.5 Device driver dose runction
5.6.6 Device driver interrupt service routine
5.7 Block device drivers
5.7.1 Device driver ,\tmtrgy function
5.7.2 Block device r, lid and lII,',If' functions
5.7.3 Raw disk 1/0
262
263
263
2f14
264
265
265
Ui6
Ui9
270
271
273
273
273
277
279
282
282
283
283
285
285
2M
2M
288
290
291
]!}2
292
293
296
296
297
298
2 ~
300
301
301
304
306
306
307
308
30'J
309
. ~ .
5.8
5.9
5.10
5.11
5.12
Chapter 6
6.1
6.2
0.3
6.4
6.5
6.6
6.7
6.8
6.9
CONTENTS
5.7.4
The II/ty,m)ck( ) function
Character device drivers
Character device read and write functions
5.8.1
Device driver ioctl function
5.8.2
Character device pall function
The mmap system call
5.8.3
Block device and regular file mmap
5.9.1
5.9.2
Character device rnmap function
Example character driver: mm
The Device Driver Interface and Driver Kerncllnterface
5.11.1 DDI/DKI section 2
5.11.2 DD1/DKI section 3
5.11.3 DDl/DKI section 4
Exercises
FilE MANAGEMENT SUBSYSTEM
Introduction to the file management subsystem
Associating with a file
6.2.1
The process open file table
6.2.2
The system open file table
6.2.3
File allocation operations
6.2.4
File descriptor allocation
File descriptors inherited from the parent
6.2.5
6.2.6
The opcn and ('Hal system calls
The file system independent lmod,
6.3.1
Allocating a lmode
6.3.2 vnadr operations
File system type dependent llnolleop," functions
6.3.3
File and record locking
6.4.1
Advisory locking
File and record locking in the lmode
6.4.2
6.4.3
Mandatory locking
Lock resource and accounting
The virtual file system
Virtual file system switch table (VFSSW)
6.4.4
6.5.1
File system type dependent VFS operations
6.5.2
The UNIX file system hierarchy
6.6.1
Mountable file systems
The system's VFS mount list
6.6.2
The llnodes association with the 1 1 f ~ structure
6.6.3
The mount and umollnt system calls
0.6.4
The directory name lookUp cache
Pathname resolution
The pathname data structure
6.8.1
Pathname resolving functions
The special file system (specM
6.8.2
xv
:m
313
313
313
3Hi
319
122
321
325
327
329 .,
330 l
,f'i
333
\
333
335
335
336
336
337
340
341
342
144
,145
346
346
348
357
358
358
359
360
3(..0
3(12
363
3(,9
370
373
376
376
37R
3Rl
3Rt
3R1
3R4
,. ."vBi' ;. ,. ',ev 76d tt'lfiWhflllf ':I ".ii',.,j;Wije!ij[ei' ffffW'p gib ;=rrmN'# ft\'iF'f f'U & 5' tsOrt . 'io "$5 m' . t riswf'itiiiF: rttf'eW dT emf'
xvi The Magic: Carden Explained CONTENTS xvii
6.10
6.9.1 The shadow-special-vIlode ('node)
6.9.2 The fifo file system (NuN
Concept of the mode
6.10.1 Layout of the file and illndl' on disk
385
3AA
388
390
7.8 STREAMS 5cheduling and now-control impiementatiull
7.8.1 Flow-control variables
7.8.2 Flow-control procedures
7.8.3 The STREAMS scheduler
464
4<14

4(18
6.11 The /proc file system (proffs) 392
7.9 Operation of the stream head 4(l9
6.11.1 /proc implementation 393
7.9.1 Stream head data structures 4(,9
6.12 Exercises 39H
7.9.2 Limiting STREAMS memory 472
7.9.3 Opening a stream 473
Part 3 Additional Facilities 401
7.9.4
7.9.5
OpeIling a clone device
Writing to a stream
474
476
7.9.6 Reading from a stream 477
Chapter 7 STREAMS 403
7.9.7 Stream well 4l{2
7.1 Introduction 403
7.9.8 and gcllllsg 4S7
7.2 STREAMS data structures 409
7.9.9 Polling a stream 4l{9
7.2.1
7.2.2
STREAMS messages
STREAMS /fUCliC structures
409
412
7.9.10
7.').11
The .)/I'illfn array
qalllll'li() and qdctllcli()
4q]
497
7.2.3 The modulc structures 4111
7.10 STREAMS-bascd pipes and F1FOs 497
7.2.4 Initiali:t,ation of module data structures 41H
7.10.1 FIFO operations 4')H
7.3 STREAMS modules 41H
7.10.2 Pipe operatiolls 500
7.3.1 Open procedures 420
7.11 STREAMS terminals S02
7.3.2 Put procedures 421
7.1U Using I.llerm 503
7.3.3 Service procedures. 422
7.11.2 Job control 505
7.3.4 Message processing 423
7.11.3 The struccess( ) function 508
7.3.5 Processing iocti 424
7.12 Implementation of Id/crlll 50S
7.3.6 Flush handling 430
7.12.1 Data structures in Idlerm 508
7.3.7 Close procedures 432
7.12.2 Idler1/! read side 509
7.4 STREAMS drivers 433
7.12.3 Idlei'm write side 511
7.4.1
7.4.2
7.4.3
Configuration and linking
Driver open
Driver close
434
434
436
7.12.4
7.12.5
7.12.6
idterl/! ioell
Character input
Special character I/O
511
511
513
7.4.4 Driver input
7.4.5 Driver output
73 Multiplexors
7.5.1 Building the mUltiplexor
7.5.2 Multiplexor data structures
7.5.3 Multiplexor open
7.5.4 Multiplexor write side
7.5.5 Multiplexor read side
7.5.6 Multiplexor close
7.6 STREAMS utility functions
7.6.1 STREAMS memory allocation functions
437
431{
441
442
444
447
447
452
453
454
4511
7.13
7.14
7.15
7.16
7.12.7 Flow-control
7.12.8 VMIN & VTIME input
Other terminal issues
7.13.1 Pseudo terminals
7.13.2 Intelligent controllers
STREAMS networking support
7.14.1 Transport service interface
7.14.2 Socket interface
7.14.3 Transport layer interface
STREAMS module configuration
Exercises
513
514
Sill
5111
51H
519
S19
521
523
526
526
7.6.2
7.6.3
Queue manipulation functions
Flow-control functions
459
460
Chapter 8 INTERPROCESS COMMUNICATION 528
7.7 STREAMS memory management
7.7.1 allocb() and cshalloc()
7.7.2 Comparison of old and new allocation schemes
461
461
462
8.1
8.2
Introduction to interproccss communication
8.1.1 IPC operation permissions
Semaphores
528
529
510
l
;r;, . MiMi i
1
f'n'if$S'M'tt
W
wftWiHMW't*t ri
xviii The Magic Garden Explained
8.2.1 Semaphore initialization and control
8.2.2 Using semaphores
8.3 The implementation of semaphores
8.3.1 Semaphore support functions
8.3.2 Semaphore initialization
8.3.3 Semaphore allocation
8.3.4 Semaphore operations
8.3.5 Semaphore undo
8.4 Message queues
8.4.1 Message initialization and control
8.4.2 Using messages
8.5 The implementation of message queues
8.5.1 Message initializat ion
8.5.2 Message allocat ion
8.5.3 Message operations
8.6 Shared memory
8.6.1 Shared memory data structures
8.6.2 Using shared memory
8.7 The implementation of shared memory
8.7.1 Initialization and control of shared memory
8.7.2 Attaching shared mcmory
8.7.3 Detaching shared memory
8.8 Exercises
Chapter 9 CRASH
9.1 Introduction to crash
9.2 Gctting started
9.3 Symbols
9.4 Processes
9.4.1 The proc command
9.4.2 Hints for the proc command
9.4.3 The u command
9.4.4 Hints for the u command
9.4.5 The as command
9.5 Kernel stack
9.5.1 C Language stack
9.5.2 The kernel stack layout
9.5.3 Kernel stack commands
9.5.4 Kernel stack hints
9.6 Files
9.6.1 The 1 He command
9.6.2 Examining
9.6.3 Examining mo(/rs
9.6.4 Mounted file systems
9.7 Memory
9.7.1 Memory configuration commands
5,"'(ret')" sn
532
534
535
539
540
540
540
541
543
543
544
545
548
549
549
551
551
553
555
557
559
559
559
561
561
563
565
568
571
574
576
582
583
585
585
589
590
591
594
51)5
5')5
5')6
W)
601
601
9.7.2 Virtual memory commands
9.7.3 The map command
9.7.4 Memory hints
9.8 STREAMS
9.8.1 STREAMS memory
9J\'2 Queues and streams
9.8.3 STREAMS terminals
9.8.4 STREAMS hints
9.9 Miscellaneous commands
Appendix A System call error codes
Appendix B filock structure
Appendix C siginfo structure
Appendix D strevent structure
Appendix E Streams D3DK functions
Appendix F Crash commands
Appendix G IEEE POSIX Suite
BIBLIOGRAPHY
INDEX
CONTENTS xix
un
604
(,(15
(,05
606
610
614
f>1R
619
622
611,
627
62R
629
632
636
611-\
642
'midts.

, J