Lions - Unix Operating System Source Code Level Six 197711
Lions - Unix Operating System Source Code Level Six 197711
UNIX
. OPERATING
SYSTEM
SOURCE .
CODE
LEVEL
SIX
I
~
The University of New South Wales
UNIX
OPERATING
SYSTEM
SOURCE
CODE
File paralT,.h 2369 printn File te)d:,.c 6045 stat:L 8023 1-<.1 open
File sYstm.h 2386 putchar 4368 ~<swap 6069 dlJP 8055 klclose
File ses.h 2416 F'anic 4398 )-(free 6086 smount 8062 kl T'ead
File proc.h 2433 prdev 4433 )·(alloc 6144 sumount 8066 klwrite
File 1J~;er.h 2447 deverror 4490 Nccdec 6181 setmdev 8070 khdnt
File 10w.5 File m311oc.c File buf.h File rdwT'i. c 8078 klrint
File m40.s 2528 malloc File conf.h (S22:t readi B090 k.l s~.=1tt.~
0676 .. cleal'ses: 2556 mfree File conf.c 6276 writei File ttw.c
0696 .. copwses: Fi I€,' res.h File bio.c 6326 ma)·( 8165 sthl
0725 _savu: File trap.c 4754 bT'ead 6339 min 81.83 sttw
0734 ._a retu: 2693 trap 477:3 breada 6364 iomove B201 ssttw
0740 _retu: 2841 trapl 4809 bwrite File s'Jbr.c 8217 wfllJshttw
0814 _fuibwte: 2855 nosws 4836 bdwrite 6415 blT,ap 8234 ci.nit
0815 _ fub!~te: 2864 nullsws 4856 bawrite 6517 passe 8252 flu~;httw
0826 .. suib!olte: File swsent.c 4869 brelse 6542 CP(3SS 8274 canon
0827 _subwte: File sws1.c 4899 incore 6566 nodev 8333 ttwinPlJt
0844 _flJiword: 3020 e)·(ec 4921. setblk 6577 nulldev 8373 ttwoutP'Jt
0845 .. fuwo I'd: 3205 re}dt 4982 i.owait 6585 bcop~~ 8486 ttrstrt
0860 .. suiword: 3219 e)dt 4999 notavail File fio.c 8505 ttstart
0861 _suword: 3270 wait 5018 iodone 6619 setf 8535 ttread
0889 _savfp; 3322 fOT'k 5038 clrbuf 6643 clo~;;ef 8550 tt.write
0890 _displa,d 3354 sbreak 5055 binit 6672 clQsei 85T7 ttWStt~1
0895 _incupc: File s~54.c 5096 devstart 6702 openi Fi ll? pc-.c-
ono _setc: 3413 setswit 5123 rhstart 6746 access 8648 pcopen
09b7 .. put.c: 3420 stime 5156 ITlapalloc 6791 owner' 8669 pcclose
1.012 .. back'Jp: 3428 stime 5182 IT,Clpfree 6811 suser 8682 pCT'ead
1244 _copwin: 3439 set'Jid 5196 swap 6824 ufallQc 870i. pcwT'ite
1252 _CQpwout: 3452 setuid 5229 bfllJsh 6847 falloc 8710 pcstal't
J.~o...t _idle! 3460 setsid 5259 ph~sio File alloc.c 8719 pCI'int
1.293 ._spl0: 3472 setsid 5336 seterror 6922 iinit 8739 pcpint
1297 _spu.: 3480 setpid File rk.c 6956 allQc 8748 PCO'.J"Lput
1302 _sp14: 3486 sY'nc 5389 rkstrate9w 7000 free 8763 pcl~~ad(i!r
1303 _sp15: 3493 nice 5420 rkaddr 7040 badblock File Ip.c
1308 _sp16: 3510 unlink 5440 rkstart 7067 ia110c 8850 lpopen
1.313 _sp17: 3538 chdir 5451 rkintr 7134 ifree 8863 lpclose
1317' _dPadO; 3560 l:hmud 5476 i"~:.i"2~d 716 7 getf'c. 8870 Ipwrite
1327 _dpcmp: 3575 chown 5483 rkwrite 7201 update 8879 Ipcanon
1393 _ldiv: 3595 smdate File file.h File iset.c 8967 Ipstart
1401 _lrefTI: 3614 SSi9 File filsws.h 7276 iset 8976 Iplnt
1410 _lshift: 3630 ki 11 File iroo.h 7344 iput 8986 Ipoutput
File mairo.c 3656 times File inode.h 7374 iupdat File mefTI+c
1550 main 3667 profil File sys2.c 7414 itrunc 9016 iTllT,read
1650 estab'JT' File clock.c 5711 read 7455 iTlaknode 9042 iTllT,wri te
1739 sure9 3725 clock 5720 write 7477 wdir
1771 nses 3845 timeout 5731 I'dwr File nami.c
File slp.c File sis.c 5765 open 7518 namei
1826 newproc 3949 sisnal 5781 creat 7b79 schar
1940 sched 3963 psisnal 5804 open1 7689 ,-,char
2066 sleep 3991 issis 5846 close File pipe.c
2113 wakeup 4016 stop 5861 seek 7723 pipe
2134 set run 4043 psis I::"lii\Q
...J7V7 1 inj.~. 7758 readp
2156 setpT'i 4094 core 5952 mknod 7805 writep
2178 swtch 4136 srow 5979 sslep 7862 plock
2268 e)·(pand 4164 ptrace File sys3.c 7882 prele
File prf.c 4204 proc}(mt 6014 fstat File tty.h
2340 printf File te)·(t .h 6028 stat File kl.c
Ma\,/ 26 15:46 UNIX Operating S\,/stem Defined S\,/mbols Page 1
5372 ARDY 0100 0489 EMFILE 24 5696 IREAD 0400 0160 PUSER 100 7975 TBDELAY 006000
7993 ASLEEP 0100 0496 EMLINK 31 5627 1SGID 02000 0158 PWAIT 40 2615 TBIT 020
7992 BUSY 040 0488 ENFILE 23 5694 1SGID 02000 2605 RO (0) 7984 TIMEOUT 01
8617 BUSY 04000 0484 ENODEV 19 7987 1SOF'EN 04 2606 R1 (-2) 7961 TTH1WAT 50
4584 B_ASYNC 0400 0468 ENOENT 2 5626 1SUID 04000 2607 R2 (-9) 7951 TT1PR1 10
4576 B_BUSY 010 0474 ENOEXEC 8 5693 ISUID 04000 2608 R3 (-8) 7962 TTLOWAT 30
4586 B_DELWRI 01000 0478 ENOMEM 12 5628 1SVTX 01000 2609 R4 (-7) 7952 TTOF'R1 20
4574 B_DONE 02 0493 ENOSF'C 28 5695 ISVTX 01000 2610 R5 (-6) 7963 TTYHOG 256
4575 B_ERROR 04 0480 ENOTBLK 15 5684 ITEXT 040 2611 R6 (-3) 0311 UBMAP 0170200
4579 B_MAP 040 0485 ENOTDIR 20 5680 IUPD 02 2612 R7 (1) 0308 UDSA 0177660
4577 B_PHYS 020 0490 ENOTTY 25 5683 IWANT 020 7971 RAW 040 0306 U1SA 0177640
4573 B_READ 01 0472 ENXIO 6 5630 IWRITE 0200 5094 RCOM 04 0304 U1SD 0177600
458:~ B_RELOC 0200 8612 EOF 3 5697 IWRITE 0200 8014 RDRENB 01 3706 UMODE 0170000
4581 B.. WANTED 0100 0467 EPERM 1 0165 KL 0177560 8614 RDRENB 01 2659 UMODE 0170000
4 ..cI,
-.,r)
.:.. B_WRITE 0 0497 EPIPE 3'1
"- 8008 KLADDR 0177560 8611 READING 2 2662 USER 020
0140 CANBSIZ 256 0495 EROFS 30 8009 KLBASE 0176500 5367 RESET 0 0103 USIZE 16
8840 CAP 01 8618 ERROR 0100000 7968 LCASE 04 5121 RHRCOM 070 7977 VTDELAY 040000
7990 CARR_ON 020 0494 ESPIPE 29 8812 LF'ADDR 0177514 5120 RHWCOM 060 8610 WAITING 1
7955 CEOT 004 0469 ESRCH 3 8819 LPHWAT 100 5363 RKADDR 0177400 5093 WCOM 02
8818 LPLWAT 50 0315 RO 02 5373 WLD 020000
7'154
7958
CERASE
CINTR
'*'
0177
0491
7973
ETXTBSY
EVENP
26
0200 8817 LF'PRI 10 0106 ROOTINO 1 0316 WO 04
7956 CKILL '@' 0483 EXDEV 18 8821 MAXCOL 80 2613 RPS (2) 7985 WOPEN 02
1509 CLOCKl 0177546 3018 EXPRI -1 0135 MAXMEM (64*32) 0317 F~W 06 7967 XTABS 02
1510 CLOCK2 0172540 8847 FORM 014 0130 NBUF 15 3707 SCHMAG 10
B609 CLOSED 0 5519 FPIPE 04 0143 NCALL 20 2660 SETD 0170011
0141 CMAPSIZ 100 5517 FREAD 01 0146 NCLIST 100 0385 SIDL 4
7957 CaUIT 034 5518 FWRITE 02 8012 NDL11 0 0123 SIGBLJ~; 10
7976 CRDELAY 030000 5095 GO 01 0134 NEXEC 3 0120 SIGEMT 7
7970 CRMOD 020 5368 GO 01 0132 NFILE 100 0121 SIGFPT 8
5374 CTLRDY 0200 7966 HLJPCL 01 0131 NINODE 100 01:l4 SlGHUP 1
0107 DIRSIZ 14 0147 HZ 60 8011 NKL:ll 1 O:L17 SlGINS 4
8010 DLBASE 0175610 5681 IACC 04 7974 NLDELAY 001400 0115 SIGINT 2
7980 DONE 0200 5620 IALLOC 0100000 0133 NMOUNT 5 0119 SIG10T 6
fl616 DONE 0200 5687 IALLOC 0100000 0105 NODEV (-1) 0122 SIGKIL 9
B815 DONE 0200 5092 IENABLE 0100 0139 NOFILE 15 0126 SIGPIPE 13
5369 DRESET 014 5370 IEN~IBLE 0100 0144 NPROC 50 01:L6 SIGCHT 3
5371 DRY 0200 7981 IENABLE 0100 5364 NRK 4 0124 SIGSEG 11
Bon DSRDY 02 8615 IENABLE 0100 5365 NRKBLK 4872 0125 SIGSYS 12
0473 E2BIG 7 8814 IENABLE 0100 0113 NSIG 20 01:L8 SIGTRC 5
0479 EACCES 13 5631 IEXEC 0100 0145 NTEXT 40 0138 SINCF~ 20
0477 EAGAIN 11 5698 IEXEC 0100 0104 NULL 0 0391 SLOAD 01
0475 EBADF 9 5624 IFBLK 060000 7972 ODDP 0100 0393 SLOCK 04
2658 EBIT 1 5691 IFB~K 060000 8843 OPEN 04 0142 SMAPSIZ 100
0481 EBUSY 16 5623 IFCHR 020000 B607 F'CADDH 0177550 0384 SRUN 3
0476 ECHILD 10 5690 IFCHR 020000 8624 F'CIHWAT 250 OB7 SSIZE 20
7969 ECHO 010 5622 IFDIR 040000 B620 PCIPRI 30 0382 SSLEEP 1
0318 ED 010 5689 IFDIR 040000 8623 PCOHWAT 100 798B SSTART 010
0482 EEXIST 17 5621 IFMT 060000 B622 PCOLWAT 50 0387 SSTOF' 6
0466 EFAULT 106 5688 IFMT 060000 8621 F'COF'RI 40 0394 SSWAP 010
0492 EFBIG 27 5625 ILARG 010000 0155 F'INOD --9() 0392 SSYS 02
0470 EINTR 4 5692 ILARG 010000 7715 F'IPSIZ 4096 0395 t,TRC 020
0487 EINVAL 22 5679 I LOCI":: 01 0157 F'F' I F'E 1 0166 ~3W 0177570
0471 EIO 5 5682 IMOUNT 010 0156 F'RIBIO -50 0383 SWAIT 2
0486 EISDIR 21 8844 IND 010 0164 F'S 0177776 0396 SWTED 040
8842 EJECT 02 3914 IPCPRI (-1) 0159 PSLEF' 90 2661 SYS 0104400
8820 EJUNE 60 5629 IREAD 04()0 0154 PSWP -100 0386 SZOMB 5
May 26 15:45 UNIX Operatin~ System Source Code Cross Reference Listin~ Pa~e 1
aa 2556 2563 bawrite 4845 4856 6310 buffers 4720 5067 5071 5079
abae 5123 5125 5134 bcopy 3238 6124 6585 6931 BUSY 7992 8617 8691 B... MAP 4579 5024 5172 5186
abn 7040 7046 6976 7019 7220 7636 bwrite 3239 4809 4863 4963 B_PHYS 4577 5206 5299 5397
abp 5156 5157 5171 5259 bdevsw 4617 4622 4656 4763 5241 7021 7221 7400 B_READ 2034 2042 4573 4761
5260 5268 5336 5337 4785 4795 4819 4843 3049 3153 3238 3290 4783 4793 4817 5111
5341 5389 5390 5396 4906 4934 5060 5076 4529 5044 5067 5107 5140 5479 6260
8333 8340 8373 8382 5212 6113 6166 6689 5136 5210 5305 5307 B_F:ELOC 4583 4966
access 3041 3552 4109 5815 6722 6926 6052 6124 6125 6371 b_T'esid 4533 5322
5817 6746 7563 7604 bdp 5060 5076 5077 6437 6473 6491 6931 B_WANTED 4581 4876 4878 4879
7658 bdwrite 4836 6311 6443 6449 6935 6974 7017 7098 4887 4942 4954 5030
addr 8024 8039 8041 8043 6485 6500 6501 7174 7212 7220 7328 5166 5187 5203 5216
8044 8051 8052 8079 bflg 1049 1060 1094 1108 7387 7427 7432 7433 5219 5296 5318 5321
8082 8083 8084 8086 1204 1238 7636 4528 4762 4784 4794
8508 8513 8515 8518 bflush 5229 7230 4584 4793 4820 4862 4818 5108 5137 5208
8522 bfreelis 4567 4878 4879 4880 4887 4962 5027 5239 5310
ad(~v 4773 4778 4785 4795 4884 4891 4932 4953 4524 4556 4967 4968 4572 5486 6306 6373
4899 4905 4906 4954 4955 4960 5062 4970 4971 5062 5068 6386
2344 2346 2355 2357 5063 5068 5069 5070 5070 5080 4530 5110 5134 5139
2361 5071 523~j 2454 4531 4908 4938 5173 5178 5211 5308
afp 7040 7045 bi~~er 3375 3386 4974 5209 5309 5402 call 0555 0558 0561 0564
ai.p 6221 6222 6229 6276 binit 1614 5055 5428 6442 6450 6470 0567 0570 0574 0577
6277 6284 6746 6747 blkno 4754 4758 4773 4780 6484 6498 0752 0776 2669 2771
6751 4781 4799 4899 4908 4576 4887 4941 4966 calli 0762 0771
alloe 6435 6448 6468 6480 4921 4938 4974 5196 5010 5072 5165 5169 callo 0260 3727 3847
6497 6956 5209 5202 5206 5219 5295 callout 0265 3748 3750 3767
an 6364 6370 6248 6298 6415 7626 5299 5321 3768 3773 3853
ARDY 5372 6958 6967 6968 6970 B_.DELWRI 4586 4817 4823 4847 callp 2696 2754 2755 2761
aret'.1 0724 0734 2106 2242 6973 6981 7000 7008 4961 5237 2762 2765 2771
ar!:! 3845 3871 7016 7025 2453 4527 4819 4843 CANBSIZ 0140 0202 8316
ASLEEP 7993 8224 8562 bpi 8278 8319 8322 4883 4908 4938 4973 canon 8274 8543
atp 8217 8218 8221 8252 bread 3282 4754 4799 6051 5066 5207 5238 5300 canonb 0202 8291 8300 8316
8253 8257 8274 8275 6116 6258 6305 6472 5399 5429 5431 8320
8282 8333 8334 8339 6488 6927 6973 7097 4574 4759 4782 4790 8840 8884
8486 8490 8505 8506 7319 7386 7426 7431 4817 4847 4989 5026 7990 8046 8285 8541
8512 8535 8536 8540 7625 5214 5315 8556
8550 8551 9555 8577 b!'e~d? 477~ 6256 b_error 4532 eblock 8140 8141 8146 8149
8578 8581 brelse 3195 3298 4791 4822 B_ERROR 4575 4817 4882 5220 8237
8577 8578 8582 4848 4869 5028 5073 b_error 5311 cc 8635 8731 8743 8754
4526 4884 4889 5008 6062 6118 6129 6172 B_ERROR 5342 8830 8981 8988
5009 5063 6261 6308 6481 6487 b_error 5343 ccc 8835 8910 8918 8935
av_forw 4525 4888 4891 4953 6503 6932 6977 7112 B_ERROR 5403 5467 7323 8937 8941 8942 8946
4960 5008 5009 5063 7324 7332 7436 7440 b_ fla~s 4522 4759 4761 4782 8950 8954 8955 8962
5235 5236 5407 5412 7602 7624 7656 4783 4790 4793 4816 ccp 8236 8239 8240 8244
5470 buf 4520 4523 4524 4525 4817 4847 4862 4876 8246 8247
backp 4872 4884 4888 4889 4526 4535 4555 4556 4878 4879 4882 4887 cdevsw 4635 4641 4669 6234
4890 4557 4558 4567 4721 4941 4942 4954 4961 6287 6685 6716 8213
backup 1009 1012 1015 1047 4756 4775 4810 4812 4962 4966 4989 5010 8238 8245
2812 4837 4839 4857 4859 5024 5026 5027 5030 cdp 8238 8245
badblock 6970 7008 7040 4870 4872 4902 4923 5072 5111 5140 5172 CEOT 7955 8306
badtrap 1465 1468 4983 4985 5000 5002 5186 5200 5237 5239 CERASE 7954 8048
6419 6437 6439 6473 5019 5021 5057 5065 5295 5296 5299 5315 cf 8636 8831
6479 6484 6491 6497 5097 5101 5124 5128 5318 5321 5342 5397 efree 8146 8239 8240
6499 6506 5157 5160 5183 5231 5403 5467 7323 cfreeli 0928 0954 0955 0977
base 5264 5269 5273 5278 5260 5263 5337 5339 4523 4555 4907 4937 0979· 0986 0988
5291 5305 5306 5307 5387 5390 5392 5421 4967 4968 4969 4971 cfreelis 8149 8241 8242
5308 5423 5442 5453 6365 4972 5062 5069 5070 chan 2066 2076 2089 2113
Maw 26 15:45 UNIX Operating Swstem Source Code Cross Reference Listing Page 2
2118 8379 8424 8426 8440 6250 6252 6256 6258 6551 7695
chdir 2924 3538 8441 8445 8452 8453 6281 6300 6302 6304 EFBIG 0492 6424
chlllod 2927 3560 8468 8469 8472 6305 EINTI:;; 0470 2773
choloJrl 2928 3575 0222 2141 2165 2224 DONE 7980 8518 8616 8691 E1NVAL 0487 3620 6157
cinit 161.3 8234 0263 3770 3776 3866 8714 8815 8971 E10 0471 4193 5344 8751
CINTR 7958 8344 8345 3871 dpadd 1318 1319 3292 3293 8854
CKILL 7956 8049 7910 8074 8223 8349 3295 3296 5756 5890 E1SDIR 0486 5819
c1 8637 8832 8543 8544 8560 5895 5986 6382 9051 EJECT 8842 8857 8923 8927
clearseg 0675 0676 1566 3134 c_cf 7911 dpclllP 1326 1327 5988 5989 EJLINE 8820 8927
3395 4155 c_cl 7912 5990 6243 6312 eloop 7592 7643 7647
cli.st 7908 7928 7929 7930 c_func 0264 3748 3751 3769 DRESET 5369 EMFILE 0489 6833
8634 8643 8644 3770 3774 3855 3861 DRY 5371 EMLINK 0496 5918
cl.ock 0569 0570 3725 3865 3870 DSRDY 8013 8051 end 0611 0632 0654
CLOCK1 1509 1601 c_ne:·:t 8141 8241 dUIllP 0521 0523 1352 1353 ENFILE 0488 6863 7311
CLOCK2 1510 1603 c_time 0262 3751 3753 3767 1355 ENODEV 0484 6569
cloop 7542 7667 3769 3775 3855 3856 2953 6069 ENOENT 0468 7538 7612
close 2918 5846 3859 3864 3869 4557 5409 5410 5444 ENOEXEC 0474 3102
CLOSED 8609 8653 8675 dey 2433 2436 2693 2700 5457 5470 ENOMEM 0478 1728
closef 3230 5854 6643 2702 2718 3725 4754 4553 5414 5446 5455 ENOSPC 0493 6989 7121
c1osei. 6656 6672 4758 4763 4776 4778 5458 ENOTBLK 0480 6190
clrbuf 5038 6982 4780 4781 4788 4789 4558 5412 5413 ENOTDIR 0485 3547 7560
CMAPSIZ 0141 0203 4799 4901 4905 4908 4619 4637 6166 6685 ENOTTY 0490 8210
colp 8378 8400 8401 8402 4921 4927 4931 4934 6689 ENXIO 0472 6193 6727 8027
8404 8423 8429 8435 4938 4973 5229 5238 d_errcnt 4554 5463 5469 8654
8436 8442 8443 8448 5259 5300 5476 5479 d_llIaJor 2436 4606 4763 4785 EOF 8612 8689 8728
8454 8458 8459 8475 5483 5486 6676 6679 4795 4819 4843 4906 ep 7418 7432 7433 7434
COlli 5102 5109 5112 5114 6685 6689 6706 6709 4927 4934 6113 6166 7435
5115 5i29 5138 5141 6716 6722 6956 6961 6192 6234 6287 6680 EPERM 0467 6816
5142 5143 6970 6973 6981 6988 6710 6926 8213 EPIPE 0497 7827
cont 7106 7110 7000 7004 7008 7016 2436 4605 4883 5399 EROFS 0495 6755
copsu 1245 1253 1264 7040 7048 7067 7072 5429 5431 8026 8030 err 0855 0872 0880 1656
copwin 124:5 1244 6374 7078 7097 7104 7120 8039 8040 8042 8057 1658 1661 1663 1727
CC)P!:lout 1243 1252 1630 6376 7134 713tl 7167 7173 8063 8067 8072 8081 error 4219 4226 4234 4241
C()p~jse~~ 0695 0696 1915 2292 7178 7276 7286 7296 8093 9021 9031 9047 4248 4260 4281
3380 3392 4152 7314 7319 tl023 8026 9064 ERRDR 8618 8691 8722 8727
core 4076 4094 8030 8033 8039 8040 4618 4636 5076 6113 8750
coreaddl' 51.96 5210 5211 8042 8055 8057 8062 6716 6722 6926 8245 esc 8891 8895 8899 8903
corelllap 0203 1568 1896 1982 8063 8066 8067 8070 d_read 4638 6234 8908
2278 2282 2293 3241 8072 8078 8081 8090 d_sstt!:l 4640 8213 ESPIPE 0494 5870
4383 4497 8093 8648 8669 8850 d_strat,e 4620 4763 4785 4795 ESRCH 0469 3652 4177
. count 2668 2762 2765 5196 8863 9016 9021 9031 4819 5212 estabur 1629 1650 3118 3138
5208 6585 6592 9042 9047 9064 4621 4843 4906 4934 3152 3371 4120 4146
cpl 7480 7483 7485 devbll<. 5096 5106 5123 5135 5077 4460
cp2 7480 7484 7485 deverror 2447 5460 d_write 4639 6287 ETXTBSY 0491 3106 6759
CF'ass 6388 6542 8558 8705 devioc 5096 5098 5104 5123 E2BIG 0473 3064 EVENP 7973
8874 9057 5125 5131 EACCES 0479 6778 EXDEV 0483 5937
0208 1459 1461 1571 devstart 5096 5447 EAGAIN 0477 :3330 e:-:ec 2923 3020
1655 1746 1756 5133 devtab 4551 4840 4903 4924 EBADF 0475 5740 6630 e:·:ecnt 0210 3037 3038 3039
5162 5058 5386 EBIT 2658 2753 2776 3196 3197 3198
CQUIT 7957 tl344 DIRSIZ 0107 0429 0433 3524 EBUSY 0481 6135 6163 e:dt 3209 3219 4032 4080
CRDELAY 7976 3526 7484 7486 7572 ECHILD 0476 3317 427B
ereat 2920 57tll 7576 7589 7608 7637 ECHO 7969 8047 836:1. e:·:pand 1628 2268 3129 3132
cret 1429 1430 7638 7645 ED 0318 1711 3383 3387 4148 4459
CRMOD 7970 8047 8342 8412 displaw 0888 0890 3740 edata 0611 0651 4473
csv 1419 1420 DLBASE 8010 8043 EEXIST 0482 5930 5960 EXF'RI 3018 3038
CTLRDY 5374 5462 dn 6226 6243 6245 6247 EFAULT 0466 5326 6378 6524 falloc 5827 6847 7731 7737
Maw 26 15:45 UNIX Operatins·Swstem Source Code Cross Reference ListinS PaSe 3
fetch 1051 1173 1180 1184 5889 5890 5901 5902 IFMT 3041 3522 3546 4110 3937 4185 4218
4220
1222 6858 6859 7772 7773 5621 5688 5818 5921 4225 4227 4232
4240
ff 4368 4382 7774 7796 7798 6189 6233 6242 6286 4242 4247 4249
4254
file 5507 5513 5807 6849 setblk 3040 3237 4758 4781 6297 6682 6711 7559 3938 4184 4191
4220
6854 8204 4789 4921 6123 6304 8209 4227 4235 4242
4249
filsws 5561 7042 6928 6981 7016 7216 ifree 7134 7355 4264 4266 4268
4273
flag 4813 4816 4820 ..'.823 £ietc 0930 8259 iset 1616 1618 ~5519 7078 3935 4181 4183 4194
6364 6373 6386 7518 8264 8292 8520 8544 7276 7534 7664 4209
7537 7603 7657 8023 8673 8688 8714 8971 iinit 1615 6922 3936 4186 4189 4192
8648 8652 8669 8671 Seterror 4824 4992 5323 5336 ILARG 5625 5692 6427 6444 4211 4212 4282
8833 8850 8853 8857 Setf 5736 5850 5866 6018 7425 7445 IREAD 5629 5696 5815 6651
8863 8866 8884 8923 6073 6619 8206 IL.OCI( 1617 1619 5679 5926 7789 7850 7851
8927 8936 setfs 6754 6961 7004 7072 7224 7225 7287 7303 ISGID 3176 5627 ~j694
fllJshttw 8227 8252 8346 8350 7138 7167 7383 7316 7351 7868 7872 ISOPEN 7987 8045 8046
fmt 2340 2341 2348 2353 setsid 2959 3472 7888 :issis 2073 2085 2821 3826
fork 2914 3322 setmdev 6093 6151 6181 IMOUNT 5682 6130 6168 7292 3991
FORM 8847 8859 8865 8921 Setpid 2932 3480 incore 4780 4788 4899 ISUID 3171 5626 569:~
8928 8930 setswit 2950 3413 incupc 0894 0895 3791 ISVTX 3568 4406 5628 5695
found 3329 3333 4176 4180 setuid 2936 3452 IND 8844 8857 8936 5790
6156 6160 sid 3462 3464 3465 3466 info 8142 ITEXT 3105 4410 4471 5684
foundl 1994 2021 3467 ino 7070 7077 7078 7095 6758
fClund2 1983 2031 GO 5095 5109 5138 5368 7100 7105 7107 7134 i trlJnc 4112 5825 7353 7414
FPIF'E 5519 5746 5869 6649 5461 7143 7276 7286 7297 IUPD 3530 3570 3583 5680
7746 7748 srow 2813 4056 4136 7315 7319 7328 5942 6285 6318 6452
FREAD 5517 5713 5747 5753 stirlle 2925 3420 inode 5605 5659 5675 6147 6467 7382 7396 7448
5814 5829 7748 sttw 2944 8165 6161 6222 6227 6277 7462 7609 7751
fl'ee 7000 7435 7438 7442 sword 0818 0830 0848 0851 6282 6416 6793 7104 ilJpdat 6050 7226 7357 7374
frolll 6585 6586 6590 hbcom 5096 5109 7105 7203 7223 7278 IWANT 5683 7288 7869 7889
fstat 2940 6014 hibwte 0180 3456 3476 3582 7285 7345 7521 8205 7890
fub!olte 0807 0815 3058 4225 8585 8593 inta 3921 4235 4254 IWRITE 4109 5630 5697 5817
6550 7693 httab 4728 4844 intes 0175 2070 2095 2391 6651 6753 7604 7658
fl.lib!olte 0809 0814 1564 4218 HUPCL 7966 3416 3852 3872 4885 7776 7777 7836
9034 HZ 0147 3797 3800 4892 5006 5011 8262 5613 5672 5969 6191
fui.word 0813 0844 1602 1604 IACC 5681 6232 6285 7382 8266 6192 6234 6252 6287
2734 2754 2756 2766 7391 7462 7751 10 0641 1455 6302 6439 6440 6442
!ALLOC 5620 5687 i~d~~~ S(H8 SA{)A 5.1171 64.117 6451 6456 6466
fun 3845 3870 ialloc 7067 7459 iomove 6260 6306 6364 6470 6679 6680 6709
func 7518 7519 7532 7536 IALLOC 7463 iowait 4764 4800 4821 4982 6710 7082 7330 7389
7574 7579 8510 8515 ialloc 7728 ipc 3939 4181 4182 4183 7423 7430 8213
fuword 0811 0845 0847 2758 IALLOC 7752 4184 4185 4186 4189 i_atime 5614
2763 3052 4227 8188 icode 1516 1630 4190 4191 4192 4194 i_colJnt 1883 3105 4472 5662
8189 8190 idle 1283 1284 2220 2423 4195 4209 4211 4212 6100 6681 7302 7306
FWRITE 5518 5722 5793 5795 IENABLE 5092 5109 5138 5370 4213 4218 4220 4225 7317 7350 7362 7750
5816 5829 5832 6656 7981 8051 8052 8615 4227 4232 4235 4240 7787 7825
7746 8659 8663 8692 8732 4242 4247 4249 4254 3519 5663 5935 6051
1878 5510 5836 6079 8814 8858 4264 4266 4268 4273 6053 6162 6250 6300
6655 6657 6855 6857 IEXEC 3041 3552 5631 5698 4282 6422 6754 7104 7286
7739 6764 6765 7563 IPCF'RI 3914 4182 4190 7314 7355 7383 7386
5509 5739 5746 5829 IFBLK 5624 5691 6100 6189 iput 3194 3232 3533 3534 7426 7431 7435 7438
5869 6649 6656 7746 6242 6297 6314 6688 3549 3554 3571 3584 7442 7459 7534 7625
//~o 4126 4411 5839 5931 7662
f_inode 5511 5754 5755 5830 IFCHR 5623 5690 6100 6233 5936 5945 5972 6037 1617 1619 3105 3530
5894 5895 6021 6650 6286 6314 6684 6713 6137 6169 6194 6691 3570 3583 4410 4471
6656 7747 7749 7764 7421 8209 6802 7091 7325 7344 5661 5926 5942 6130
7810 8208 IFDIR 3522 3546 5622 5689 7490 7663 7670 7733 6168 6232 6285 6318
f_offset 5512 5751 5752 5756 5818 5921 7559 7741 6452 6467 6758 7224
Ma~ 26 15:45 UNIX Operating S~stem Source Code Cross Reference listing Page 4
7225 7287 7288 7292 klread 4671 8062 lpsr 8824 8853 8858 8971 2542 2564 2565 2566
7303 7316 7351 7359 klregs 8016 Ipstart 8967 8980 8992 2568 2569 2572 2576
7382 7391 7396 7448 klrint 0557 0558 8078 Ipwrite 4675 8870 2578 2583 2584
7462 7609 7751 7868 kIsstt~ 4671 8090 Irem 1400 1401 2375 5433 namei 3034 3515 3543 4101
7869 7872 7888 7889 kltbuf 8020 8086 6052 7328 7387 5770 5786 5914 5928
7890 kItcsr 8019 8052 lshift 1409 1410 5309 6239 5958 6033 6097 6186
Lsid 3177 3582 5610 5669 kIwrite 4671 8066 6294 9024 9055 6796 7518
6771 7466 kb:int 0560 0561 8070 main 0611 0669 1550 nblkdev 4631 4927 5084 6192
i._Iastr 5673 6255 6259 7318 I<.wlp 0534 0535 0570 maknode 4105 5790 5966 7455 6720
i_mode 3041 3171 3176 3522 large 6445 6462 ITlalloc 1896 1982 2282 2528 NBUF 0130 4535 4720 5064
3546 3566 3569 4110 Ibn 6225 6239 6248 6255 3234 4375 4457 NCAll 0143 0265
4406 5607 5666 5818 6259 2515 2529 2532 2557 nchrdev 4647 6714 8247
5921 6100 6189 6233 IbC)lt 0212 3797 3800 3808 2559 NCLIST 0146 8146 8240
6242 6286 6297 6314 4925 8650 8660 mapaIIoc 5156 5398 NDl11 8012 8015 8026
6427 6444 6651 6682 lCASE 7968 8047 8309 8353 ITlapfree 5025 5182 newproc 1627 1826 3334
6711 6764 6774 7081 8399 maplock 5155 5165 5166 5167 newsize 2268 2275 2277 2278
7082 7329 7354 7388 Idiv 1392 1393 2373 4143 5169 5187 5188 5189 2282
7421 7425 7445 7463 5434 6051 7319 7386 8117 8309 8311 NEXEC 0134 3037 3196
7559 7752 7776 7777 7589 7626 ma}! 6326 8443 NFIlE 0132 5513 6854
7789 7836 7850 7851. li.nk 2921 5909 MAXCOl 8821 8954 nice 2946 3493
8209 Iks 0226 1601 1602 1603 MAXMEM 0135 NINODE 0131 5675 6161 7103
i_mtime 5615 1604 1607 3734 ma:{mem 0224 1567 1576 7223 7285
L.nIink 3529 5608 5667 5917 IC)b~te 0180 3443 3444 3455 MAXMEM 1582 NKl11 8011 8015 8026 8042
5941 7352 7464 3464 3465 3475 3581 ma:·(mem 1582 1662 8043
5664 6051 6052 6162 8584 8592 mcc 8834 8924 8925 8950 NlDElAY 7974
7105 7286 7315 7355 loop 1951 1957 1969 2025 8952 8955 8957 8960 NMOUNT 0133 0277 6103 6154
7360 7385 7482 7534 2048 2195 2221 2347 mfree 1568 1583 2044 2278 7172 7210 7294
5611 5670 5894 6243 2362 3245 3260 3276 2293 2556 3241 3283 NODEV 0105 3040
6312 6315 7446 3315 4020 4030 4930 4383 4408 4497 nodev 4659 4660 4661 4662
5612 5671 5895 6243 4945 4957 4964 5233 min 1582 6241 6247 6296 4663 4664 4665 4673
6312 6316 7447 7589 5242 7075 7092 7119 6339 7846 4675 4677 4678 4679
7772 7775 7835 7845 7283 7290 7298 7765 IlIknod 2926 5952 4680 4681 4682 4684
3173 3174 3581 5609 7791 7812 7839 7854 ITI1e 8836 8924 8926 8927 4686 4687 4688 4689
5668 6769 6798 7465 8290 8305 8931 4690 4691
.i 7070 7099 7101 Ipll 8837 8853 8857 8866 III ITt read 4682 9016 NODEV 5238 6123
.ifls 1.018 1193 1239 8884 8910 8918 8923 IlImwrite 4682 9042 nodev 6566
k 7070 7103 7104 7105 8924 8925 8926 8927 Illode 5731 5735 5804 5812 NODEV 6928 7230
ka6 0322 1459 1460 1560 8931 8935 8936 8937 6746 6752 7455 7463 nofault 0757 0766 0854 0855
1589 1599 2716 9032 8941 8942 8946 8950 ITlount 0272 0277 6090 6103 0871 0872 0876 0881
9065 8952 8954 8955 8957 6148 6154 6933 6934 0909 0910 0918 1224
kill 2949 3630 8960 8962 8971 8981 7169 7172 7204 7210 1225 1228 1232 1259
KISAO 0619 1447 8982 8988 8989 8990 7281 7293 7294 1267 1273 1277 1465
KISA6 0743 1368 1448 1460 lPADDR 8812 8853 8858 8971 ITIPid 0216 1841 1842 1843 1466
KI!JDO 0620 1449 8972 1849 1867 NDFIlE 0139 0438 1876 3227
KL. 01.65 2393 2397 2398 Ipbuf 8825 8972 1373 1450 6624 6828
2399 2406 Ipcanon 8859 8865 8875 8879 2518 2536 2537 2541 nospace 6966 6969 6986
k1.1.1. 8015 8030 8057 8063 8909 2564 2565 2567 2571 nos~s 2855 2939 2941 2945
8067 8072 8081 8093 Ipclose 4675 8863 2576 2577 2580 2581 2951 2952 2957 2961
KlADDR 8008 8039 8041. lPI-lWAT 8819 8988 0275 6104 6123 6124 2962 2963 2964 2965
KlBASE 8009 8041 8043 Ipint 0573 0574 8976 6125 6155 6170 6171 2966 2967 2968 2969
klclose 4671. 8055 IF'LWAT 8818 8981 6933 7173 7174 7211 2970 2971 2972 2973
klin 0526 0558 Ipopen 4675 8850 7212 2974 2975
klC)pen 4671 8023 Ipou 0541 0574 lTt_dev 0274 6105 6122 6155 notavail 4948 4960 4999 5240
klou 0527 0561 Ipoutput 8929 8951 8956 8959 6934 7173 7216 7296 NF'ROC 0144 0376 1846 1960
kl rblJf 8018 8083 8986 lTt_inodp 0276 6121 6167 7295 1991 2006 2120 2203
klrcsr 8017 8051 8084 lPF'RI 8817 8989 ITt_size 2517 2534 2535 2538 2206 3246 3250 3277
Ma~ 26 15:45 UNIX OperatinS S~stem Source Code Cross Reference Listin~ Pase 5
3327 3639 3810 3953 PCOPRI 8621 8755 0783 0787 0790 0798 4022 4024 4175
4023 4172 PCOIJ 0531 0567 0852 0853 0869 0870 0362 2078 2091 2141
nps 2693 3725 PC out 8644 8714 8743 8744 0877 0882 0932 0934 2167 2209 2211 3817
NRK 5364 8754 8755 8756 0935 0958 0964 0970 0363 3287 3305 3625
NRKBLK 5365 5402 PCOIJtPIJt 8706 8748 8769 0973 0974 0999 1005 3626 3971 3972 3997
r,seS 1657 1660 1771 3366 pcpbuf 8630 8715 1285 1286 1288 1294 4000 4049 4050 4273
NSIG 0113 0447 3183 3225 pcpcsr 8629 8663 8 ...., .......
·" 8750 1298 1299 1304 1305 0372 1590 1893 1895
3619 3968 pcpint 0566 0567 8739 1309 1310 1314 1444 1978 2042 2044 2274
nswap 0232 1583 4698 pcrbuf 8628 8730 2070 2095 2275 3241 4119 4148
NTEXT 0145 4314 4441 pcrcsr 8627 8659 8674 8691 PS 2693 2699 2717 2753 4149 4374 4375
rolJl1dev 4658 4682 4684 6577 8692 8722 8727 8732 2776 3725 3759 3788 0360 1591 1847 1861
nulls~s 2864 2912 2942 pcread 4673 8682 3798 3824 1903 1908 1961 1993
ODDP 7972 pcrint 0563 0564 8719 PS 3852 3872 4885 4892 2008 2077 2090 2140
el", 4256 4259 4261 pcstart 8710 8742 8758 5006 5011 8262 8266 2208 3243 3253 3280
on 6225 6240 6241 6260 pcstate 8642 8653 8657 8658 psi~ 2074 2086 2105 2822 3284 3301 3328 3811
6280 6295 6296 6306 8675 8689 8721 8724 3827 4043 3973 3974 3975 4026
9018 9025 9034 9044 8726 8728 psisnsl 2793 2818 3649 3955 4173
9056 9067 pcwrite 4673 8701 3963 7828 0374 1752 1866 1879
of'en 2917 5765 ph~sio 5259 5479 5486 PSLEP 0159 5994 1979 2032 4378 4401
OPEN 8843 8853 8857 PINOD 0155 6963 7007 7074 F'SWP 0154 1955 1968 5167 4402 4448 4469
of'en:L 5774 5793 5795 5804 7289 5204 5215 0365 1869 1962 1964
of'eni 5832 6702 piPE! 2954 7723 ptrsce 2938 4164 2009 2011 2047 3812
outl 6119 6136 F'IPSIZ 7715 7835 7846 F'USER 0160 2162 3817 3973 3813 4386
elwner 3564 3579 6791 plock 7768 7815 7862 3974 0368 1864 3288 3644
F'sd 5575 F'F'IPE 0157 7790 7838 7870 putc 0926 0967 8323 8355 3954 8031 8032
panic 1605 1853 2051 2416 prdev 2433 2453 6988 7048 8358 8414 8478 8730 0364 1863 3174 3446
2719 3236 3521 4377 7120 7178 8756 8990 3646
4381 4451 4458 4928 prele 3518 3556 5826 6131 PIJtchar 2351 2359 2375 2386 0373 2076 2089 2122
4936 6930 7184 7300 7227 7358 7363 7786 2401 2402 2403 2405 2139
F'ilnicstr 2328 2419 7799 7817 7826 7837 PWAIT 0158 3314 3221 3225 3226 3227
F'iII'tab 7947 8424 8522 7849 7882 pword 0840 0865 0868 3228 3229 3240 3241
F'SSSC 6394 6517 8544 8695 pri 2066 2072 2078 2091 p_sddr 0371 1589 1743 1894 3242 3243 3247 3251
9038 PRIBIO 0156 4943 4955 4990 1904 1913 2042 2044 3259 3632 3638 3640
pc 2693 2734 2754 2756 5297 5316 2045 2193 2228 2276 3644
2757 2766 2767 3725 printf 1576 1577 1578 1579 2290 2294 3134 3241 ~c 5393
3791 2310 2421 2436 3242 3282 3376 3388 Gl 5393
.. e' .... .,.
pcll 8641 8645 8653 8657 2454 2716 2717 2718 4149 4380 4383 4384 r 0185 i56i 1563 .L~/W
8658 8673 8675 8688 6862 7310 4467 1574 1599 1600 1745
8689 8693 8714 8721 printn 2355 2369 2374 0366 2161 3795 3796 1750 1755 1760 5175
8724 8726 8728 8730 proc 0358 0376 1589 1590 3814 3815 3816 5177 5306 7726 7736
8731 8734 8743 8744 1591 1592 1593 1829 0361 1592 1862 1907 7740 7745 9026 9027
8754 8755 8756 1830 1846 1942 1943 1961 1992 2007 2023 9029 9030 9032 9035
F'CADDR 8607 8659 8663 8674 1960 1991 2006 2115 2046 2143 2208 2240 9036 9059 9060 9062
8691 8692 8714 8715 2119 2136 2180 2182 2241 2286 3170 3224 9063 9065 9068 9069
8722 8727 8730 8732 2185 2193 2206 2207 3289 3302 3303 3309 RO 2605 2679
8750 3222 3246 3248 3250 3998 4028 4169 4187 rO 2693 2701 2777
pcclose 4673 8669 3273 3277 3324 3327 4379 4385 4466 4468 RO 3208 3281 3304 3335
PCIHWAT 8624 8731 3632 3639 3644 3728 4479 5312 5317 3344 3416 3423 3432
F'cin 0530 0564 8643 8673 3810 3951 3953 3994 0367 1865 2162 3502 3443 3455 3456 3464
8688 8693 8730 8731 4018 4023 4166 4172 0369 1849 1867 1868 3475 3476 3482 3497
8734 proc;·~iiJt 4025 ~t204 3247 3251 3278 3281 3623 3637
f'CIPRI 8620 8660 8693 profil 2956 3667 3285 3304 3335 3344 rO 3725 3825
pcleader 8664 8678 8763 PS 0164 0668 0677 0679 3482 3642 4024 4174 RO 4079 4184 4191 5736
F'COHWAT 8623 8754 0691 0697 0700 0720 4175 4183 4209 5758 5831 5850 5853
F'COLWAT 8622 8743 0726 0731 0735 0741 0370 1868 3247 3251 5866 5986 6018 6073
pcopen 4673 8648 0748 0756 0773 0777 3252 3259 3278 3286 6830 7736 7744 7745
May 26 15:45 UNIX Operating System Source Code Cross Reference Listing Page 6
8206 rkread 4684 5476 SIGFPT 0121 2793 2797 4071 SRUN 0384 1591 1861 1908
RI 2606 2679 rkstart 5415 5440 5464 5472 SIGHUP 0114 1961 2008 2140 2208
!'I 2693 rkstrate 4658 5389 5479 5486 SIGINS 0117 2734 2736 4053 ssig 2960 3614
R1 3297 3305 3424 3433 rktab 4658 5386 5409 5410 4067 SSIZE 0137 3118 3131 3150
1'1 3725 5412 5413 5414 5444 SIGINT 0115 8345 SSLEEP 0382 2008 2090
F:1 7744 5446 5455 5457 5458 SIGIOT 0119 2744 4069 sslep 2947 5979
R2 2607 2679 5463 5469 5470 SIGKIL 0122 3619 3971 ssr 0759 0760 1013 1016
R3 2608 2679 rkwc 5380 sisnal 3949 8345 1021 1023 1028 1050
R4 2609 2679 rkwrite 4684 5483 SIGPIPE 0126 7828 1150 1171 1465 1467
R5 2610 2679 RO 0315 1668 1674 SIGQIT 0116 4066 8345 SSRO 0613 0647 0759 0761
F:6 2611 2679 3155 4055 rootdeY 0228 1616 1618 4695 SIGSEG 0124 2815 4073 0765 1354 1445
4059 6926 6927 6934 7728 SIGSYS 0125 2781 4074 SSR2 0760 1446
F:7 2612 2679 3188 3347 rootdir 0206 1616 1617 7533 SIGTRC 0118 2740 4053 4068 SST ART 7988 8514
4058 4061 ROOTINO 0106 1616 1618 7297 SINCR 0138 4143 SSTOP 0387 1993 3253 3301
!'ablkno 4773 4788 4789 RPS 2613 2679 4057 4060 sleep 1955 1968 2066 3038 4026 4173
!'.lb 1. m:1<. 0235 6253 6256 6454 4262 3314 4182 4190 4943 SSWAP 0394 1907 2240 2241
6456 6504 6506 rrkbuf 5387 5479 5486 4955 4990 5167 5204 2286 4479
4775 4789 4790 4791 rsr 2315 5215 5297 5316 5994 SSYS 0392 1592 1992 2007
4793 4794 4795 runin 0218 1954 1955 2080 6963 7007 7074 7289 start 0521 0522 0611 0612
7971 8297 8344 8356 2081 2082 3820 3821 7790 7838 7870 8225 0614
8386 3822 8287 8563 8660 8693 stat 2930 6028
!'br 2316 run out 0219 1967 1968 2143 8755 8989 stat1 6021 6036 6045
ReOM 5094 5112 2144 2145 4387 4388 SLOAD 0391 1592 1862 1961 sti!lte 2937 3428
!'dfls 5196 5206 4389 1992 2007 2023 2046 stop 3999 4016
RDHENB 8014 8051 8084 8614 0220 0770 0788 2142 2143 2208 4385 str 2433 2436
8659 8692 8732 2166 2196 3807 SLOC" 0393 1992 2007 4379 strat 5259 5261 5313
!'dw!' 5713 5722 5731 RW 0317 1684 1690 1707 • 4385 4466 4468 5312 STRC 0395 3170 3224 3309
!'ead 2915 5711 1711 5317 3998 4028 4169
,'eadi 3090 3142 4464 5754 rw 5259 5299 6672 6685 sloop 1953 2004 2014 stty 2943 8183
6221 7797 6689 6702 6"716 6722 SMAPSIZ 0142 0204 slJbyte 0807 0827 3161 6523
F~EADING 8611 8724 8726 sayfp 0888 0889 2698 slTtount 2933 6086 slJibyte 0809 0826 9067
!'e.ldF' 5748 7758 sayu 0724 0725 1889 1905 SITtP 6090 6102 6108 61.09 SIJiWOI'd 0813 0860 4240 4242
!'eslc)c: 0237 1011 1025 1038 2189 2281 2284 2846 6111 6121 6122 6123 su!ltount 2934 6144
1148 2677 3186 4258 4476 4477 6124 6125 6126 6127 SIJres 1724 1739 2229 2295
f,ESET 5367 5461 sbreak 2929 3354 6128 SIJser 3431 3444 3465 3500
,'et!'y 1840 1844 1850 schar 1552 4097 4101 7679 sp 2693 2811 3725 4136 3522 3579 5921 5957
"etlJ 0724 0740 2193 2228 sched 1637 1940 4137 4141 4143 6800 6811
2294 SCHMAG 370"7 3814 3815 splO 1292 1293 1976 2022 suword 0811 0861 0864 3156
,'e;,:i.t 2913 3205 seek 2931 5861 2079 2092 4944 4947 3159 3164 3661 4057
"fp 6646 6648 6649 6650 sep 1650 1654 1677 1698 4956 4959 4991 5170 4058 4247 4249 6055
6655 6656 6657 1714 3023 3094 3100 5218 5245 5320 5416 6059 8175 8176 8177
RHHCOM 5121 51.41 3118 3151 5996 8228 8289 8565 SW 0166 2391 3416
I'h~;tart 5123 SET£! 2660 2734 8676 8697 8759 8993 SWAIT 0383 1993 2077 3975
RHWCOM 5120 5142 setgid 2958 3460 9037 9070 swap 2034 2042 4380 4467
F:KADDli: ~)363 setpri 2156 2823 3818 3828 spl1 1292 1297 3803 5196
,'k.lddl' 5420 set res 1089 1099 1117 1120 sp14 1292 1302 8672 8686 swar-,dey 0229 3237 3282 4696
RKADDR 5447 1196 8757 8991 5207 5212
rkaddr 5447 set run 2123 2134 3254 3310 sp15 1292 1303 3766 5408 swaper' 2035 2043 2050
RKADDR 5459 5460 5461 5462 3976 4188 8222 8263 8283 8559 swap!ltap 0204 1583 2044 3234
I'f.'.ba 5381 setuid 2935 3439 sp16 1292 1308 1958 1990 3283 4375 4408 4457
!''''.CS 5379 5459 5461 5462 sstty 8171 81.91 8201 2075 2088 4886 4940 swbuf 4721 5200 5207 5208
!''''.del 5~582 544"7 SIDL 0385 1903 4952 4988 5007 5164 5209 5210 5211 5212
""'.ds 5377 5460 sis 3949 3955 3963 3968 5201 5213 5234 5294 swplo 0231 1583 4697
rk£!1' 5378 5460 3972 5314 swtch 0770 0791 2084 2093
I'f.'.int I' 0576 0577 5451 SIGBUS 0123 2722 4072 spI7 1292 1313 3854 5983 2178 2287 3256 4027
"ki.o 0544 0577 SIGEMT 0120 2748 4070 9028 9061 4480
May 26 15:45 UNIX Operatin~ System Source Code Cross Reference Listin~ Pa~e 7
SWTED 0396 3302 3303 3309 7218 7219 7226 7357 8390 8399 8412 8440 update 2420 3489 6150 7201
4187 7392 7393 8452 8463 8468 8586 lIpdloci<. 0234 1559 7207 7209
sync 2948 3486 timeout 3845 8594 7229
SYS 2661 2759 TIMEOUT 7984 8491 8518 7937 8049 8304 8585 I.Jser 0413
S~lsent 2667 2670 2696 2754 timeout 8524 8593 USER 2662 2700 2721 2733
2755 2761 2910 TIMEOUT 8525 7930 8074 8075 8223 2739 2743 2747 2751
~;ZOMB 0386 3243 3280 times 2955 3656 8225 8259 8261 8414 2796 2810
s_flock 5570 6127 6936 6962 tmt,ab 4727 4844 8478 8520 8560 8563 USIZE 0103 0636 0646 0662
6963 6972 6978 6979 to 6585 6586 659:L 7928 8260 8264 8287 1442 1560 1590 1628
7006 7007 7015 7022 tOI.Jt 0214 3434 3804 3805 8292 8349 8355 8357 1662 1682 3129 3131
7023 7214 5989 5990 5991 5992 8358 3133 3370 4116 4119
5572 6983 7005 7026 5994 t_speeds 7941 8583 8591 4233 4459 4467 4473
7084 7144 7213 7217 trap 0512 0513 0514 0515 t_state 7938 8045 8046 8059 0452 2701 2812 3155
s .. f rec? 5567 6967 6976 7012 0516 0517 0518 0538 8224 8285 8491 8514 3187 3188 3208 3281
7019 7025 0547 0548 0549 0555 8518 8525 8541 8556 3297 3304 3305 3335
~; .. _fs:i.;:·:e 5564 7047 0752 0754 0755 0762 8562 3344 3347 3416 3423
s_i 1 DCI<. 5571 6126 6937 7073 2693 u 0646 0659 0662 0744 3424 3432 3433 3443
7074 7094 7116 7117 trapl 2771 2841 1440 1441 3455 3456 3464 3475
7139 7213 trf 5804 5813 5824 uO 1067 1096 3476 3482 3497 3623
s_i.node 5569 7077 7107 7143 TTHIWAT 7961 8560 ul 1067 1189 3637 3825 4055 4057
s_isize 5563 7047 7096 TTIF'RI 7951 8287 1J2 1067 1190 4058 4059 4060 4061
5565 6965 6967 6971 TTLOWAT 7962 8074 u3 1067 1191 4079 4184 4191 4258
6975 6987 7010 7011 TTOF'RI 7952 8225 8563 u4 1067 1087 4262 5736 5758 5831
7014 7018 7020 7025 ttrbuf 8157 u5 1067 1071 1075 1097 5850 5853 5866 5986
7175 7179 ttrcsr 8156 1.16 :1.067 1069 6018 6073 6830 7736
5568 7076 7077 7107 ttread 8063 8535 1.17 1067 1192 7744 7745 8206
7108 7113 7118 7141 ttrstrt 8486 8524 ub 6045 6055 6056 6059 0440 2763 2766 2770
7143 7176 7180 ttstart 8073 8363 8492 8505 6060 3052 3056 3085 3095
5573 6128 6754 6938 8561 8568 UBMAF' 0311 1573 1574 5175 3096 3097 3099 3101
7214 7383 tttbl.Jf 8159 8522 5177 3105 3116 3117 3140
s .. time 5574 6939 6940 7218 tttcsr 8158 8518 l.Jchar 3026 3034 3513 3515 3141 3208 3297 3364
7219 ttwrite 8067 8550 3541 3543 5768 5770 3568 3569 3581 3582
tOO 1056 1059 tty 7926 8015 8025 8056 5784 5786 5912 5914 3618 3624 3649 3661
tOl 1056 1079 1085 1101 8071 8080 8092 8218 5928 5955 5958 6031 3662 3670 3671 3672
t,02 1056 1102 8220 8253 8255 8275 6033 6091 6097 6184 3673 4075 4079 4168
t03 1056 1103 8279 8334 8337 8374 6186 6794 6796 7689 4174 4185 4186 4439
t04 1056 1104 8377 8488 8506 8509 UDSA 0308 5306 4455 4461 5743 5744
t05 1056 1105 8536 8538 8551 8553 ufalloc 6076 6824 6852 5756 5758 5773 5774
t06 1056 1106 TTYHOG 7963 8349 lIid 3441 3443 3444 3445 5790 5873 5875 5876
t07 1056 1093 ttyinput 8087 8333 3446 3447 5880 5927 5966 5969
UO 1057 1062 ttyoutpu 8362 8373 8392 8403 urSA 0306 1563 1599 1745 6021 6036 6096 6113
t11 1057 1110 8413 8566 1750 1763 5306 9026 6128 8174 8187 8188
t12 1057 1111 ttYstty 8094 8577 9029 9032 9035 9059 8189 8190 8590
t13 1057 1112 t_addr 7932 8044 8082 8513 9062 9065 9068 0425 3085 3139 3525
t14 1057 1113 t_canG 7929 8258 8321 8543 UISAO 0678 0680 0690 0698 4115 4121 4463 5269
U5 1057 1114 8544 0701 0719 1451 5743 6372 6374 6376
t,16 1057 1107 t_char 7940 UISA1 0699 0702 0718 1452 6381 6522 6523 6530
ti7 1057 1140 1188 t_col 7935 8393 8423 UISD 0304 1561 1600 1755 6549 6550 6557 7488
TBDELAY 7975 t_delct 7934 8265 8284 8294 1760 1763 9027 9030 9050
TBIT 2615 4060 8359 9036 9060 9063 9069 0428 1618 1619 1883
4306 4314 4436 7942 8033 U!SDO 0681 0.',82 0689 0703 3232 3554 3555 7531
tim 3845 3851 7936 8048 8299 8584 0705 0717 1453 0426 3086 3141 3526
time 0213 3423 3424 3432 8592 UISD1 0704 0706 0716 1454 4116 4122 4461 5273
3433 3801 3802 3804 7931 8047 8297 8309 UMODE 2659 2699 3706 3788 5291 5310 5322 5744
3806 5984 5985 5988 8336 8341 8342 8344 3824 5756 5758 6230 6241
5989 6050 6939 6940 8353 8356 8361 8386 unlink 2922 3510 6262 6290 6296 6319
Ma~ 26 15:45 UNIX Operatins S~stem Source Code Cross Re~erence Listins PaSe 8
6383 6527 6531 6546 0438 1876 3227 5835 8580 8582 8583 8584
6554 7486 7589 7600 5853 6078 6626 6829 8585 8586 8590 8591
7639 7811 7818 7846 6856 7740 8592 8593 8594
7847 9048 9049 0435 5935 5936 7459 VTDELAY 7977 8463
u_cstime 0451 3291 3292 3293 7489 7490 7606 wait 2919 3270
3336 3337 0424 1593 1743 1752 WAITING 8610 86S7 8658 8721
u_cutime 0450 3294 3295 3296 1859 1891 1917 2071 wal<.elJp 2082 2113 2145 3197
3339 3340 2273 2793 2818 2823 3248 3249 3434 3805
u_dbuf 0429 7484 7570 7572 3134 3170 3174 3224 3808 3822 4025 4195
7576 7645 7646 3240 3278 3314 3326 4213 4389 4877 4880
u_dent 0434 3519 3525 3527 3376 3388 3446 3482 5031 5188 5217 5319
7482 7483 7488 7636 3502 3625 3626 3638 6652 6653 6979 7023
7640 7646 7664 3794 3828 3996 4021 7117 7778 7852 7891
u_dirp 0430 2770 4100 5927 4048 4119 4148 4149 8075 8260 8261 8357
6096 7682 7693 4169 4175 4209 4273 8734 8744 8982
u_dsize 0442 3149 3152 3369 4401 4402 4448 4465 WCOM 5093 5114
3371 3373 4146 5291 4478 4479 5312 5317 wdir 5940 7467 7477
u_error 0419 1728 2752 2773 7828 8031 8032 wflushtt 8058 8217 8589
2774 2775 2777 2857 0453 3127 3670 3671 WLO 5373
3064 3092 3102 3106 3672 3673 3790 3791 1010 0316 1762
3317 3330 3547 3620 IJ_Gsav 0445 2106 2846 WOPEN 7985
3652 4052 4099 4103 u_rSid 0423 3465 3467 3475 write 2916 5720
4127 4177 4193 5326 IJ_rsav 0415 1889 2189 2281 writei 3528 4118 4124 5755
5343 5344 5740 5788 4476 6276 7489 7848
5819 5822 5833 5870 0422 3444 3447 3455 writep 5749 7805
5918 5930 5933 5937 4111 ;.:1 2340 2346
5960 5964 6094 6114 0418 3089 3091 4117 2340
6117 6135 6152 6157 4123 5745 6372 6521 :-:3 2340
6163 6190 6193 6262 6548 7487 7587 :-:4 2340
6307 6319 6378 6424 0444 3151 3152 3365 2340
6524 6551 6569 6630 3371 4146 5276 5306 :-:6 2340
6727 6755 6759 6778 0447 2734 3183 3225 :-:7 2340
6816 6833 6863 6929 3623 3624 4003 4051 :-:8 2340
6989 7121 7311 7538 4054 :-:9 2340
7548 7560 7571 7580 0446 1905 2242 2284 :-:a 2340
7612 7695 7827 8027 4477 ;-:alloc 3130 4433
8172 8210 8654 8751 0443 3150 3152 3370 ;-:b 2340
8854 9038 9057 3371 3376 3378 3389 :-:br 2318 2399
u_fsav 0416 3189 4255 4141 4143 4146 4150 :-:c 2340
u_Sid 0421 3177 3466 3476 4156 5292 :-:ccdec 4378 4403 4490
6771 7466 u_stime 0449 3293 3338 3793 ;-:free 3128 3233 4398
u_ino 0432 3519 3527 7482 u_tsize 0441 3148 3152 3366 >:swap 1906 2024 2285 4368
7640 7664 3371 4146 5275 4478
u_intfls 0454 2772 2845 2848 0420 3172 3173 3445 XTABS 7967 8047 8390
u_name 0433 7483 7646 3456 3567 3646 4111 :-:_caddr 1753 2036 4309 4497
u_offset 0427 3087 3088 3140 6763 6769 6798 6814 ;-:_ccoIJnt 1881 1980 2033 2039
3524 4113 4114 4462 7465 4313 4453 4475 4483
5309 5751 5752 6239 0436 1665 1678 1694 4495 4496
6240 6244 6294 6295 1699 1715 1716 1717 1880 4312 4404 4447
6309 6313 6315 6316 1744 4452
6382 6528 6529 6555 0437 1666 1719 1720 2034 4308 4409 4457
6556 7585 7586 7608 1721 1754 4467
7622 7626 7636 7638 0448 3296 3341 3660 4311 4405 4407 4442
7642 7795 7796 7798 3789 4446 4454
7844 7845 7846 9024 v 8090 8091 8094 8167 1981 2034 2037 4310
9025 9051 9055 9056 8170 8201 8202 8213 4408 4456 4497
Hay 24 12:28 1976 unix/param.h Page 1 Ms\,l 24 12:28 1976 unix/param.h Page 2
Reproduced under licence from the Western Electric Compan\,l, NY Reproduced under licence from the Western Electric Company, NY
Copyright. J. Lions, 1976 Copyright, J. Lions, 1976
Sheet 01 Sheet 01
Maw 24 12:28 1976 unix/swstm.h Pa~e 1 Maw 24 12:28 1976 unix/swstm.h Page 2
int m_dev'
int *m_b,Jfp;
int *m_inodp'
1* device mounted *1
1* pointer to superblock *1
1* pointer to mounted on inode *1
0227 0277 } mount[NMOUNTJ;
0228 int rootdev; 1* dev of root see confoc *1 0278 1* ------------------------- II
0229 int swapdev; I I dev of swap see conf.c I I 0279
0230 0280
0231 int swplo; 1* block number of swap space *1 0281
0232 int nswBP; I I size of swap space I I 0282
0233 0283
0234 int updlocld I I lock for swnc *1 0284
0~!35 int rablock; I I block. to be read ahead 0285
0236 *' 0286
0237 char regloc[J; I I locs. of saved user re~isters 0287
0238 (see trap.c) *1 0288
0239 0289
0240 0290
0241 1* ------------------------- 0291
0242 *' 0292
0243 0293
0244 0294
0245 0295
0246 0296
0247 0297
0248 0298
0249 0299
Reproduced under licence from the Western Electric Companw, NY Reproduced under licence from the Western Electric Companw, NY
Copwright, J. Lions, 1976 Copwrisht, J. Lions, 1976
Sheet 02 Sheet 02
May 24 12:28 1976 unix/se~.h Pase 1 May 24 12:28 1976 unix/proc.h Page 1
0300 0350 1*
0301 1* kt-ll addresses and bits *1 0351 * One structure allocated per active
0302 0352 * process. It contains all data needed
0303 0353 * about the process while the
0304 idefine UISD 0177600 1* first 'Jser I-space descriptor 0354 * process may be swapped out.
0305 register *1 0355 * Other per process data (user.h)
0306 idefine UISA 0177640 1* first user I-space address 0356 * is swapped with the process.
0307 reSister *1 0357 *1
0308 idefine UDSA 0177660 1* first 'Jser [I-space address 0358 struct proc
0309 reSister *1 0359 {
0310 0360 char p_stat;
0311 idefine UBMAP 0170200 1* access to 11170 unibus map *1 0361 char p_fla~H
0312 0362 char p_pri; 1* priority, negative is high *1
0313 0363 char p_sis; 1* signal n'JII.ber sent to this process *1
0314 0364 char p_'Jid; 1* 'Jser id, used to direct tty signals *1
0315 idefine RO 02 1* access abilities *1 0365 char p_time; 1* resident time for sched'J ling *1
0316 idefine WO 04 0366 char p_cpu; 1* cpu usage for schedulin~ *1
0317 idefine RW 06 0367 char p_nice; 1* nice for sched'JI ing *1
031.E1 #define ED 010 1* expand segment downwards *1 0368 int p_ttyp; 1* controlling tty *1
0319 0369 int p_pid; 1* 'JniG'Je process id *1
0320 1* ------------------------- *1 0370 int p_ppid; 1* process id of parent *1
0321 0371 int p_addr; 1* address of swappable image *1
0322 int 1* 11/40 KISA6; 11/45 KDSA6 *1 0372 int p_size; 1* size of swappable image (*64 bytes) *1
0323 0373 int p_w~han;l* event process is awaiting *1
0324 0374 int *p_ te:-:'!:.p; 1* pointer to te:-:t struct'Jre *1
0325 0375
0326 0376 } procCNPROCl;
0327 0377 1* ------------------------- *1
0328 0378
0329 0379 1* stat codes *1
0330 0380
0331 0381 1* null 0 not assigned *1
0332 0382 idefir.e SSLEEP 1 1* sleeping on high priority *1
0333 0383 idefine SWAIT 2 1* sleeping on low priority *1
0334 0384 idefine SRUN 3 1* running *1
0335 0385 idefine SIDL 4 1* process is being created *1
0336 0386 tdefine SZOMB 5 1* process is being te rlloi nated *1
0337 0387 tdefine SSTOP 6 1* process being traced *1
0338 0388
0339 0389 1* flag codes *1
0340 0390
0341 0391 tdefine SLOAD 01 1* in core *1
0342 0392 tdefine SSYS 02 1* sched'Jling process *1
0343 0393 "'define SLOCK 04 1* process cannot be swapped *1
0344 0394 "'define SSWAP 010 1* process is being swapped o'Jt *1
0345 0395 "'define STRC 020 1* process is being traced *1
0346 0396 "'define SWTED 040 1* another tracing flag *1
0347 0397
0348 0398
0349 0399
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
CoPYright, J. Lions, 1976 Copyright, J. Lions, 1976
Sheet 03 Sheet 03
Maw 24 12:29 1976 unix/user.h PaSe 1 Maw 24 12:29 1976 unix/user.h PaSe 2
*** 1* *1
0403 Contains all per process data 0453 int u_prof[4J; profile arsuments
0404 that doesn't need to be referenced 0454 char u_intfl.; 1* catch intr fran, sws *1
0405 while the process is swapped. 0455 f* kernel stack per user
0406 *
The user block is USIZE*64 bytes 0456
* e:o(tends from u + USIZE164
0407 *
Ions; ~esides at virtual kernel 0457 * backward not to reach here
**
04013 loc 140000; contains the swstem 0458 *I
0409 stack per user. is cross referenced 0459 } u;
0410 * with the proc structure for the 0460 f* ------------------------- *1
0411 * same process. 0461
0412 *! 0462 f* u_error codes *I
0413 struct user 0463 f* See section 'INTRO(II)' of
0414 { 0464 * the UNIX F' raS ramn,e r ' s n,anual
04:L5 int u_rsav[2J. 1*save r5,r6 when exchansins stacks *1 0465 for the meaninss of these codes. *f
0416 int u_fsav[25J; 1* *1
save fp reSisters 0466 "'define HAULT 106 *
0417 1* rsav and fsav must be first in structure *1 0467 tdefine EPERM 1
0418 char u_seSfIS; 1*flas for 10; user or kernel space *1 0468 tdefine ENOENT 2
04:[9 char u_error' 1* *1
return error code 0469 tdefine ESRCH 3
0420 char u_uid; 1*
effective user id *1 0470 tdefine EINTR 4
0421 chaT' 'Lsid; 1*
effective Sroup id *1 0471 tdefine EIO 5
0422 char u_ruid; 1*
real user id *1 0472 tdefine ENXIO 6
0423 c~har u_rsid; 1*
real Sroup id *1 0473 "'define E2BIG 7
0424 i nt u __ p rocP, 1*pointer to proc structure *1 0474 "'define ENOEXEC 8
0425 cha T' *u_base; 1*base address for 10 *1 0475 :l!:define EBADF 9
0426 cha r *u_.count; 1*bwtes remaining for 10 *1 0476 tdefine ECHILD 10
04~~7 char *u_offset[2J; 1*
offset in file for 10 *1 0477 tdefine EAGAIN 11
04213 int *u_cdir' 1* pointer to inode of current directorw *1 0478 tdefine ENOMEM 12
0429 char u_dbuf[DIRSIZ]; 1*
current pathname component *1 0479 tdefine EACCES 13
0430 char *u_dirp' 1*current pointer to inode *1 0480 tdefine ENOTBLK 15
0431 struct { 1*
current directorw entrw *1 0481 tdefine EBUSY 16
0432 int u_ino; 0482 tdefine EEXIST 17
0433 char u_name[DIRSIZ]; 0483 tdefine EXDEV 18
0434 } u_dent; 0484 tdefine ENO[IEV 19
0435 int *u_pdir; 1*inode of parent directorw of dirp *1 0485 tdefine ENOTDIR 20
0436 int u_uisa[16]; 1*prototwpe seSmentation addresses *1 0486 tdefine EISDIR 21
0437 int u_uisd[16]; 1*prototwpe seSmentation descriptors *1 0487 tdefine EINVAL 22
0438 int u_ofile[NOFILE]; 1*
pointers to file structures of 0488 tdefine ENFILE 23
0439 *1
open files 0489 tdefine EMFILE 24
0440 int u_ars[5]; 1*
arSuments to current swstem call *1 0490 tdefine ENOTTY 25
0441 int u_tsize' 1* *1
text size (*64) 0491 tdefine ETXTBSY 26
0442 int u_dsize; 1* *1
data size (*64) 0492 idefine EFBIG 27
0443 int u_ssize; 1* *1
stack size (*64) 0493 tdefine ENOSPC 28
0444 int u_sep; 1*
flaS for I and D separation *1 0494 tdefine ESF'IPE 29
0445 int u_Gsav[2]; 1*label variable for Guits & interrupts *1 0495 tdefine EROFS 30
0446 int u_ssav[2J; 1*
label variable for swapp ins *1 0496 tdefine EMLINK 31
0447 int u_siSnal[NSIG]; 1*
disposition of sisnals *1 0497 :tdefine EPIPE 32
0448 int u_utime; 1*
this process user time *1 0498
0449 int u_stime; 1*
this process swstem time *1 0499
Reproduced under licence from the Western Electric Companw, NY Reproduced under licence from the Western Electric Companw, NY
Copwrisht, J. Lions, 1976 Copwrisht, J. Lions, 1976
Sheet 04 Sheet 04
May 24 12:29 1976 unix/low.s Page 1 Ma~ 24 12:29 1976 unix/low.s Page 2
klin; br4
"-.lou; br4
0575
0576
0577
.slobl
rkio:
_rkintr
Jsr rO,call; _rkintr
0528 0578
0529
0530
0531
· = 70~.
pcin; br4
pcou; br4
0579
0580
0581
0532 0582
0533 , == 10()~, 0583
0534 "-.wlp; br6 0584
0535 kwlp; br6 0585
0536 0586
0537 , = 114~ • 0587
0538 trap, br7+7. I 11/70 parity 0588
0539 0589
0540 - 200~. 0590
0541 Ipo,-d br4 0591
0542 0592
0543
0544
0545
· = 220",
rldo. br5
0593
0594
0595
0546
0547
0548
· :: 240".
trap; br7+7.
trap; br7+8.
I
I
programmed interrupt
floating point
0596
0597
0598
0549 trap; br7+9. I segmentation violation 0599
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
Copyright, J. Lions, 1976 CoPYright, J. Lions, 1976
Sheet 05 Sheet 05
Ma~1 24 12:29 1976 uni )·:/m40. s POIse 1 MOl!'! 24 12:29 1976 un h:/m40. s Pase 2
Reproduced under licence from the Western Electric Compan!'!, NY Reproduced under licence from the Western Electric Compan!'!, NY
CoP!'!risht, J. Lions, 1976 CoP!'!risht, J. Lions, 1976
Sheet 06 Sheet 06
Ma~ 24 12:29 1976 'Jni>:/m40.s Pase 3 Ma~ 24 12:29 1976 'Jnh:/Il,40.s Page 4
Reproduced under licence from the Western Electric Compan~, NY Reproduced under licence from the Western Electric Company, NY
CoPyrisht, J. Lions, 1976 Cop~risht, J. Lions, 1976
Sheet 07 Sheet 07
Ma!:l 24 12:29 1976 uni:-:/m40. s PaSe 5 May 24 12:29 1976 unix/m40.s PaSe 6
0810
0811
1* -------------------------
• slobl _f'.Jwor-d • _sl.Jword
*1 0860
0861
_suiword:
_suward:
0812 1* --------------------------
_fuiword, _sl.Jiword
*1 0862
0863
mov 2(sp),r1
4 ( sr- ) .1'0
08B .slobl ITIOV
0814 _ fl.Jib!:lte: 0864 suword:
0815 _fub!:lte! 0865 jST~ pc.pword
0816 moy 2(sp).rl 0866 rts pc
0817 bic $1,1'1 0867
0818 Jsr pc,sword 0868 pword:
0819 cmp r1,2(sp) 0869 mov PS.-(SF')
OB20 beG if 0870 bis $340,PS
0821 swab 1'0 0871 mov nofaul t. -- (sp)
0822 1! 0872 mov $err,nofault
0823 bic $!377,rO 0873 mov rO,-(sp)
0824 rts PC 0874 ITltpi (1'1)
OB25 0875 1:
OB26 _suib!:lte! 0876 mov (sp)+.nofault
0827 _subste: 0877 mov (sp) -j-, F'S
0828 ITIOY 2(sp),r1 0878 rts PC
082';> bic $1,r1 0879
0830 Jsr F'C, Sword 0880 err:
0831 ",OY rO,-(sp) 0881 mov (sp)+,nofal.Jlt
OS;32 cmp r1.4(sp) 0882 mov (sp)+,PS
0833 beG If 0883 tst (spH
0834 IIloyb 6(sp),1(sp) 0884 mov $-l,rO
0835 br 2f 0885 rts PC
0836 1: 0886
0837 rrloyb 6(sp),(sp) 0887 1* ------------------------- *1
0838 2: 0888 .slobl
0839 mov (sp)+,rO 0889 _savfp:
0840 Jsr pc,pword 0890 _displa~J:
0841 clr rO 0891 rts PC
0842 rts PC 0892
0843 0893 1* ------------------------- *1
0844 _fuiword: 0894 .slobl
0845 _fuword: 0895 _incupc:
0846 mov 2(sp),r1 0896 mov r2,-(sp)
0847 fuword: 0897 mov 6(sp)n'2 1 base of prof with base,lenS,off,scale
0848 Jsr pc.Sword 0898 mov 4(sp),rO / PC
0849 rts PC 0899 sl.Jb 4(r2hrO I offset
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric COITIPan!:l, NY
CoPYrisht, J. Lions, 1976 CoPYrisht, J. Lions, 1976
Sheet 08 Sheet 08
Ma~ 24 12:29 1976 unix/m40.s Page 7 Ma~ 24 12:29 1976 unix/m40.s Page 8
Reproduced under licence from the Western Electric Compan~, NY Reproduced under licence frolll the Western Electric COIIIPan~, NY
Cop~risht, J. Lions, 1976 Cop~risht, J. Lions, 1976
Sheet 09 Sheet 09
Maw 24 12:29 1976 unix/m40.s Pa~e 9 Maw 24 12:29 1976 unix/m40.s Pa~e 10
Reproduced under licence from the Western Electric Companw, NY Reproduced under licence from the Western Electric Companw, NY
Copwri~ht, J. Lions, 1976 Copwri~ht, J. Lions, 1976
Sheet 10 Sheet 10
Ma~ 24 12:29 1976 'Jni:·:/m40. s Page 11 Ma~ 24 12:29 1976 uni:{/m40.s Page 12
Reproduced under licence from the Western Electric Compan~, NY Reproduced under licence from the Western Electric Compan~. NY
COP\:Iright, J. Lions, 1976 Cop~right, J. Lions, 1976
Sheet 11 Sheet 11
May 24 12:29 1976 unix/m40.s PaSe 13 May 24 12:29 1976 urti:·:/m40. s Pase 14
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
Copyrisht, J. Lions, 1976 Copyrisht, J, Lions, 1976
Sheet 12 Sheet 12
Ma~ 24 12:29 1976 unix/m40.s Pa~e 15 Ma~ 24 12:29 1976 unix/m40.s Pa~e 16
(1'0)
1330 sub 6(51"),1'0 1380 tstb
1331 sub 8(51"),1'1 1381 b~e 2b
1332 sbc 1'0 1382 tst ( rO)t
1.333 bse 1f 1383 b~e 1b
1334 cmp 1'0,$-1 1384 reset
1335 bne 2f 1385
1336 cmp 1'1,$-512. 1386 I end of file and 1001"
1337 bhi 3f 1387
1338 2: 1388 11,0 V $60007,-(1'0)
1.:''139 mov $-512.,1'0 1389 br
1340 rts pc 1390
1341 1: 1391 1* ------------------------- *1
1342 bne 2f 1392 .slobl _ldiv
1. :~43 cmp 1'1.$512. 1393 _ldiv:
1.:,44 blo 3f 1394 clr 1'0
1345 2: 1395 mov 2(sp),rl
1346 mov $512.,1'1 1396 div 4(sp),rO
1347 ~5 : 1397 rts pc
1348 mov 1'1,1'0 1398
1.:549 T'tS PC 1399 1* ------------------------- *1
Reproduced under licence from the Western Electric Companw, NY Reproduced under licence from the Western Electric Compan~, NY
Copwrisht, J. Lions, 1976 Copwrisht, J. Lions, 1976
Sheet 13 Sheet 13
Maw 24 12:29 1976 unix/m40.s Pa~e 17 Maw 24 12:29 1976 unix/m40.s Pase 18
Reproduced under licence from the Western Electric Companw, NY Reproduced under licence from the Western Electric Company, NY
CoPYri~ht, J. Lions, 1976 Copyright, J. Lions. 1976
Sheet 14 Sheet 14
Ma~ 24 12:29 1976 unix/main.c PaSe 1 Ma~ 24 12:29 1976 unix/main.c PaSe 2
1515 *1 1565
1566
break;
clearseSCi);
1516 int icode[]
1517 { 1567 ma:·:mem++ ;
1518 0104413, 1*
s~s exec; init; initp *1 1568 mfreeCcoremap, 1, i);
1519 0000014, 1569 itt;
1520 0000010, 1570 }
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
Cop~risht, J. Lions, 1976 CoPyrisht. J. Lions, 1976
Sheet 15 Sheet 15
May 24 12:29 1976 unix/main.c Pa~e 3 May 24 12:29 1976 unix/main.c Pa~e 4
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
Copyright, J. Lions, 1976 Copyright, J. Lions, 1976
Sheet 16 Sheet 16
May 24 12:29 1976 unix/main.c Pa~e 5 May 24 12:29 1976 unix/main.c Pase 6
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
CoPYrisht, J. Lions. 1976 CoPYrisht, J. Lions. 1976
Sheet 17 Sheet 17
May 24 12:30 1976 unix/slp.c Pase 1 May 24 12:30 1976 unix/slp.c PaSe 2
***
1821 but in fact the code that runs is that of swtch. 1871 /*
1822 The subtle implication of the returned value of swtch 1872 * make duplicate entries
1823 (see above) is that this is the value that newproc's
*
caller in the new process sees.
1873
:L874
* where needed
1824 */
1825 */ 1875
1826 newproc() 1876 farerip = &u.u_ofileCO]; rip <: &u.u_ofileCNOFILE];)
1827 { 1877 if«rpp = *riptt) != NULL>
1828 int al, a2; 1878 rpp-)f_count+t;
1829 struct proc *p, *UP; 1879 if«rpp=up-)p_textp) != NULL) {
1.El30 reSister struct proc *rpp; 1880 rpp-):·:_col.mttt;
lEl31 reSister *rip, n; 1881 rpp->:·LcCOIJnttt;
l.8~~2 1882 }
1.833 ? = NULU 1883 u.u_cdir-)i_counttt;
1834 /* 1884 /*
1835 * First, Just locate a slot for a process 1885 * Partially simulate the environment
1836 *
and copy the useful info fro·m this process into it.
* The panic ·cannot happen' because fork has already
1886
1887
* of the new process so that when it is actuallY
* created (by copyins) it will look risht.
1837
1838 *
checked for the existence of a slot. 1888
1889
U
savu(u.u_rsav);
1839 U
1840 retrY: 1890 rpp == p;
1841 ITIPidtH 1891 u.u_procp = rpp;
1842 if(mpid <: 0) { 1892 rip = UP;
1843 mpid 0; 1893 n = rip-)p_size;
1El44 soto retrY. 1894 a1 = rip-)p_addr;
1845 } 1895 rpp-)p_size = n;
1846 for(rp? = &proc[O]; rpp <: &proc[NPROC]; rpptt) { 1896 a2 = malloc(coremap, n);
l.847 if(rpp-)p_stat == NULL && p==NULL) 1897 /*
1848 p = rpp;
if (rpp-)p_pid==mpid)
1898
1899
** new
If there is not enouSh core for the
process, swap out the current process to
1849
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
CopyriSht, J. Lions, 1976 Copyright, J. Lions, 1976
Sheet 18 Sheet 18
Maw 24 12:30 1976 unix/slp.c Pa~e 3 Maw 24 12:30 1976 unix/slp.c PaSe 4
1900
1901
* ~enerate the copw. 1950
1951 go to loop;
*1
1902 if(a2 == NULL> { 1952
1903 rip-)p_stat = S1DL; 1953 sloop:
1904 rpp-)p_addr = al; 1954 runin+H
1905 savIJ(u.IJ_ssav) ; 1955 sleep(&runin, PSWP) ;
1906 xswap(rpp, 0, 0); 1956
1907 rpp-)p_fla~ =: SSWAP; 1957 loop:
1908 rip-)p_stat = SRUN; 1958 sp 16 ( ) ;
1909 } else { 1959 n = -1;
1910 1* 1960 for(rp = &proc[O]; rp < &proc[NPROC]; rp++)
1911 *
There is core, so Just copw. 1961 ifCrp-)p_stat==SRUN && (rp-)p_flag&SLOAD)==O &&
1912 *1 1962 rp-)p_time ) n) {
1913 rpp-)p_addr = a2; 1963 pI = rp;
1914 while(n--) 1964
1915 copwse~(a1++, a2++); 1965 }
1916 } 1966 if(n -1) {
1917 u.u_procp rip; 1967 runout++;
1918 ,'eturn(O) ; 1968 sleepC&runout, PSWP);
1919 } 1969 goto loop;
1920 1* *1 1970 }
1921 1971
1922 1* 1972 1*
1923 *
The main loop of the schedulin~ Cswappin~) 1973 * see if there is core for that process
1924 * process. 1974 *1
1925
1926
*
The basic idea is:
see if anyone wants to be swapped in;
1975
spIO() ;
1976
1927 *swap out processes until there is room; 1977
1928 ** swap him in; 1978 a = rp->p_size;
1929 reF'eat. 1979 ifCCrp=rp-)p_textp) != NULL)
1930 * Althoush it is not remarkablw evident, the basic 1980
1931 **synchronization here is on the runin fla~p which is 1981 a =+ rp->x_size;
1932 slept on and is set once per second bw the clock routine. 1982 ifCCa=mallocCcoremap, a)) != NULL)
1933
1934 ***
Core shufflin~ therefore takes place once per second. 1983
1984
~oto found2;
Reproduced under licence from the Western Electric Companw, NY Reproduced under licence from the Western Electric Company, NY
CopwriSht. J. Lions, 1976 Copyright, J. Lions, 1976
Sheet 19 Sheet 19
Maw 24 12:30 1976 unix/slp.c Pa~e 5 Maw 24 12:30 1976 unix/slp.c Pa~e 6
2000
2001
* oldest process in core 2050
2051
swaper:
panicC"swap error");
*1
2002 2052 }
2003 ifCn < 3) 2053 1* -------------------------
2004 ~oto sloop; 2054
2005 n = -1; 2055 1*
2006
2007
ror(r? = &procCOJ; rp ( &procCNPROC]; rptt)
if«rp-)p_fla~&(SSYSISLOCKISLOAD»==SLOAD &&
2056
2057 ** Give the processor till a wakeup occurs
UP
on chan, at which time the process
2008 Crp-)p_stat==SRUN II rp-)p_stat==SSLEEP) &&
rp-)p_time ) n) {
2058
2059
* The
enters the Queue at priority pri.
schedulin~
most important effect of pri is that when
2009
20l.0 2060 ** pri(O a signal cannot disturb the sleep;
2011 2061 if pri)=O signals will be processed.
2012 }
ifCn ( 2)
2062
2063
** premature
Callers of this routine must be prepared for
return. and check that the reason for
2013
201.4
rp p1;
soto sloop; 2064 * sleeping has Sone awaw.
2015 2065 *!
2016 2066 sleep(chan. pri)
2017 1* 2067 (
2018 * swap user OIJt 2068 re~ister *rp, s;
2019 *1 2069
2020 2070 s = PS-)inte~;
2021 f()und1: 2071 rp = IJ. u_p rocp;
202~~ splO(); 2072 if(pri )= 0) (
2023 rp-)p_fla~ =& NSLOAD; 2073 if(issi~(»
2024 xswapCrp,l. 0); 2074 ~oto psi~;
2025 so to loop; 2075 sp16();
2026 2076 rp-)p_wchan = chan;
2027 1* 2077 rp-)p_stat = SWAIT;
2028 * swap IJser in 2078 rp-)p_pri = pri;
2029 *1 2079 splO ( );
2030 2080 ifCrunin != 0) (
2031 found2: 2081 runin = 0;
2032 ifCCrp=p1-)p_textp)!= NULL) ( 2082 wakeupC&runin);
2033 ifCrp-)x_ccount == 0) ( 2083 }
2034 ifCswapCrp-)x_daddr, a, rp-)x_size, B_READ» 2084 swtchC);
2035 soto swaper; 2085 ifCissi90)
2036 rp->x_caddr = a; 2086 goto psi!;!;
2037 a =t rp->x_size; 2087 } else (
2038 } 2088 spI6C);
2039 rp-)x_ccoIJnttt; 2089 rp-)p_wchan = chan;
2040 } 2090 rp-)p_stat = SSLEEP;
2041 rp p1; 2091 rp-)p_pri = pri;
2042 ifCswapCrp->p_addr, a, rp->p_size, B_READ» 2092 splOC);
2043 ~oto swaper; 2093 swtchC);
2044 mfree(swapmap, (rp-)p_sizet7)/8, rp-)p_addr); 2094 }
2045 rp-)p_addr = a; 2095 PS-)integ = s;
2046· rp->p_fla~ =1 SLOAD; 2096 return;
2047 rp-)p_time = 0; 2097
2048 soto loop; 2098 1*
2049 2099 * If prioritw was low ()=o) and
Reproduced under licence from the Western Electric Companw, NY Reproduced under licence from the Western Electric Companw. NY
Copwright, J. Lions, 1976 Copwright, J. Lions. 1976
Sheet 20 Sheet 20
Ma~ 24 12:30 1976 unix/slp.c PaSe 7 Ma~ 24 12:30 1976 unix/slp.c Page 8
Reproduced under licence from the Western Electric Compan~, NY Reproduced under licence from the Western Electric Compan~, NY
Cop~risht, J. Lions, 1976 Cop~riSht. J. Lions, 1976
Sheet 21 Sheet 21
Ma~ 24 12:30 1976 unix/slp.c Pa~e 9 Ma~ 24 12:30 1976 unix/slp.c Pa~e 10
2200 1* 2250
2201 * Search for hi~hest-priorit~ runnable process 2251 1*
2202 *1 2252 * Chan~e the size of the datatstack re~ions of the process.
2203 i = NPROC; 2253 * If the size is shrinkin~, it's eas~-- Just release the
2204 do { 2254 * extra core. If it's ~rowin~, and there is core, Just
2205
2206 if(rp )=Iproc[NPROC])
2255
2256 **allocate it and cop~ the ima~e, takin~ care to reset
re~isters to account for the fact that the s~stem's
2207
2208
rp = &proc[O];
ifCrp-)p_stat==SRUN && Crp-)p_fla~&SLOAD)!=O) {
2257
2258
**stack has moved.
If there is no core, arran~e for the process to be
2209 ifCrp-)p_pri < n) {
p := rp;
2259 * swapped out after adjustin~ the size reGuirement--
2260 * when it comes in, enoush core will be allocated.
2210
2211 n = rp-)p_pri; 2261 * Because of the ssave and SSWAP fla~s, control will
2212 } 2262 * resume after the swap in swtch, which executes the return
221.3
2214
}
} while(.--i);
2263
2264
* from this stack level.
2215
2216
1** If no process is runnable, idle.
2265
2266
** After the expansion, the caller will take care of cop~in~
the user's stack towards or awa~ from the data ared.
221.7 *1 2267 *1
2218 if(p == NULL> { 2268 e;·:pand( newsize)
2219 p = rp; 2269 {
2220 idleC); 2270 int i, n;
2221 aoto loop; 2271 re~ister *p, al,
..')'") "/") } 2272
L~"''''
Reproduced under licence from the Western Electric Compan~, NY Reproduced under licence from the Western Electric Compan~, NY
Cop~ri~ht, J. Lions, 1976 Cop~risht, J. Lions, 1976
Sheet 22
May 24 12:30 1976 unixfprf.c PaSe 1 May 24 12:30 1976 unix/prf.c Page 2
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
CopYrisht, J. Lions, 1976 CoPYriSht, J. Lions, 1976
Sheet 23 Sheet 23
May 24 12:30 1976 unix/prf.c PaSe 3 May 24 12:30 1976 unix/prf.c PaSe 4
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
CopYrisht, J. Lions, 1976 Copyrisht, J. Lions, 1976
Sheet 24 Sheet 24
Maw 24 12:30 1976 unix/malloc.c Page 1 Ma~ 24 12:30 1976 unix/malloc.c Page 2
2500
2501 1*
* 2550 1*
2551 Free the previouslw allocated space aa
2502 *1 2552 *of size units into the specified map.
2503 2553 *Sort aa into map and combine on
2504 2554 *one or both ends if possible.
2505
1*
* Structure of the coremap and swapmap 2555 *1*
2506 * arraws. Consists of non-zero count 2556 mfree(mp, size, aa)
2507 * and base address of that manw 2557 struct map *mp;
2508 * contiguous units. 2558 {
2509 * (The coremap unit is 64 bwtes, 2559 register struct map *bp;
2510 * the swapmap unit is 512 b~tes) 2560
2561
register int t;
register int a;
2511 * The addresses are increasing and
2512 * the list is terminated with the 2562
2563 a = aa;
2513 * first zero count.
2514 *! 2564 for Cbp = mp; bp-)m_addr<=a && bp-)m_size!=O; bp+t) ;
2515 struct map 2565 if (bp)mp && (bp-1)-)m_addrt(bp-1)-)m_size a) {
2516 .{ 2566 (bp-1)-)m_size =t size;
2517 char *m_size; 2567 if (atsize == bp-)m_addr) {
2518 char *m_addr; 2568 (bp-1)-)m_size =t bp-)m_size;
2519 }; 2569 while Cbp-)m_size) {
2520 2570 bptt;
2521 2571 (bp-1)-)m_addr
2522 1* 2572 (bp-1)->ITI_size
2523 * Allocate size units from the given 2573 }
2524 * map. Return the base of the allocated 2574 }
2525 * space. 2575 } else {
2526 * Algorithm is first fit. 2576 if (atsize == bp-)ITI_addr && bp-)ITI_size) {
2527 *1 2577
2528 mallocCmp, size) 2578 bp-)ITI_size =t size;
2529 struct map *mp; 2579 } else if (size) do {
2530 { 2580 t = bp-)ITI_addr;
2531 register int a; 2581 bp-)ITI_addr = a'
2532 register struct map *bp' 2582 a = t;
2533 2583 t = bp->m_size;
2534 for (bp = mp; bp-)m_size; bptt) { 2584 bp-)ITI_size = size;
2535 if (bp-)m_size )= size) { 2585 bptt;
2536 a = bp-)m_addr; 2586 } while (size = t);
2537 bp-)m_addr =t size. 2587 }
2538 if «bp-)m_size size) 0) 2588
2539 do { 2589
2540 bptt; 2590
2541 Cbp-1)-)m_addr = bp-)m_addr' 2591
2542 } whileCCbp-1)-)m_size = bp-)m_size)' 2592
2543 return(a) ; 2593
2544 } 2594
2545 } 2595
2546 return(O); 2596
2547 } 2597
2548 1* ------------------------- 2598
2549 2599
Reproduced under licence from the Western Electric Companw, NY Reproduced under licence from the Western Electric COITIPanw. NY
Copwright. J. Lions, 1976 Copwright, J. Lions, 1976
Sheet 25 Sheet 25
Maw 24 12:35 1976 unix/reg.h Page 1 Maw 24 12:35 1976 unix/trap.c Page 1
Reproduced under licence from the Western Electric Companw, NY Reproduced under licence from the Western Electric Companw, NY
Copwright, J. Lions, 1976 Copyright, J. Lions, 1976
Sheet 26 Sheet 26
Ma~ 24 12:35 1976 unix/trap.c Page 2 Ma~ 24 12:35 1976 unix/trap.c Page 3
Reproduced under licence from the Western ~lectric Compan~, NY Reproduced under licence from the Western Electric Compan~, NY
Cop~right, J. Lions, 1976 Cop~right, J. Lions, 1976
Sheet 27 Sheet 27
Ma~ 24 12:35 1976 unix/trap.c Page 4 Ma~ 24 12:35 1976 unix/tra?c Page 5
2805 * On the 11/40 this is not the case and 2855 nos~s()
2806
2807
** The
the routine backup/140.s
ma~ fail.
classic example is on the instruction
2856
2857
{
u.u_error = 100;
2808 * cmp -(sp) ,-(sp) 2858 }
*I
2809 *1 2859 1* -------------------------
2810 case 9+USER: 1* segmentation exception *1 2860
2811 a = sp; 2861 1*
2812 if(backup(u.u_arO) == 0)
if(grow(a»
2862
2863
* Ignored
*1
s~stem call
2813
2814 gato out; 2864 nIJlls~s()
2815 i = SIGSEG; 2865 {
2816 break; 2866 }
2817 } 2867 1* ------------------------- *I
2818 iH 2868
2819 2869
2820 out: 2870
2821 if(issig(» 2871
2822 psig(); 2872
2823 setpri(u.u_procp); 2873
2824 } 2874
2825 1* ------------------------- *1 2875
2826 2876
2827 1* 2877
2828 Call the s~stem-entr~ routine f (out of the 2878
2829 ** s~sent table). This is a subroutine for trap, and 2879
2830 not in-line, because if a signal occurs 2880
2831 *during processing, an (abnormal) return is simulated from 2881
2832 **the last caller to savu(Gsav); if this took place 2882
2833 inside of trap, it wouldn't have a chance to clean up. 2883
2834 * 2884
2835 *
* If this occurs, the return takes place without 2885
2836 * clearing u_intflg; if it's still set, trap 2886
2837 * marks an error which means that a s~stem 2887
2838 * call (like read on a t~pewriter) got interrupted 2888
2839
2840
* b~ a sisnal. 2889
2890
*1
2841 trapl ( f ) 2891
2842 int (*f)(); 2892
2843 { 2893
2844 2894
2845 2895
2846 savu(u.u_Gsav); 2896
2847 (*f)(); 2897
2848 2898
2849 } 2899
Reproduced under licence from the Western Electric Companw, NY Reproduced under licence from the Western Electric Compan~, NY
Cop~right, J. Lions, 1976 Copwright, J. Lions, 1976
Sheet 28 Sheet 28
Ma~ 24 12:36 1976 uni:·:/s~sent. c F'ase 1 Ma\,l 24 12:36 1976 IJni}:/sssent. c F'aSe 2
Reproduced under licence frolTl the Western Electric COITIPan'=l, NY Reproduced under licence from the Western Electric COITIPan'=l. NY
COP'=lright, J. Lions. 1976 COP\,lright. J. Lions, 1976
Sheet 29 Sheet 29
Haw 24 12:36 1976 unix/sws1.c Pa~e 1 Ma~ 24 12:36 1976 unix/s~s1.c PaSe 2
3000 t 3050 na = 0;
3001 tinclude ".~/param.h" 3051 nc = 0;
3002 tinclude " •• /swstm.h" 3052 while(ap = fuword(u.u_arg[l]» {
3003 linclude " •• /user.h" 3053 natt;
3004 linclude " •• /proc.h" 3054 if(ap == -1)
3005 linclude " •• /buf.h" 3055 soto bad;
3006 linclude " •• /res.h" 3056 u.u_arg[l] =t 2;
3007 tinclude " •• /inode.h" 3057 forU n {
3008 3058 c = fubyte(aptt);
3009 /* 3059 if(c == -1)
3010 * exec swstem call. 3060 goto bad;
3011 * Because of the fact that an I/O buffer is used 3061 *cptt c;
3012 * to store the caller's arguments durin~ exec, 3062 nct+;
3013 * and more buffers are needed to read in the text file, 3063 if(nc :::- 510) {
:1014 * deadly embraces waiting for free buffers are possible. 3064 u.u_error E2BIG;
3015 * Therefore the number of processes simultaneouslw 3065 soto bad;
3016 * running in exec has to be limited to NEXEC. 3066 }
3017 */ 3067 if(c 0)
3018 Idefine EXPRI -1 3068 break;
:1019 3069 }
3020 exec () 3070 }
3021 { 3071 if«nc&1) != 0) {
3022 int ap, na, nc, *bp; 3072 *cP+t 0;
3023 int ts, ds, sep; 3073 nett;
3024 register c, *ip; 3074 }
3025 resister char *cp; 3075
3026 e:-:t.e rn ucha r; 3076 1* read in first 8 b~tes
3027 3077
3078
*
of file for segment
* sizes:
3028 /*
3029 * pick UP file names 3079 * wO = 407/410/411 (410 -) RO t.ext) (411 -> sep III)
3030 * and check various modes 3080 * w1 text size
3031 * for execute permission 3081 * w2 data size
3032 */ 3082 * w3 bss size
3033 3083 *1
3034 ip = namei(&uchar, 0)' 3084
'3035 if ( i p == NULL> 3085 u.u_base = &u.u_ar~[O];
3036 return; 3086 u.u_count = 8;
3037 while(execnt )= NEXEC) 3087 u.u_offset[1] = 0;
3038 sleep(&execnt, EXPRI); 3088 u.u_offset[O] = 0;
3039 e:-:ecnttt; 3089 u.u_segflg U
3040 bp = getblk(NODEV); 3090 readi(ip);
3041 if(access(ip, IEXEC) :: (ip-)i_mode&IFHT)!=O) 3091 u.u_segflg 0;
3042 goto bad; 3092 if(u.u_error)
3043 3093 go to bad;
3044 1* 3094 sep = 0;
3045 * pack UP arguments int.o 3095 if(u.u_arg[O] == 0407) {
3046 * allocated disk buffer 3096 u.u_ars[2] =t u.u_arg[l];
3047 */ 3097 u.u_ars[1] = 0;
3048 3098 } else
3049 3099 if(u.u_ar~[O] == 0411)
Reproduced under licence from the Western Electric Companw, NY Reproduced under licence from the West.ern Electric Compan~, NY
Copwri~ht, J. Lions, 1976 Copwri~ht, J. Lions, 1976
Sheet 30 Sheet 30
Mas 24 12136 1976 unix/swsloc Page 3 Maw 24 12:36 1976 unix/sssioc Page 4
Reproduced under licence from the Western Electric Companw, NY Reproduced under licence from the Western Electric Company, NY
Copwright, ~o Lions, 1976 Copwright, Jo Lions, 1976
Sheet 31 Sheet 31
Maw 24 12:36 1976 unix/swsl.c Page 5 Maw 24 12:36 1976 unix/swsl.c Page 6
Reproduced under licence from the Western Electric Companw, NY Reproduced under licence from the Western Electric Companw, NY
Copwrisht, J. Lions, 1976 Copwright, J. Lions, 1976
Sheet 32 Sheet 32
May 24 12:36 1976 unix/sysl.c Pa~e 7 May 24 12:36 1976 unix/sys1.c PaSe 8
3300 } 3350
330.1 if(p-)p_stat == SSTOP) { 3351 1* break system call.
3302 ifCCp-)p_fla~&SWTED) == 0) {
=1 SWTED.
3352 * --bad plannins: 'break" is a dirty word in C.
3303 p-)p_fla~ 3353 *1
3304 u.u_arO[ROJ p-)p_pid; 3354 sbreak<)
3305 u.u_arO[R1J Cp-)p_si~«8) 3355 {
~3306 017]; 3356
3307 retlJrn; 3357 int i.
3308 } 3358
3309 3359 1* set n to new data size
3310 setrlJnCp) ; 3360 set d to new-'old
3311 3361 * set n to new total size
3312 }
}
3362 *
*1
33:L3 ifCf) { 3363
3~314 3364 n = CC(u.u_ar~[OJ+63»)6) & 01777);
3315 soto lQQP~ 3365 ifC!u.u_sep)
3316
3317
}
u.u_error = ECHILD.
3366
3367 if(n < 0)
n =- nseSCu.u_tsize) *
128;
3318 } 3~568 n = 0;
3319 1* ------------------------- *1 3369 d = n - u.u~dsize;
3320 3370 n =+ USIZE+u.u_ssize;
3321 1* fork system call. *1 3371 ifCestabur(u.u_tsize. u.u_dsize+d. u.u_ssize. u.u_sep»
3322 forkC) 3372 return;
3323 { 3373 u.IJ_dsize =+ d;
3324 re~ister struct proc *pl, *p2; 3374 if Cd ) 0)
3325 3375
3326 p 1 = IJ. u_p rocp ; 3376 a u.u_procp-)p_addr + n - u.u_ssize;
3327 forCp2 = &proc[OJ; p2 < &proc[NPROCJ. p2++) 3377 i r,;
3328 ifCp2-)p_stat == NULL) 3378 n u.IJ_ssize;
3329 ~oto found. 3379 while(n--) {
3330 u.u_error = EAGAIN; 3380 coPYseS(a-d. a).
3331 ~oto out; 3381 a++;
3332 3382 }
3333 found: 3383 expand(i);
3334 ifCnewprocC» { 3384 return;
3335 u.u_arO[ROJ pl-)p_pid; 3385
3336 u.u_cstime[OJ 0; 3386 bis~er:
3337 u.u_cstime[lJ 0; 3387 expand(n);
3338 u.u_stime = 0; 3388 a = u.u_procp-)p_addr + n;
3339 u.u_cutime[OJ = 0; 3389 n = u.u_ssize;
3340 u.u_cutime[lJ = 0; 3390 whileCn--) {
3341 IJ.u_utime = 0; 3391 a--;
3342 return; 3392 coPyse~(a-d, a);
3343 } 3393 }
3344 3394 while(d--)
3345 3395 clearsesC--a);
3346 OIJt: 3396 }
3347 u.u_arO[R7J =+ 2; 3397 1* ------------------------- *1
3348 } 3398
3349 1* ------------------------- *1 3399
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
Copyri~ht, J. Lions, 1976 Copyri~ht, J. Lions, 1976
Sheet 33 Sheet 33
Ma~ 24 12:36 1976 unix/sys4.c Pase 1 May 24 12:36 1976 unix/sys4.c PaSe 2
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
Copyrisht, J. Lions, 1976 Copyrisht, J. Lions, 1976
Sheet 34 Sheet 34
Maw 24 12:36 1976 unix/sws40c PaSe 3 Maw 24 12136 1976 unix/sws40c PaSe 4
Reproduced under licence from the Western Electric Companw, NY Reproduced under licence from the Western Electric Companw, NY
Copwrisht, Jo Lions, 1976 Copwright, J. Lions, 1976
Sheet 35 Sheet 35
May 24 12:36 1976 unix/sys4.c Pa~e 5 May 24 12:36 1976 unix/s~s4.c Pa~e 6
3600 3650 }
3601 if «ip = owner(» == NULL) 3651 ifCf 0)
3602 return; 3652 u,u_error = ESRCH,
3603 ip-)i_fla~ =: IUPD, 3653 }
3604 tp = &tboJf[2]; 3654 1* ------------------------- *1
3605 *--tp = u.u_arOCR1]; 3655
3606 *--tp = u.u_arOCRO]; 3656 times()
3607 iupdatCip, tp), 3657 {
3608 ip-)i_fla~ =& NIUPD; 3658 resister *p;
3609 iput(ip); 3659
3610 } 3660 for(p = &u.u_utime; p (&u,u_utime+6;) {
3611 *1 3661 suwordCu,u_arSCO], *p++);
3612 1* ------------------------- *1 3662 u,oJ_arSCOJ =+ 2;
3613 3663 }
3614 ssisC) 3664 }
3615 { 3665 1* ------------------------- *1
3616 resister a, 3666
3617 3667 profile)
3618 <OJ =.oJ_ars[O];
OJ 3668 {
3619 if(.(=O :: a)=NSIG :: a ==SIGKIL) { 3669
3620 u.u_error = EINVAL, 3670 u.oJ_prof[OJ 1* base of sample buf *1
3621 return; 3671 OJ .oJ_prof[ 1 J 1* size of same *1
3622 } 3672 oJ.u_prof[2J OJ, u_arsC2J; 1*
pc offset *1
3623 u.u_arOCRO] = u.u_si~nalCa]' 3673 u,u_profC3J (u.u_ars[3J»1) & 077777; 1* pc scale *1
3624 u.u_siSnal[a] = u.u_arSC1]; 3674 }
3625 ifCu.u_procp->p_si~ == a) 3675 1* ------------------------- *1
3626 u.u_procP->p_si~ = 0, 3676
3627 } 3677
3628 1* ------------------------- *1 3678
3679
3629
3630 I<.i 11 ( ) 3680
3631 { 3681
3632 re~ister struct proc *p, *0, 3682
3633 reSister a; 3683
3634 int n 3684
3635 3685
3636 f 0; 3686
3637 a = u.u_arOCRO], 3687
3638 G u.u_procp; 3688
3639 for(p = &procCO]; p ( &procCNPROC], p++) { 3689
3640 ifCp <.1) 3690
3641 continoJe, 3691
3642 if(a != 0 && p-)p_pid != a) 3692
3643 continue, 3693
3644 if(a==O&&(p-)p_ttYP!=G-)p_ttyp: :p(=&procC1]» 3694
3645 continue; 3695
3646 if(u.u_uid != 0 && u,u_uid != p-)p_uid) 3696
3647 continue; 3697
3648 3698
3649 3699
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
CoPyrisht, J. Lions, 1976 Copyrisht. J, Lions. 1976
Sheet 36 Sheet 36
May 24 12:36 1976 unix/clock,c Page 1 May 24 12:36 1976 unix/clock.c Page 2
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
Copyright, J. Lions, 1976 Copyright, J. Lions, 1976
Sheet 37 Sheet 37
May 24 12:36 1976 unix/clock.c Page 3 May 24 12:36 1976 unix/clock.c Page 4
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
Copyright. J. Lions. 1976 Copyright, J. Lions, 1976
Sheet 38 Sheet 38
Maw 24 12:36 1976 unix/si~,c Pa~e 1 Maw 24 12:36 1976 unix/si~,c PaSe 2
3900
3901
*
1*
3950 {
3951 re~ister struct proc *1"';
3902 *1 3952
3',03 3953 forCp = &proc[O]; I'" < &proc[NPROC]; p++)
3904 tinclude ',./param,h' 3954 if(p-)p_ttwP == tp)
3905 tinclude ",./swstm.h" :~955 psigna1(p, si~);
3906 iinclude !! + + fuse r • h II 3956 }
3'~07 tinclude u •• /proc.hu 3957 1* -------------------------
3908 'B'include ".,/inode.h" 3958
3909 iinclude ""/reg,h" 3959 1*
3910 3960 * Send the specified signal to
3911 1* 3961 * the specified process.
3912 *
Prioritw for tracins 3962 *1
3913 *1 3963 psi~nal(p, si~)
3914 ltd€!fine IPCPRI (--1 ) 3964 int *1"';
39:t5 3965 {
3916 1* 3966
3917 *
Structure to access an arraw of intesers. 3967
if(sis NSIG)
3918 *1 3968 )=
3919 str'uct, 3969 return;
3'1'20 { 3970 rp = p;
3921 int inta[]; 3971 if(rp-)p_sig != SIGKIL)
3922 }; 3972 rp-)p_sis = sis;
3923 1* ------------------------- 3973 if(rp-)p_stat ) PUSER)
3924 3974 rp-)p_stat = PUSER;
3925 1* 3975 if(rp-)p_stat == SWAIT)
3926 *
Tracins variables. 3976 set r'.1n ( rp) ;
3927 *
Used to pass trace command from 3977 }
3928 *
parent to child beinS traced. 3978 1* ------------------------- *1
3929 *
This data base cannot be 3979
3930 *
shared and is locked 3980 1*
3931
39:32
*
per user.
*1
3981
3982
* Returns true if the current
* process has a signal to process,
3933 struct 3983 * This is asked at least once
3934 { 3984 * each time a process enters the
3935 int ip_Iocld 3985 * swstem,
39:56 int ip_reG; 3986 * A sisnal does not do anwthing
:3937 int ip_addr; 3987 * directlw to a process; it sets
3938 int ip_data; 3988 * a flas that asks the process to
3939
3940
} ipc; 3989
3990
*
*!
do somethins to itself.
1* -------------------------
3941 3991 issig()
3942 1* 3992 {
3943 * Send the specified sisnal to 3993 resister rd
3944 * all processes with 'tp' as its 3994 resister struct proc *1"';
3945 * controllinS teletwpe. 3995
3946 * Called bw ttw,c for Guits and 3996 = 'J, 'J_p rocp;
I'"
3947 * interrupts. 3997 if(n = p-)p_sis) {
3948 *! 3998 if (p->p_fla~&STRC) {
3949 siSnal(tp, sis) 3999 stope);
Reproduced under licence from the Western Electric Companw, NY Reproduced under licence from the Western Electric Companw, NY
Copwright, J. Lions, 1976 Copwri~ht, J, Lions, 1976
Sheet 39 Sheet 39
May 24 12:36 1976 unix/siS.c PaSe 3 Maw 24 12:36 1976 unix/sis.c PaSe 4
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Companw, NY
Copwrisht, J. Lions. 1976 Copyright, J. Lions, 1976
Sheet 40 Sheet 40
Maw 24 12:36 1976 unix/si~+c Pa~e 5 Maw 24 12:36 1976 unix/5i~+c Pase 6
Reproduced under licence from the Western Electric Companw. NY Reproduced under licence from the Western Electric Companw, NY
Copwrisht, J. Lions, 1976 Copwrisht, J. Lions. 1976
Sheet 41 Sheet 41
Ma~ 24 12:36 1976 unix/sis.c PaSe 7 May 24 12:36 1976 unix/sis.e Pase 8
Reproduced under licence from the Western Electric Company. NY Reproduced under licence from the Western Electric Company. NY
Copyrisht. J. Lions. 1976 Copyrisht. J. Lions. 1976
Sheet 42 Sheet 42
Program Swapping
Basic Input/Output
Block Devices
Ma~ 24 12:40 1976 unix/text.h PaSe 1 Ma~ 24 12:41 1976 unix/text.c PaSe 1
4300 1* 4350 t
4301 * Text structure. 4351 tinclude ' •• /param.h'
4302 * One allocated per pure 4352 tinclude ' •• /s~stm.h'
4303 * procedure on swap device. 4353 tinclude ' •• /user.h'
4304
4305
* Manipulated text.c
b~ 4354 tinclude
tinclude
'
'
•• /proc.h'
•• /text.h'
*f 4355
4306 struct text 4356 tinclude ' •• /inode.h'
4307 { 4357
4308 int :cdaddr; 1* disk address of seSment *1 4358 1* Swap out process P.
4309 int 1* core address, if loaded *1 4359 * The ff flas causes its core to be freed--
4310 int :csize; 1* size C *64 j *I 4360 * it ma~ be off when called to create an imase for a
4311 int *:ciptr' 1* inode of protot~pe*1 4361 *
child process in newproc.
4312 char x_count; 1* reference count *1 4362 * as is the old size of the data area of the process,
4313 char x_ccount; 1* number of loaded references *1 4363 * and is supplied durins core expansion swaps.
4314 } te:·:t[NTEXTJ; 4364
4315 1* ------------------------- 4365 ** panic: out of swap space
4316
4317
4366
4367
**I panic: swap error -- 10 error
4318 4368 xswap(p, ff, as)
4319 4369 int *p;
4320 4370 { resister *rp, a;
4321 4371
4322 4372 rp = p;
4323 4373 if(os == 0)
4324 4374 as = T'p->p_size;
4325 4375 a = malloc(swapmap, (rp-)p_size+7)/B),
4326 4376 if (a == NULL>
4327 4377 panicC'out of swap space'),
4328 4378 xccdec(rp-)p_textp);
4329 4379 rp->p_flas =1 SLOCK,
4330 4380 if(swap(a, rp-)p_addr, as' 0»
4331 4381- panic('swap error'),
4332 4382 if(ff)
4333 4383 mfree (coremap, as' rp->"",-addr);
4334 4384 rp->p_addr = a;
4335 4385 rp->p_flas =& M(SLOADISLOCK),
4336 4386 rp->p_time :: 0;
4337 4387 if(runout) {
4338 4388 runout = 0;
4339 4389 wakeup(&runout);
4340 4390 }
4341 4391 }
4342 4392 1* -------------------------
4343 4393
4344 4394 1*
4345 4395 * relinGuish use of the shared text seSment
4346
4347
4396
4397
* of a process.
*1
4348 4398 :·:free ( )
4349 4399 { resister *xp, *ip;
Reproduced under licence from the Western Electric Compan~. NY Reproduced under licence from the Western Electric Compan~, NY
Cop~risht, J. Lions, 1976 Cop~risht, J. Lions, 1976
Sheet 43 Sheet 43
Ma~ 24 12:41 1976 unix/text.c Pa~e 2 Ma~ 24 12:41 1976 unix/text.c Pa~e 3
4400 4450 }
440l ifCCxp~u,u_procp-)p_textp) != NULL) { 4451 if(Cxp-rp) == NULL) panicC'out of text');
4402 u.u_procp-)p_textp = NULL; 4452
4403 )·:ccdec C).:p ) ; 4453
4404 ifC--xp-)x_count == 0) { 4454 xp-)x_iptr = ip;
4405 4455 ts = CCu.u_ar~[lJ+63»)6) & 01777;
4406 if«ip-)i_ffiode&ISVTX) == 0) { 4456
4407 xp-)x_iptr = NULL; 4457 if«xp-)x_daddr = malloc(swapmap, Cts+7)/8» NULL)
4408 mfreeCswapmap, Cxp-)x_size+7)/8, 4458 panicC'out of swap space');
44()9 . xp-)x_daddr); 4459 expandCUSIZE+ts);
4410 ip-)i_fla~ =& NITEXT; 4460 estabur(O. ts, 0, 0);
44i1 ipute ip); 4461 U.u_cDunt = u.u_arS[lJ;
4412 } 4462 u.u_offset[lJ = 020;
4413 } 4463 '.J. u_base = 0;
4414 } 4464 readiCip);
4415 4465 rp = u.u_procp;
4416 4466 rp-)p_fla~ =i SLOCK;
441'7 4467 swap(xp-)x_daddr, rp-)p_addr+USIZE, ts, 0);
4418 1* Attach to a shared text se~ment. 4468 rp-)p_fla~ =& NSLOCK;
Reproduced under licence from the Western Electric Compan~, NY Reproduced under licence from the Western Electric Company, NY
Cop~ri~ht, J. Lions, 1976 Cop~ri~ht, J. Lions, 1976
Sheet 44 Sheet 44
May 24 12:41 1976 unix/buf.h Pa~e 1 May 24 12:41 1976 unix/buf.h Pa~e 2
4500 1* 4550
4501 * Each buffer in the pool is usually doubly linked into two 4551 struct devtab
4502 * lists: for the device with which it is currently associat-4552 {
4503 * ed (always) and also for a list of blocks available for 4553 char 1* busy flaS*1
4504 * allocation for other use (usually). 4554 char d_errcnt; 1* error count (for recovery)*1
4505 * The latter list is kept in last-used order, and the two 4555 struct buf *b_forwi 1* first buffer for this dev *1
4506 * lists are doubly linked to make it easY to remove 4556 struct buf *b_backi 1* last buffer for this dev *1
4507 * a buffer from one list when it was found by 4557 struct buf *d_actfi 1* head of 110 Queue *1
4508 * look inS throu~h the other. 4558 1* tail of liD Queue *1
4509 * A buffer is on the available list, and is liable 4559 };
4510 * to be reassi~ned to another disk block, if and only 4560 1* -------------------------
4511 * if it is not marked BUSY. When a buffer is busy, the 4561
4512 * available-list pointers can be used for other purposes.
4513 * Most drivers use the forward ptr as a link in their liD
4562
4563
i** This is the head of the Queue of available
4514 * active Queue. 4564 * buffers-- all unused except for the 2 list heads.
4515 * A buffer header contains all the information reQuired
4516 * to perform liD.
4565
4566
*i
4517 * Most of the routines which manipulate these thinSs 4567 struct buf bfreelisti
4518 * are in bio.c. 4568
4519 *1
4520 struct buf
4569
4570
i** These fla~s are kept in b_flass.
4521 { 4571 *i
4522 int b_fla~s; 1* see defines below *1 4572 idefine B_WRITE 0 i*non-read pseudo-fla~ *i
4523 struct buf *b_forw; 1* headed by devtab of b_dev *1 4573 idefine B_READ 01 1* read when 1/0 occurs *1
4524 struct buf *b_back; 1* *1 4574 idefine B_DONE 02 1* transaction finished *1
4525 struct buf *av_forwi 1* position on free list, *1 4575 idefine B_ERROR 04 1* transaction aborted *1
4526 strlJct buf *av_back; 1* if not BUSY*I 4576 idefine B_BUSY 010 1* not on av_forwiback list *1
4527 int b_dev; 1* maJor+minor device name *1 4577 idefine B_PHYS 020 1* Physical 10 potentiallY
4528 int b_wcol.mt; 1* transfer count (usu. words) *1 4578 usins the Unibus map *1
4529 char *b_addr; 1* low order core address *1 4579 idefine 040 1*This block has the UNIBUS
4530 char *b_xmem; 1* hish order core address *1 4580 map allocated *1
4531 char' *b __ blkno; 1* block i on device *1 4581 idefine 0100 1* issue wakeup when
4532 char b_error; 1* returned after liD *1 4582 BUSY ~oes off *1
4533 char *b_resid; 1* words not transferred after 4583 idefine 0200 1* no lonser used *1
4534 error *1 4584 idefine 0400 1* don't wait for liD
4535 } bufCNBUFJi 4585 coifIF,letion *1
4536 1* ------------------------- 4586 idefine B_DELWRI 01000 1*don't write till block
4537 4587 leaves available list *1
4538 1* 4588
4539 * Each block device has a devtab, which contains private 4589
4540 * state stuff and 2 list heads: the b_forw/b_back list, 4590
4541 * which is doubly linked and has all the buffers currently 4591
4542 * associated with that major device;
4543 * and the d_actf/d_actl list, which is private to the
4592
4593
4~544 * device but in fact is always used for the head and tail
4545 * of the liD Queue for the device.
4594
4595
4546 * Various routines in bio.c look at b_forw/b_back 4596
4547 * (notice they are the same as in the buf structure) 4597
4548 * but the rest is private to each device driver. 4598
4549 *I 4599
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
Copyri~ht, J. Lions, 1976 Copyri~ht. J. Lions, 1976
Sheet 45 Sheet 45
Maw 24 12:41 1976 unix/conf.h Pa~e 1 May 24 12:41 1976 unix/conf.c Page 1
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
CoPYright, J. Lions, 1976 Copwrisht, J. Lions, 1976
Sheet 46 Sheet 46
Ma~ 24 12:41 1976 unix/bio.c Page 1 May 24 12:41 1976 unix/bio.c Page 2
4700 I 4750
4701
4702
'**1 4751 1* Read in (if necessary) the block and
4752
* return a buffer pointer,
4703 *1
4753
4704 linclude '.,/param.h' 4754 bread(dev, blkno)
4705 tinclude ',./user,h' 4755 {
4706 tinclude '"/buf.h' 4756 register struct buf *rbp;
4707 linclude ' •• /conf.h' 4757
4708 linclude ',./sYstm.h' 4758 rbp = getblk(dev, blkno);
4709 linclude ' •• /proc.h' 4759 if (rbp-)b_flaSs&B_DONE)
4710 .include '.,/seg.h' 4760 return(rbp);
4711 4761 rbp-)b_flags =: B_READ;
4712 1* 4762 rbp-)b_wcount = -256;
4/,13 * This is the set of buffers proper, whose heads 4763 (*bdevsw[dev.d_maJ~r].d_strategy)(rbp);
4714 * were declared in buf.h. There can exist buffer 4764 iowait(rbp);
4715 * headers not pointing here that are used purel~ 4765 ret'J rn ( rbp) ;
4716 * as arguments to the liD routines to describe 4766 }
4717
4718
*
liD to be done-- e.S. swbuf, Just below, for
* swappins,
4767 1*
4768
47:l9 *1 4769 1*
4720 char buffersCNBUF]C514]; 4770 * Read in the block, like bread, but also start liD on the
4721 struct b'Jf swbuf; 4771 *
read-ahead block (which is not allocated to the caller)
4722 4772 I I
4723 1* 4773 breada(adev. blkno, rablkno)
4724 • Declarations of the tables for the mastape devices; 4774 {
4725
4726 .1
*
see bdwrite. 4775 register struct buf *rbp, *rabp;
register int dey;
4776
I.
4727 int tmtab; 4777
4728 int httab; 4778 dey = adev;
4729 4779 rbp = OJ
4730 4780 if (!incore(dev, blkno» {
4731 *
The followins several routines allocate and free 4781 rbp = setblk(dev, blkno);
4732 *
buffers with various side effects. In general the 4782 if «rbp-)b_flags&B_DONE) == 0) {
4733 *
arguments to an allocate routine are a device and 4783 rbp-)b_flaSs =: B_READ;
4734 • a block number, and the value is a pointer to 4784 rbp-)b_wcount = -256;
4735 *
to the buffer header; the buffer is marked ·bus~· 4785 (*bdevswCadev.d_maJorJ.d_strateSY) (rbp);
4736 • so that no on else can touch it. If the block was 4786 }
4737 * already in core. no liD need be done; if it is 4787 }
4738 *
already busy, the process waits until it becomes free. 4788 if (rablkno && !incore(dev, rablkno» {
4739 *
The following routines allocate a buffer: 4789 rabp = setblk(dev, rablkno);
4740 *
getblk 4790 if (rabp-)b_flags & B_DONE)
4741 * bread 4791 brelse(rabp);
4742 * breada 4792 else {
4743 *
EventuallY the buffer must be released, possibly with the 4793 rabp-)b_flass =: B_READ:B_ASYNC;
4744 *
side effect of writing it out. by using one of 4794 rabp-)b_wcount = -256;
4745 * bwrite 4795 (*bdevsw[adev.d_maJorJ.d_strategy) (rabp);
4746 * bdwrite 4796 }
4747 • bawrite 4797 }
4748 * brelse 4798 if (rbp==O)
4749 *1 4799 return(bread(dev, blkno»;
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
Copyright, J. Lions, 1976 COPYright, J. Lions, 1976
Sheet 47 Sheet 47
May 24 12:41 1976 unix/bio.c Pa~e 3 May 24 12:41 1976 unix/bio.c Pa~e 4
4817 rbp-)b_fla~s =& NCB_READ i B_DONE i B_ERROR i B_DELWRI); 4867 1* release the buffer, with no 110 implied.
4818 rbp->b_wcount = -256; 4868 *1
4819 (*bdevsw[rbp->b_dev.d_maJorJ.d_strate~y)(rbp); 4869 brelse(bp)
4820 if «fla~&B_ASYNC) == 0) { 4870 struct buf *1..11"';
4821 iowait(rbp); 4871 {
4822 brelse(rbp); 4872 re~ister struct buf *rbp, **backp;
4823 } else if «fla~&B_DELWRI)==O) 4873 re~ister int SPS;
4El24 ~eterror(rbp) ; 4874
4825 } 4875 rbp = bp;
4826 1* ------------------------- 4876 if (rbp-)b_flags&B_WANTED)
4827 4877 wakeup(rbp);
4828 1* 4878 if (bfreelist.b_flagsIB_WANTED) {
4829 * Release the buffer, markin~ it so that if it is ~rabbed 4879 bfreelist.b_fla~s =& NB_WANTED;
4830 * for another purpose it will be written out before bein~ 4880 wakeup(&bfreelist);
4831 * siven UP (e.g. when writing a partial block where it is 4881 }
4832 * assumed that another write for the same block will soon 4882 if (rbp-)b_fIB~s&B_ERROR)
4KB *
follow). This can't be done for ma~tape, since writes 4883 rbp-)b_dev.d_minor -1; 1* no assoc. on error *1
4834 * must be done in the same order as reGuested. 4884 backp = &bfreelist.av_back;
4835 *1 4885 sps = PS->inte~;
4836 bdwrite(bp) 4886 spI6();
4837 struct buf *bp; 4887 rbp->b_fla~s =1 N(B_WANTEDiB_BUSYiB_ASYNC);
4838 { 4888 (*backp)-)av_forw = rbp;
4839 re~ister struct buf *rbp; 4889 rbp-)av_back = *backp;
4840 re~ister struct devtab *dp; 4890 *backp = rbp;
4841 4891 rbp-)av_forw = Ibfreelist.
4842 rbp = bp; 4892 PS-)inte~ =, sps;
4843 dp = bdevsw[rbp-)b_dev.d_maJorJ.d_tab; 4893 )
4844 if (dp == &tmtab i i dp == &httab) 4894 1* -------------------------
4845 bawrite(rbp); 4895
4846 else { 4896 1* See if the block is associated with some buffer
4847 rbp->b_fla~s =: B_DELWRI 4897 *
(mainly to avoid ~ettin~ hun~ UP on a wait in breada)
4848 brelse(rbp); 4898 *1
4849 } 4899 incore(adev, blkno)
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
Copyri~ht, J. Lions, 1976 Copyri~ht, J. Lions, 1976
. Sheet 48 Sheet 48
May 24 12:41 1976 unix/bio.c PaSe 5 May 24 12:41 1976 unix/bio.c PaSe 6
4900 -( 4950 }
4901 resister int dey; 4951 }
4902 resister struct buf *bp; 4952 spI6();
4903 resister struct devtab *dpj 4953 if (bfreelist.av_forw == &bfreelist) -(
4904 4954 bfreelist.b_flags =: B_WANTED;
4<;>05 dey = adev; 4955 sleep(&bfreelist, PRIBIO);
4906 dp = bdevsw[adev.d_ma~or].d_tab; 4956 spIO();
4907 for Cbp=dp-)b_forw; bp != dp; bp = bp-}b_forw) 4957 goto loop;
4908 if Cbp-}b_blkno==blkno && bp-}b_dev==dev) 4958 }-
4909 ret<J rn Cbp ) ; 4959 spIO();
4910 returnCO); 4960 notavail(bp = bfreelist.av_forw);
4911 )- 4961 if (bp-}b_flass & B_DELWRI) -(
4912 1* 4962 bp-}b_flags =: B_ASYNC;
4913 4963 bwrite(bp);
4914 1* Assisn a buffer for the siven block. If the appropriate 4964 goto loop;
4915 * block is already associated, return it; otherwise search 4965 }
4916 * for the oldest non-busY buffer and reassiSn it. 4966 bp-}b_flags = B_BUSY : B_RELOC;
4917 * When a 512-byte area is wanted for some random reason 4967 bp-}b_back-}b_forw = bp-}b_forw;
4918 * Ce.S. durins exec. for the user arslist) setblk can be 4968 bp-}b_forw-}b_back = bp-}b_back;
4919 * called with device NODEV to avoid unwanted associativity, 4969 bp-}b_forw = dp-}b_forw;
4920 *1 4970 bp-}b_back = dp;
4921 setblkCdev, blkno) 4971 dp-}b_forw-)b_back = bp;
4922 -( 4972 dp-}b_forw = bp;
4923 resister struct buf *bp; 4973 bp-}b_dev = dey;
4924 resister struct devtab *dp; 4974 bp-}b_blkno = blkno;
4925 e}:tern lbolt; 4975 return(bp) ;
4926 4976 }-
4927
4928
ifCdev.d_lI!a~or >= nblkdev)
panic("blkdev");
4977 1* -------------------------
4978
4929 4979 1* Wait for 1/0 completion on the buffer; ret<Jrn errors
4930 loop: 4980 * to the user.
4931 if (dev < 0) 4981 *!
4932 dp &bfreelist; 4982 iowait(bp)
4933 else -( 4983 struct buf *bp;
4934 dp bdevsw[dev.d_maJor].d_tab; 4984 -(
4935 if(dp == NULL> 4985
4936 panic("devtab"); 4986
4937 for (bp=dp-)b_forw; bp != dp; bp = bp-)b_forw) -( 4987 rbp = bp;
4938 if (bp-)b_blkno!=blkno :: bp-)b_dev!=dev) 4988 spI6();
4939 continue; 4989 while (Crbp-}b_flass&B_DONE)==O)
4940 spI6(); 4990 sleep(rbp, PRIBIO);
4941 if (bp-)b_flaSs&B_BUSY) -( 4991 spIO();
4942 bp-}b_flaSs =: B_WANTED; 4992 geterrorCrbp);
4943 sleep(bp, PRIBIO); 4993 }-
4944
4945
spIO();
soto loop;
4994 1* -------------------------
4995
4946 } 4996 1* Unlink a buffer from the available list and mark it busy.
4947 splO ( ) ; 4997 * Cinternal interface)
4948 notavaiICbp); 4998 *!
4949 returnCbp); 4999 notavail(bp)
Reproduced under licence froll! the Western Electric Company, NY Reproduced under licence froll! the Western Electric Company, NY
COPYright, J. Lions, 1976 CopyriSht. J. Lions, 1976
Sheet. 49 Sheet 49
Maw 24 12:41 1976 unix/bio.c PaSe 7 Maw 24 12:41 1976 unix/bio.c PaSe 8
Reproduced under licence from the Western Electric Companw, NY Reproduced under licence from the Western Electric Companw, NY
Copwrisht, J. Lions, 1976 CopwriSht, J. Lions. 1976
Sheet 50 Sheet 50
Maw 24 12:41 1976 unix/bio.c Pa~e 9 Ma~ 24 12:41 1976 unix/bio.c Pa~e 10
Reproduced under licence from the Western Electric Compan~. NY Reproduced under licence from the Western Electric Companw, NY
Cop~right, J. Lions. 1976 Copwright, J. Lions. 1976
Sheet 51 Sheet 51
May 24 12:41 1976 unix/bio.c Page 11 May 24 12:41 1976 unix/bio.c Page 12
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
Copyright, J. Lions, 1976 CoPYrisht, J. Lions. 1976
Sheet 52 Sheet 52
May 24 12:41 1976 unix/bio.c PaSe 13 May 24 12:42 1976 unix/rk.c PaSe 1
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
CopyriBht, J. Lions, 1976 Copyright, J. Lions, 1976
Sheet 53 Sheet 53
May 24 12:42 1976 unix/rk.c Pa~e 2 May 24 12142 1976 unix/rk.c Page 3
Sheet 54 Sheet 54
May 24 12:54 1976 unix/file.h PaSe 1 May 24 12:54 1976 unix/filsys.h Page 1
5500 1* 5550 1*
5501 * One file structure is allocated 5551 *
Definition of the unix super block.
5502 * for each open/creat/pipe call. 5552 **
The root super block is allocated and
5503 ** Main use is to hold the read/write 5553 read in iinit/alloc.c. Subseouently
5504 pointer associated with each open 5554 **
a super block is allocated and read
5505
5506
* file.
*1
5555 with each mount (smount/sys3.c) and
5556 * released with unmount (sumount/sys3.c).
5507 struct file 5557 * A disk block is ripped off for storage.
5508 { 5558 * See alloc.c for general alloclfree
5509 char 5559 * routines for free list and I list.
5510 char f_count; 1* reference count *1 5560 *1
5511 int f_inodei 1* pointer to inode structure *1 5561 struct filsys
5512 char *f_offset[2]i 1* read/write character pointer */5562 {
5513 } file[NFILE]i 5563 int s_isize; 1* size in blocks of I list *1
5514 1* ------------------------- *1 5564 int s_fsizei 1* size in blocks of entire volume *1
5515 5565 int 1* number of in core free blocks
5516 1* flags *1 5566 (between 0 and 100) *1
5517 idefine FREAD 01 5567 int s_free[100]i 1* in core free blocks *1
5518 idefine FWRITE 02 5568 int s_ninodei 1* number of in core I nodes (0-100) *1
5519 Idefine FPIPE 04 5569 int s_inode[100]i/* in core free I nodes *1
5520 5570 char s_flocki 1* lock during free list manipulation *1
5521 5571 char s_ilocki 1* lock during I list manipulation *1
5522 5572 char s_fmodi 1* super block modified flag*1
5523 5573 char s_ronly; 1* mounted read-only flag *1
5524 5574 int s_time[2]i 1* current date of last update *1
5525 5575 int pad[50]i
5526 5576 };
5527 5577 1* ------------------------- *1
5528 5578
5529 5579 ~
5530 5580
5531 5581
5532 5582
5533 5583
5534 5584
5535 5585
5536 5586
5537 5587
5538 5588
5539 5589
5540 5590
5541 5591
5542 5592
5543 5593
5544 5594
5545 5595
5546 5596
5547 5597
5548 5598
5549 5599
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
Ccpyrisht, J. Lions, 1976 Copyright, J. Lions. 1976
Sheet 55 Sheet 55
Ma~ 24 12:54 1976 unix/ino.h PaSe 1 Ma~ 24 12:54 1976 unix/inode.h PaSe 1
Reppod~ced wnde~ licence from the Western Electric COffiPanyv NY Reproduced und2r licence from the :~estGrn El~ctric COffiPans~ NY
Cop~riSht, J. Lions, 1976 Cop~ri~ht. J. Lions. 1976
Sheet 56 Sheet 56
May 24 12:54 1976 unix/sys2.c Page 1 May 24 12:54 1976 unix/sys2.c Page 2
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
Copyright, J. Lions, 1976 Copyright, J. Lions, 1976
Sheet 57 Sheet 57
Maw 24 12:54 1976 unix/sws2.c Pa~e 3 Maw 24 12:54 1976 unix/sys2.c Pa~e 4
5800 *
COffiffion code for open and creat. 5850 fp = setf(u.u_arO[ROJ);
5801 *
Check permissions. allocate an open file structure. 5851
5852
if(fp == NULL)
return,
5802 * and call the device open routine if any.
5803 *1 5853
5854
u.u_ofile[u.u_arO[ROJJ = NULL;
closef(fp);
5804 openl(ip, mode, trf)
!5805 5855 }
5806 5856 1* -------------------------
5807 resister struct file *fp; 5857
!;'ja08 re~ister *rip, m; 5858 1*
~=;a09 int i; 5859 *
seek system call
5810
rip = ip;
5860 *1
5861 seek()
~'iBii
51312 m = mode; 5862 {
5813 if(trf ! = 2) { 5863 int n[2J;
!;'j814 if(m&FREAD) 5864 re~ister *fp, t;
!;'ji315 access(rip, IREAD); 5865
5 Ell 6 if (ffi&FWRITE) { 5866 fp = setf(u.u_arO[ROJ);
5817 access(rip, IWRITE); 5867 if(fp == NULL>
5818 if«rip-)i_mode&IFMT) == IFDIR) 5868 ret'Jrn;
5819 u.u_error = EISDIR; 5869 if(fp-)f_flas&FPIPE) {
5820 5870 u.u_error = ESPIPE;
582j. 5871 return;
5822 if(u.u_error) 5872 }
5823 soto out; 5873 t = u.u_arsI:1J;
5824 i f (trf) 5874 if(t ) 2) {
!..1825 itrunc(rip); 5875 n[IJ = u.u_ar~[OJ«9;
~=;826 prele(rip); 5876 n[OJ = u.u_arsI:OJ»7;
51327 if «f? = falloc(» == NULL) 5877 if(t -- 3)
5828 soto out; 5878 n[OJ =& 0777;
5829 fp-)f_flas = m&(FREADIFWRITE); 5879 } else {
5830 fp-)f_inode = rip; 5880 n[IJ u.u_ar~[OJ;
58;31 i = u,'J_arO[ROJ; 5881 n[OJ 0;
!;'j832 openi(rip, m&FWRITE); 5882 if(t!=O && n[IJ(O)
5833 if(u.u_error == 0) 5883 n[OJ = -1;
~'i834 return; 5884 }
5835 u.u_ofile[iJ = NULL; 5885 switch(t) {
58;36 fp-)f_count--; 5886
5837 5887 case 1:
51338 o'Jt: 5888 case 4:
5839 iput(rip); 5889 n[OJ =t fp->f_offset[O);
5840 } 5890 dpaddCn, fp-)f_offset[I]);
5841 1* ------------------------- *1 5891
5892
break;
5842
5843 1* 5893 defa'Jlt:
5844 *' close ~~steffi call 5894 n[OJ =t f?-)f_inoda->i_sizeO:0377;
5845 *1 5895 dpadd(n, fp-)f_inode-)i_sizel);
5846 close() 5896
51347 { 5897 case 0:
5848 resister *fp; 5898 case 3:
5849 5899
Reproduced under licence from the Westgrn Electric Com?anYr NY Repr~duced und8; li~=nce from tl,e W~ste~i) El~c~pic COffi?a~~; NY
Copyrisht, J. Lions, 1976 Cop~rishtv J. Lions. 1976
Sheet 58 Sheet 58
I
May 24 12:54 1976 unix/sys2.c Page 5 May 24 12:54 1976 UniK/sys2.c Page 6
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
Copyrisht, J. Lions, 1976 Copyright, J. Lions, 1976
Sheet 59 Sheet 59
Ma~ 24 12:55 1976 unix/s~s3.c Pa~e 1 Ma~ 24 12:55 1976 unix/s~s3.c Pa~e 2
Reppoduced un~2~ li~ence from ths Western Elactric COffiPan~p NY He-Pf-oduced lJ'ld'S' ...· licl,;;<!"";ct:;,· ?·~·U~ji Lhs {!Jes-t.er-~i El,:::-c;--(,i"ic.- COii:pi!:;;'..:r ;~ . .(
Copwrisht, J. Liens. 1976 Cop~ri~ht. J. Lions. 1976
Sheet 60 Sheet 60
Ma~ 24 12:55 1976 unix/s~s3.c Pa~e 3 Ma~ 24 12:55 1976 unix/s~s3.c Page 4
Reproduced under licence from the Western Electric Compan~, NY Reproduced under licence from the Western Electric Compan~, NY
Cop~right, J. Lions, 1976 Cop~right, J. Lions, 1976
Sheet 61 Sheet 61
May 24 12:55 1976 unix/rdwri.c Page 1 May 24 12:55 1976 unix/rdwri.c Page 2
6200 i 6250 dn
6201 1* 6251 } else {
6202 *1 6252 dn ip-)i_addrCOJ;
6203 6253 rablock = bn+l;
6204 iinclude " •• /param.h" 6254 }
6205 linclude " •• /inode.h" 6255 if (ip-)i_Iastr+l == Ibn)
6206 linclude " •• /user.h" 6256 bp breada(dn, bn. rablock);
6207 *include " •• /buf.h" 6257 else
6208 iinclude ' •• /conf.h" 6258 bp bread(dn, bn);
6209 iinclude " •• /systm.h" 6259 ip-)i_Iastr = Ibn;
6210 6260 iomove(bp, on. n. B_READ);
6211 1* 6261 brelse(bp);
6212 * Read the file corresponding to 6262 } while(u.u_error==O && u.u_count!=O);
6213 * the inode pointed at bw the argument. 6263 }
6214 *
The actual read arguments are found 6264 1*
f~~~
U~&W *
in the variablc~: 6265
6216 *
u_base core address for destination 6266 1*
6217 *
u_offset byte offset in file 6267 * Write the file corresponding to
6218 *
u_count number of bytes to read 6268 *the inode pointed at by the argument.
6219
6220
*
u_segflg read to kernel/user 6269 *The actual write arSuments are found
*1 6270 * in the variables:
6221 readi(aip) 6271 * u_base core address for source
6222 struct inode *aip; 6272 * u_offset bwte offset in file
6223 { 6273 * u_count number of bytes to write
6224 int *bp; 6274 * u_segflg write to kernel/user
6225 int Ibn, bn, on; 6275 *1
6226 register dn, n; 6276 writei(aip)
6227 register struct inode *ip; 6277 struct inode *aip;
6228 6278 {
6229 ip = aip; 6279 int *bp~
6230 if(u.u_count == 0) 6280 int n, on;
6231 return; 6281 resister dn, bn;
6232 ip-)i_flaS =: IACC; 6282 register struct inode *ip;
6233 if«ip-)i_mode&IFMT) == IFCHR) { 6283
6234 (*cdevswCip-)i_addrCOJ.d_maJorJ.d_read) (ip-)i_addrCOJ) ; 6284 ip = aip;
6235 return; 6285 ip-)i_flaS =: IACCIIUPD;
6236 } 6286 if«ip-)i_mode&IFMT) == IFCHR) {
6237 6287 (*cdevswCip-)i_addr[OJ.d_maJorJ.d_write) (ip-)i_addr[OJ );
6238 do { 6288 return;
6239 Ibn = bn = lshift(u.u_offset. -9); 6289 }
6240 on = u.u_offsetC1J & 0777; 6290 if (u.u_count 0)
6241 n = min(512-on, u.u_count); 6291 return;
6242 if«ip-)i_mode&IFMT) != IFBLK) { 6292
6243 dn = dpcmp(ip-)i_sizeO&0377, ip-)i_sizel, 6293 do {
6244 u.u_offsetCOJ, u.u_offset[IJ); 6294 bn = lshift(u.u_offset, -9).
6245 if(dn <= 0) 6295 on = u.u_offset[IJ & 0777;
6246 return; 6296 n = min(512-on, u.u_count);
6247 n = min(n, dn); 6297 if«ip-)i_mode&IFMT) != IFBLK) {
6248 if «bn = bwap(ip, Ibn» 0) 6298 if (Cbn = bmap(ip, bn» == 0)
6249 return; 6299 return;
Reproduced under licence from the Western Electric Company, NY Reproduced under lic2ncG from the Western Ele=tric C~mpanY, NY
CoPYright, J. Lions. 1976 Cop~right, J. Lions. 1976
Sheet 62 Sheet 62
May 24 12:55 1976 unix/rdwri.c PaSe 3 May 24 12:55 1976 unix/rdwri.c Page 4
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company. NY
Copyright, J. Lions. 1976 Copyrisht, J. Lions, 1976
Sheet 63 Sheet 63
May 24 12155 1976 Gnix/sub~.c Page 1 May 24 12155 1976 unix/subr.c PaSe 2
6400
6401
*iinclude " •• /param.h"
6450
6451
nb = bp-}b_blkno;
ip->i_addrEbn] = nb;
6402 tincllJde " •• /conf.h" 6452 ip-}i_flag =: IUPD;
6403 tinclude " •• /inode.h" 6453 }
6404 tincllJde " •• /user.h" 6454 rablock =
0;
640!5 "'include " •• /buf.h" 6455 if Cbn(7)
(>406 iinclude " •• /systm.h" 6456 rablock
6407 6457 returr,(nb) ;
64013 1* Bmap defines the structure of file system storage 6458 }
(,409 * by returning the phYsical block number on a device given 6459
(>410 * the inode and the logical block number in a file.
I When convenient, it also leaves the physical
6460
6461
6411
6412 * block number of the next block of the file in rablock 6462 large:
(,413
6414
*
II
for use in read-ahead. 6463
6464
i = bn»8;
if(bn & 0174000)
6415 bmap(ip~ bn) 6465 i = 7;
6416 struct inode lip; 6466 ifC(nb=ip-}i_addrEi]) == 0) {
6417 int bn; 6467 ip->L flag =: IUP[I;
641El { 6468 if (Cbp = alloc(d» -- NULL)
6419 resister Ibp. Ibap, nb; 6469 returnCNULL);
64;!() int Inbp, d, i; 6470 ip->i_addr[i] - bp-}b_blkno;
6421 6471 } else
,5422 d = iF·-}i_dev; 6472 bp = breaded. nb);
(,423 if(bn & N077777) { 6473
lJ4~~4 u.u_error =
EFBIG; 6474
.5425 return(O); 6475 1* "hu~e" fetch of double indirect block II
6426 } 6476
M27 ifCCip-}i_mode&ILARG) ==
0) { 6477 if (i == 7) {
6428 6478 i = «bn»S) & 0377) - 7;
(,429 I I small file algorithm II 6479 if«nb=bap[i]) == 0) (
6430 6480 if«nbp = alloced» -- NULL) (
6431 i.f( (bn & N7) != 0) { 6481 brelse(bp);
6432 6482 return(NULL> ;
6433 1*
convert small to large *1 6483 }
(>434 6484 bap[i] =nbp->b_blkno;
(,43::j if (Cbp = alloc(d» NULL) 6485 bdwrite(bp);
6436 ret'Jrn(NULL> ; 6486 } else {
6437 bap = bp-)b_addr; 6487 brelse(bp);
(.438 for(i=O; i<8; itt) { 6488 nbp = breaded. nb);
(,4:39 *baptt = ip-}i_addr[i]; 6489 }
6440 ip-}i_addr[i] = 0; 6490 bp nbp;
6441 } 6491 bap = bp->b_addr;
6442 ip-}i_addr[O] = bp->b_blkno; 6492 }
6443 bdwrite(bp); 6493
6444 ip-)i_mode =: ILARG; 6494 1* normal indirect fetch *1
6445 go to large; 6495
6446 } 6496 i = brr & 0377;
6447 nb ip-)i_addrEbn]; 6497 if«nb=oa?EiJ) == 0 && (nbp al1oC(d» !=NULU {
(,448 if(nb "'= 0 && (bp = alloc(d» 1= NULL> -[ 6498 rrb = nbp->b_blkno~
(>449 bdwri te (bp); 6499 bapEiJ = rrb;
Reproduced u[)Je( ~icence from the We5tern Elsctric CGmpan~, NY ~e?rod~ced ~~de~ licence from ths ~~cst2~n E~2Ct~~~ C~~~2n~~ ~y
Copyright. J. Lions. 1976 Copyright. J. Lions. 1976
Sheet 64 Sheet 64
May 24 12:55 1976 unix/subr.c Page 3 May 24 12:55 1976 unix/subr.c Page 4
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
Copyright, J. Lions. 1976 Copyright, J. Lions, 1976
Sheet 65 Sheet 65
Maw 24 12:55 1976 unix/fio.c PaSe 1 Maw 24 12:55 1976 unix/fio.c Pase 2
,~600
[)(~01 1*
* 6650
6651
ip = rfp-)f_inode;
ip-)i_mode =& N(IREADIIWRITE);
6602 II 6652 wal<.eup( ip+l);
<,i,03 6653 wake'JP (ip+2) ,
6604 "'include • •• /param.h' 6654 }
6605 iinclude ' •• /tlser.h" 6655 if(rfp-)f_count (= 1)
.!·,606 iinclude ' •• /filsws.h" 6656 closei(7fp-)f_inode, rfp-)f_flss&FWRITE);
6607 iinclude " •• /file.h' 6657 T'fp-)f _coIJnt--;
6608 finclude " •• /conf.h" 6658 }
<,609 oM' i nc hIde ' •• /inode.h" 6659 1* ------------------------- II
.!,610 iinclude ',./res.h" 6660
6611 6661 Ill:
.:,612 II 6662 * Decrement reference count on an
6613 I Convert a user supplied 6663 * inode due to the removal of a
6614 *file descriptor into a pointer 6664 * referencins file structure.
6615 I to a file structure. 6665 * On the last closei, switchout
6616 *Onlw task is to check ranSe 6666 * to the close entrw point of special
6617 *of the descriptor. 6667
6668
I device handler.
* Note that the handler sets called
M>l8 II
.:,61 9 ~~f?tf· (f) 6669 * on everw open and onlw on the last
.:,620 {
~·)621 resister Ifp, rf,
6670
6671
* close,
*1
.!;~)22 6672 closei(ip, rw)
o!j6:~~5 rf = f; 6673 int *ip;
.~)b24 if(rf(O :: rf>=NOFILE) 6674 {
662~5 So to bad; 66'75 resister *rip;
6626 fp - u.u_ofile[rf], 6676 resister dey, maJ;
6627 if(fF' != NULL> 6677
6628 returnefp); 6678 rip == ip;
6629 bad: 6679 dev - rip->i_addrCOJ;
6630 u.u_error = EBADFf 6680 maJ rip-)i_addrCOJ.d_maJorl
6631 return(NULL), 6681 if(rip-)i_count (== 1)
.!,632 } 6682 switch(rip-)i_mode&IFMT) {
6633 1* ------------------------- *1 6683
6634 6684 case IFCHR:
<,635 1* 6685 (*cdevsw[maJJ.d_close) (dev, rw) ;
6636
6637
* Internal form
* Decrement
of close.
reference count on
6686
6687
break;
Re?~oduced under li=£ncG ~ro@ the :1~stcrn El~ct~ic Compan~; NY Rsproducsd under l~csnc~ from the W2stern EIE~tric CO~iP8ns~ ~!y
Copwrisht. J. Lions, 1976 Cop~risht, J. Lions. 1976
Sheet 66 Sheet 66
Ma~ 24 12:55 1976 unix/fio.c Page 3 Ma~ 24 12:55 1976 unix/fio.c Page 4
Reproduced under licence from the Western Electric Compan~, NY Reproduced under licence from the Western Electric Company. NY
Cop~right, J. Lions. 1976 Cop~right. J. Lions. 1976
Sheet 67 Sheet 67
Ma~ 24 12:55 1976 unix/fio.c PaSe 5 Ma~ 24 12:55 1976 unix/fiooe PaSe 6
.!,<'H8 } 6868
61319 1* ------------------------- *1 6869
,!,820 6870
a!1822
1**
.!lB21.
Allocate a user file descriptor.
6871
68"72
6823 *1 6873
bB24 'Jfalloc ( ) 6874
6825 { 6875
.!,H26 resister i; 6876
.!,B27 6877
,!,B28 for (i=O; i<NOFILE, itt) 6878
.!,1329 if (u.u_ofileEiJ NULL) { 6879
.!l830 6880
·6831 ret'Jrn (i) ; 6881
,!,B:32 } 6882
61333 uou_error EMFILE; 6883
.!,B34 return(-1); 6884
.5835 } 6885
.!l8361* ------------------------- *1 6886
61337 6887
.!,B38
.!,839
1** Allocate a user file descriptor
6888
6889
.!,840 * and a file structure. 6890
6841 * Initialize the descriptor 6891
.!,B42 * to point at the file structure. 6892
.!,843 6893
.!,B44
** no file -- if there are no available 6894
6845 * file structures. 6895
6846 *1 6896
61347 falloc() 6897
6848 { 6898
.!l849 resister struct file *fp; 6899
Reproduced under licance f~Qrn the Weste~~ El~ctric COm?2nS; NY ~eprodu=ed wn~a~ lic~~=2 fro"i ~hE Weste!'n EIE~::tr:t Co,~p2ri~~ ~~y
Cop~risht, J. Lions1 1976 Cop~risht, J. Lions" 1976
Sheet 68 Sheet 68
Ma~ 24 12:55 1976 unix/alloc.c Page 1 Ma~ 24 12:55 1976 unix/alloc.c Page 2
Sheet 69 Sheet 69
Maw 24 12:55 1976 unix/alloc.c PaSe 3 Maw 24 12:55 1976 unix/alloc.c Page 4
Reprodcced C~dET li2enco f~om tM~ ~2£~2rn E12ctric C02?an~r NY ~C?I-'rodu~s'd unc::- li:::<.~G r·"'Oh. '~:tE :.:25.tern El\;c~;':;'2 CDi;:P':',-::!~' :~:~
Copwright, J. Lions. 1976 Ccpwright. J. Lions, 1976
Sheet 70 Sheet 70
May 24 12:55 1976 unix/alloc.c Page 5 May 24 12:55 1976 unix/alloc.c Page 6
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
Copyright, J. Lions, 1976 CoPYright, J. Lions, 1976
Sheet 71 Sheet 71
Ma~ 24 12:55 1976 unix/alloc.c Pa~e 7 Ma~ 24 12:56 1976 unix/i~et.c Pa~e 1
7200 7250 i
7201 updateC) 7251 iinclude • •• /param.h"
n02 { 7252 iinclude • •• /s~stm.h"
7203 re~ister struct inode lip; 7253 tinclude • •• /user.h"
7204 re~ister struct mount *mp; 7254 iinclude " •• /inode.h"
7205 re~ister *bp; 7255 iinclude • •• /fils~s.h"
n06 7256 tinclude ·~~/conf~h·
7207 ifCupdlock) 7257 iinclude " •• /buf.h"
7208 return; 7258
7209 updlocktt; 7259 1*
7210 forCmp = &mountCO]; mp < &mountCNMOUNTJ. mptt) 7260 * Look UP an inode by device.inumber.
7211
'7212
ifCmp-)m_bufp != NULL) {
ip = mp->m_bufp-)b_addr;
7261 *
If it is in core (in the inode structure),
7262 * honor the lockin~ protocol.
7213 ifCip-)s_fmod==O :: ip-)s_ilock!=O :: 7263 * If it is not in core, read it in from the
721,4 ip-)s_flock!=O :: ip-)s_ronl~!=O) 7264 * specified device.
'7215 continue; 7265 * If the inode is mounted on, perform
'7216 bp = ~etblkCmp-)m_dev, 1); 7266 * the indicated indirection.
'7217 ip-)s_fmod = 0; 7267 * In all cases, a pointer to a locked
'7218 ip-)s_timeEO] = timeEO]; 7268 * inode structure is returned.
72:l9 ip-)s_timeE1J = timeCl]; 7269 *
'72~~0 bcop~(ip, bp->b_addr, 256); 7270 * printf warnin~: no inodes -- if the inode
'7221 bwriteCbp) ; 7271 * structure is full
72~~2 } 7272 * panic: no imt -- if the mounted file
n23 forCip = &inodeCO]; ip <
&inodeENINODEJf iptt) 7273 * s~stem is not in the mount table.
'7224 ifCCip-)i_fla~&ILOCK) == 0) { 7274 * 'cannot happen"
"72:-!5
7226
ip-)i_flaS =: ILOCK;
iupdatCip, time);
7275
7276
*'
i~etCdev, ina)
7227 prele(ip); 7277 {
'7228 } 7278 re~ister struct inode *P;
'7229 IJPdlock = 0; 7279 re~ister *ip2;
'7230 bfIIJshCNODEV) ; 7280 int hp1;
}231 } 7281 re~ister struct mount *ip;
}232 1* ------------------------- *1 7282
}233 1* ------------------------- *1 7283 loop:
'7234 7284 ip = NULL.
n35 7285 for(p = &inodeCO]; p < &inodeCNINODE]; pt+) {
'7236 7286 if(dev==p->i_dev && ino==p-)i_number) {
n37 7287 if«p-')Lf1a~&ILOCK) != 0) {
'7:;'!38 7288 p-)i_fla~ =i IWANTi
}~!39 7289 sleep(p. PINOD),
'7240 7290 ~oto loop;
7241 7291 }
'7242 7292 if( (p->Lfla~&IMOUNTl != 0) {
}243 7293 for (ip = &mountCO];
7244 7294 ip < &mountCNMOUNT]; iptt)
'7245 7295 if (ip-)m_inodp == p) {
n46 7296 dey = ip->m_dev;
'7247 7297 ina = ROOTINO;
'7248 7298 ~oto loop;
7249 7299 }
Reproduced under licence from the Western Electric Company, NY Reproduced under lic~nce frGffi the Western Elec~Tic Com?snYr NY
Cop~ri~ht, J. Lions, 1976 Cop~ri~ht. J. Lions, !976
Sheet 72 Sheet 72
Ma~ 24 12:56 1976 unix/iget.c Page 2 Ma~ 24 12:56 1976 unix/iget.c Page 3
Reproduced under licence from the Western Electric Compan~, NY Reproduced under licence from the Western Electric Companw, NY
Copwright, J. Lions, 1976 Copwright, J. Lions, 1976
Sheet 73 Sheet 73
Maw 24 12:56 1976 unix/iSet.c PaSe 4 Maw 24 12:56 1976 unix/iset.c PaSe 5
Sheet 74 Sheet 74
Maw 24 12:56 1976 unix/nami.c Pa~e 1 Maw 24 12:56 1976 unix/nami.c Page 2
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
Copwright, J. Lions. 1976 Copyright. J. Lions, 1976
Sheet 75 Sheet 75
May 24 12:56 1976 unix/nami.c Pa~e 3 Maw 24 12:56 1976 unix/nami.c Page 4
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
CoPYri~ht. J. Lions. 1976 Copwright. J. Lions, 1976
Sheet 76 Sheet 76
Ma~ 24 12:56 1976 unix/pipe.c Pa~e 1 May 24 12:56 1976 unix/pipe.c Page 2
**
7711 pipes will be implemented in LARGe 7761 resister *rp, *ip;
"1712 files, which is probabl~ not sood. 7762
7713 *1 7763 rp
"7714 7764 ip
7715 idefine PIPSIZ 4096 7765 loop:
'7716 7766 1* Very conservative locking.
n17 1* The s~s-pipe entr~. 7767 *1
"7718 * Allocate an inode on the root device. 7768 plocldip);
"1719
"7720
* Allocate 2 file structures.
* Put it all tosether with flass.
7769 1* If the head (read) has causht UP with
* the tail (write), reset both to O.
7770
'7721 *1 7771 *1
"1722 7772 if(rp->f_offsetCIJ == ip->i_sizel) -(
"7"723 pipe() 7773 if(rp-)f_offset[lJ != 0) (
"1724 { 7774 rp-)f_offset[IJ = 0;
}72S 7775 ip->i_sizel :: 0;
7726 int r; 7776 if(ip->i_mode&IWRITE) (
"172} 7777 ip->i_mode =& NIWRITE;
"7"728 ip = ialloc(rootdev); 7778 wakeup(ip+l);
"7729 if(ip == NULL> 7779 }
'7730 return; 7780 }
'7731- rf = falloc(); 7781
'7732 if(rf == NULL) ( 7782 1* If there are not both reader and
l733 iput< ip) ; 7783 * writer active, return without
"7734 return; 7784 * satisf~ing read.
"7735 } 7785 *1
"7736 r u.u_arO[ROJ; 7786 prele(ip) ;
"7737 wf = falloc(); 7787 if(ip->i_count < 2)
"7738 if(wf == NULL) { 7788 return;
7739 rf->f_count = 0; 7789 ip->i_mode =l IREAD;
"7"740 u.u_ofile[rJ = NULL; 7790 sleep(ip+2, PPIPE);
7"741 ipfJt(ip)j 7791 goto loop;
'7742 retfJrn; 7792 }
"7743 } 7793 1* Read and return
7744 u.u_arOCRIJ = u.u_BrO[ROJ; 7794 *1
7745 u.u_arOCROJ = r; 7795 fJ. u_offset[OJ 0;
"7746 wf->f_flag = FWRITElFPIPE; 7796 u.u_offset[IJ rp->f _offset,[ 1 J;
7747 wf->f_inode = ip; 7797 readi(ip);
"7748 rf->f_flas = FREADlFPIPE; 7798 rp->f_offset[l] = u.u_offset[l];
"7:'49 rf->f_inode =ip; 7799 prele(ip);
Reproduced under licence from the Western Electric Compan~, NY Reproduced under licence from the Western Electric Compan~, NY
Cop~risht, J. Lions, 1976 Cop~ri~ht. J. Lions, 1976
Sheet 77 Sheet 77
May 24 12:56 1976 unix/pipe.c PaSe 3 May 24 12:56 1976 unix/pipe.c PaSe 4
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Co~pany, NY
Copyright. J. Lions, 1976 Copyright. J. Lions, 1976
Sheet 78 Sheet 78
Ma~ 26 15:24 1976 unix/tts.h Page 1 Mas 26 15:24 1976 unix/ttw.h Page 2
7900 1* 7950
7901 * A clist structure is the head 7951 tdefine TTIF'RI 10
1902 * of a linked 11st aueue of characters. 7952 tdefine TTDF'RI 20
7903 ** blocks
The characters are stored in 4-word 7953
'i'
7904 containing a link and 6 characters. 7954 tdefine CERASE 1* default special characters */
7905 * The routines getc and putc (m45.s or m40.s) 7955 idefine CEDT 004
7906 * manipulate these structures. 7956 tdefine CKILL / @/
7907 *1 7957 iFdefine CQUIT 034 1* FS, cntl shift L *1
7908 struct clist 7958 idefine CINTR 0177 1* DEL *1.
7909 { 7959
7";>1 0 int c .. cc' 1* character count *1 7960 1* limits *1
7'.?11 int c_cf' 1* pointer to first block *1 7961 idefi.ne TTHIWAT 50
]'112 int c_cl; 1* pointer to last block *1 7962 "'define TTLOWAT 30
]913 }; 7963 tdefine TTYHOG 256
]'?14 Ill< *1 7964
7915 7965 1* modes *1
]'i'16 1* 7966 idefine HUPCL 01
7917 * A tts structure is needed for 7967 idefine XTABS 02
]9113 * each UNIX character device that 7968 tdefine LCASE 04
]'i'19 * is used for normal terminal 10. 7969 :idefine ECHO 010
7920 * The routines in ttw.c handle the 7970 tdefine CRMOD 020
7921 * common code associated with 7971 idefine RAW 040
7'i'22 * these 5tructures. 7972 tdefine ODDP 0100
7'123 * The definition and device dependent 7973 idefine EVENP 0200
"7924
792~5
* li<1
code i.s in each driver. (kl.c dc.c dh.c) 7974
7975
:idefine
tdefinE~
NLDELAY
TBDEL('W
001400
006000
7'i''.:.'6 struct tt~1 7976 tdefine CRDELAY 030000
7977 tdefine VTDELAY 040000
792El struct clist t_rswal 1* input chars right off device *1 7978
7929 struct clist t_csna' 1* input chars after erase and kill *1 7979 1* Hardware bits */
7'130 struct clist t_outa; 1* output list to device *1 7980 iFdf?fine DONE 0200
7931 int t_flaSs; 1* mode, settable bs stts call *1 7981 ""define IENABLE 0100
7932 int *t_addr; 1* device address (register or 7982
'79:5:3 startup fcn) li<1 7983 1* Internal state bits *1
]934 chaT' t_.delcU 1* number of delimiters in raw a *1 7984 .define TIMEOUT 01 1* Dela~ timeout in proaress *1
]'i'3~) char t_col; 1* printing column of device *1 7985 iFdefine WOPEN O? 1* Waitina for open to
] 'i'3 {, chaT' t_erasey 1* erase character *1 7986 COITIP I €~te *1
79:57 chaT' t_kill; 1* kill character *1 7987 'ltdefine ISOPEN 04 1* Device is open *1
]938 char t_state' 1* internal state. not visible 7988 iFdefine SSTMH 010 1* Has speci.aJ. start routine
7939 e;·:ternall~ *1 7989 at addr *1
7940 chaT' 1* character temporar~ *1 7990 iFdefine CARR._ON 020 1* Softwal'e cop~ of
7941 int t,_speeds; Ill< outputtinput line speed *1 7991 ca rr i e r"'p resent *1
7942 int t._dev; 1* device name *1 7992 :B'de'fine BUSY 040 1* Output in PT'Oal'ess *1
7S'43 }; 7993 tdefinE~ ASL.EEP 01.00 1* Wakeup wl'wn Clutput done *1
7944 Ill< ------------------------- *1 7994
794!5 7995
7'14/, 7996
7947 char partab[]; 1* ASCII table! paritw, character class *1 7997
7'148 7998
7949 7999
Reproduced under licence from the Western Electric Compans. NY Reproduced under licence from the Western Electric Company, NY
Copsrisht. J. Lions, 1976 Copyright. J. Lions, 1976
Slwet 79 Sheet. 79
Ma~ 26 15:24 1976 unix/kl.c Pase 1 May 26 15:24 1976 unix/kl.c Pase 2
8000 J B050 }
B001 1* KL/DL-11 driver *1 8051 addr-)klrcsr ==/ IENABLE/DSRDYIRDRENB;
8002 iincl'Jde " •• /param.h' 8052 addr-)kltcsr ==/ IENABLEf
EI003 "'include " •• /conf.h" 8053 }
8004 iincl'Jde " •• /user.h" 8054 1* ------------------------- *1
EI005 ~include " •• /tt~.h" 8055 klclose(dev)
8006 tinclude " •• /proc.h' 8056 { re~ister struct tty *tp;
8007 1* base address *1 8057 tp == &kI11[dev.d_minorJ.
8008 "'define KLADDR 0177560 1* console *1 8058 wflushtty(tp);
8009 idefine KLBASE 0176500 1* kl and dll1-a *1 8059 tp-)t_state == 0;
BOlO tdefine DLBASE 0175610 1* dl-e *1 8060 }
BOll idefine NKLil 1 8061 I I -------------------------
El012 idefine NDLil 0 8062 klread(dev)
80:L3 idefine DSRDY 02 8063 { ttreadC&kl11[dev.d_minorJ);
El014 idefine RDRENB 01 8064 }
El015 struct tty kll1[NKL11tNDLllJ; 8065 1* -------------------------
801.6 struct klress { 8066 klwrite(dev)
El017 int klrcsr; 8067 { ttwrite(&klllCdev.d_minor]);
8018 int kl rbuf; 8068 }
B019 int kltcsr; 8069 1* -------------------------
::1020 int kl tbuf; 8070 kl:-:int(dev)
El021 } 8071 { resister struct tty *tp;
El022 1* 8072 tp == &kll1[dev.d_minor];
8023 klopen(dev, flas) 8073 ttstart(tp);
8024 { resister char *addr; 8074 if (tp-)t_outG.c_cc == 0 1/ tp-)t_outG.c_cc -- TTLOWAT>
802!'i register struct tty *tp; 8075 wakeup(&tp-)t_outG),
El026 if(dev.d_minor )= NKL11+NDL11) { 8076 }
8027 u.u~error = ENXIO; 8077 I I -------------------------
8028 T'eturn; 8078 klrint(dev)
8029 } 8079 { resister int c, *addr;
8030 tp &kl11[dev.d_minorJ; 8080 register struct tty *tp;
EI031 if (u.u_procp-)p_ttyp == 0) { 8081 tp = &klll[dev.d_minor];
8032 u.u_procp-)p_ttyp tp; 8082 addr = tp-)t_addr;
ao~n tp-)t_dev == dey; 8083 c = addr-)klrbuf;
8034 } 8084 addr-)klrcsr =1 RDRENB;
8035 1* set UP minor 0 to address KLADDR 8085 if «c&0177)==0)
8036 * set UP minor 1 thru NKL11-l to address from KLBASE 8086 addr-)kltbuf = c; 1* hardware botch*1
El037
8038
*
set
*I
UP minor NKLII on to address from DLBASE 8087
8088 }
ttyinputCc, tp);
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric COffiPany, NY
Copyrisht, J. Lions. 1976 Copyright, J. Lions, 1976
Sheet 80 Sheet 80
Hay 26 15:25 1976 unix/tty,c Page 1 Hay 26 15:25 1976 unix/tty.c Page 2
8100 t 1* general TTY subroutines *1 8150 1* structure of device registers for KL, DL, and DC
8151 *
interfaces-- more particularly, those for which the
8:101
8102 tinclude ",./param,h" 8152 *
SSTART bit is off and can be treated by general routines
8103 tinclude ',./sYstm.h' 8153 *
(that is, not DH).
8104 tinclude ""/user,h" 8154 *1
8105 tinclude ',./tty.h' 8155 str'Jct {
8106 tinclude ' •• /proc.h' 8156 int ttrcsr;
8107 tinclude ' •• /inode.h' 8157 int ttrbufl
8108 iinclude '.,/file.h' 8158 int tttcsr;
8109 iinclude ".,/reg.h' 8159 int tttbufl
8110 tinclude " •• /conf.h' 8160 H
8111 8161 1* ------------------------- *1
8112 1* Input mapping table-- if an entry is non-zero, when the 8162 1* The routine implementing the gtty system call.
8:113 *
corresponding character is typed preceded by ' \ ' the 8163 *Just call lower level routine and pass back values.
8114 * escape seauence is replaced by the table value. 8164 *1
8115 * Mostly used for upper-case only terminals. 8165 gtty()
8116 *1 8166 (
8117 char maptab[J 8167 int v[3J;
8118 { 8168 register *up, *vp;
8:11 '7 000,000,000,000,004,000,000.000, 8169
8120 000,000,000.000,000,000,000,000, 8170 vp = v;
8121 000,000,000,000,000,000,000,000, 8171 sgtty(vp)'
8122 000,000,000,000,000,000,000,000, 8172 if (u.u_error)
8:123 000,': '.OOO,'t',OOO,OOO,OOO,"', 8173 return;
8124 '{','}',OOO,OOO,OOO,OOO,OOO,OOO. 8174 UP = u,'J_arg[OJ.
8125 000,000,000,000,000,000,000,000, 8175 suword(up, *vp++l;
8:126 000,000,000,000,000,000,000,000, 8176 suword(++up, *vp++l;
8127 '@',OOO,OOO,OOO,OOO,OOO,OOO,OOO. 8177 suword(++up, *vp++);
iH28 000,000,000,000,000,000,000,000, 8178 }
812'7 000,000,000,000,000,000,000,000, 8179 1* ------------------------- *1
8:130 OOO,OOO,OOO,OOO,OOO,OOO,'N',OOO. 8180 1* The routine implementing the stty system call.
8:[;31 OOO,'A','B','C','D','E','F','G', 8181 * Read in values and call lower level.
8132 .fH.I,'I','J',I"K',.IL',.IM','N','OJ', 8182 *1
8133 'P','Q','R','S/,'T','U','V','W', 8183 stty()
8134 'X','Y','Z',OOO,OOO,OOO,OOO,OOO, 8184 (
8135 H 8185
El:L36 1* ------------------------- *1 8186
8137 1* The actual structure of a clist block manipulated by 8187 'JP = u.u_arg[OJ,
::l:l38 * getc and putc (mch.s) 8188 u.u_arg[OJ fuword(up)'
8139 *1 8189 u.u_arg[lJ fuword(++up);
8140 struct cblock { 8190 u.u_arg[2J fuword(++up)'
8141 struct cblock *c_next; 819:1 sgtty(O).
8142 char info[6J' 8192 }
8143 H 8193 1*
::1144 1* ------------------------- *1 8194 n Stuff common to stty and gtty.
::1145 '* The character lists-- space for 6*NCLIST characters *1
struct cblock cfree[NCLISTJ;
8195
8196 * Check legality and switch out to individual
device routine.
8146
8197 * v is 0 for stty; the parameters are taken from u.u_argCJ.
8147
::1148 1* List head for unused character blocks. *1 8198 * c is non-zero for gtty and is the place in which the
8:l4'7 struct cblock *cfreelist. 8199 ** device routines place their information.
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
Copyright, J. Lions. 1976 Copyright, J. Lions, 1976
Sheet 81 Sheet 81
May 26 15:25 1976 unix/tty.c Pa~e 3 May 26 15:25 1976 unix/tty.c Pa~e 4
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
CoPYrisht, J. Lions, 1976 CoPYri~ht, J. Lions, 1976
Sheet 82 Sheet 82
Ma~ 26 15:25 1976 unix/ttv.c PaSe 5 Ma~ 26 15:25 1976 unix/tt~.c PaSe 6
tl331
f.1332 */
*
tt~ structure. 8381
8382
rtp = t,p;
c = ac&OiT;;
::1:333 tt~input(ac, atp) 83K1 1*Ignore EOT in normal mode to avoid hang inS UP
fl;334 struct tt~ latp, 8384 I certain terminals.
8335 -{ 8385 *I
tl~336 resister int t_flass, c, 8386 if (c==004 && (rtp-)t_flaSs&RAW)==O)
tl33? register struct ttw *tp; 8387 return,
83~'i8 8388 1*Turn tabs to spaces as reauired
El3:W tp = atp, 8389 *I
• ::1340 c :::: ac~ 8390 if Cc=='\t' && rtp-)t_flags&XTABS) -(
El341 t_flaSs = tp-)t_flaSs, 8391 do
8342 if «c =& (177) == '\r' &1 t_flags&CRMOD) 8392 ttwoutput C' " rtp);
::1343 c =:: i\ni; El393 while (rtp-)t_col&07);
:,1344 if' «t_fla!~sIRAW)""=O && (c==CQUIT :: c==CINTR» -{ 8394 return.
::1345 siSnalCtp, c==CINTR? SIGINT:SIGQIT); 8395 }-
El346 flushttw(tp), 8396 /* for upper-case-onl~ terminals,
::1347 return; 8397 * generate escapes.
El348 }- 8398 */
tl349 if (tp-)t_rawa.c_cc)=TTYHOG) -{ 8399 if (rtp-)t_flass&LCASE) -{
Reproduced under licence from the Western Electric Companw, NY Reproduced under licence from the Western Electric Companw, NY
Copwrisht, J. Lions, 1976 Cop~right. J. Lions, 1976
Sheet 83
May 26 15:25 1976 unix/tty.c PaSe 7 May 26 15:25 1976 unix/tty.c PaSe 8
Sheet 84 Sheet 84
Ma~ 26 15:25 1976 unix/ttw.c Page 9 May 26 15:25 1976 unix/tty.c Page 10
8500 * here, using the protocol of the single-line interfaces 8550 ttwrite(atp)
1
:,1~50 * (kI, dl, dc); otherwise the address word of the tty 8551 struct tty *atp;
a~j02 * structure taken to be
1S the name of the device-dependent 8552 (
::1503 * start-up routine. 8553 register struct tty *tp;
tl504 *1 8554 l'egister int c;
8~:;05 ttstart(atp) 8555 tp = atp;
:,1506 struct tt~ *atp; 8556 if (Ctp-)t_stateICARR_ON)==O)
:,1507 { 8557 return;
:3508 register int taddr, ci 8558 while CCc=cpassC»)=O) (
8::;09 register struct tty *tp; 8559 spl5CH
:,l~:; 1. 0 struct ( int Ctfunc)C); }; 8560 while ctp-)t_outG.c_cc ) TTHIWAT) (
:,l~511 8561 ttstartCtp);
~1~512 tp = atp; 8562 tp-)t_state =: ASLEEP,
:,l~)13 addr = tp-)t_addr; 8563 sIeepCltp-)t_outG, TTOPRI);
a~5:l4 if (tp-)t_stateISSTART) ( 8564 }
8~515 C*addr.func)(tp); 8565 spIO();
::I5:l6 return; 8566 ttYoutputCc, tp);
::l~51"7 } 8567 }-
::I5:L8 if CCaddr-)tttcsrIDONE)==O :: tp-)t_state&TIMEOUT) 8568 ttstartCtp);
:,l~5
.l9 return; 8569
8520 if CCc=SetcCltp-)t_outG» )= 0) ( 8570
::I~52J. if Cc<=0177) 8571 Common code for gtty and stty functions on tspewriters.
::J!522 addr-)tttbuf = c (partab[c]&0200); 8572 If v is non-zero then gtty is beins done and information
:,152:~ else ( 8573 * is passed back therein,
::J!524 timeoutCttrstrt, tp, cI0177); *
8!:'i74 if it is zero stts is being done and the input inform-
tp-)t_state =: TIMEOUT, 8575 * ation is in the u_arg arra~.
} 8576 *1
::1527 } 8577 ttsstts(atp, av)
::I~528 } 8578 int *atp, *av;
::1529 1* ------------------------- *1 8579 -(
::1530 1* Called from device's read routine after it has 8580 register *tp, *v;
8531 * calculated the ttY-structure given as argument. 8581 tp == atp;
8532 * The pc is backed UP for the duration of this call. 8582 ifCv == av) (
::1533 * In case of a caught interrupt, an RTI will re-execute. 8583 *v++ == tp-)t_speeds;
::l~534 *1 8584 v-)lobste = tp-)t_erase;
:::J5:3~5 ttl-eadCatp) 8585 v-)hibste == tp-)t_killl
8536 struct ttw *atp; 8586 vel] == tp-)t_flagsl
~1~537 { 8587 l'f?tlJ rn CI ) ;
8~538 register struct tts *tp; 8588 }
~1~53'1 8589 wflushtts ctp)'
• 8!:;40 tp = atp, 8590 v == IJ.IJ_arg'
8541 if (ctp-)t_stateICARR_ON)==O) 85'11 tp-)t_speeds = *v+tl
::J!542 retu rro' 8592 tp-)t_erase = v-)lobyte;
:,l~j4~1 if Ctp-)t_caroG. c_cc :: canon (h» ) 8593 tp-)t_kill == v-)hibste;
• 8~544 while (tp-)t_canG.c_cc II passcC~etcC&tp-)t_canG»)=O); 8594 tp-)t_flags = v[l],
::1~54~5 } 8595 return(O);
8546 1* ------------------------- *1 8596 }-
El~547 1* Called from the device's write routine after it has 8597 1*
:,1548 * calculated the tts-structure given as argument. 8598
::1:54'1 *l 8~'599
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Compans, NY
Copsriaht, J. Lions, 1976 CoPYright, J. Lions, 1976
:3hf-"et 85 Sheet 85
Maw 26 15:25 1976 unix/pc.c Pase 1 Maw 26 15:25 1976 unix/pc.c PaSe 2
Reproduced under licence from the Western Electric Companw. NY Reproduced under licence from the Western Electric Companw, NY
Copwrisht. J •. Lions. 1976 CopwriSht, J. Lions, 1976
Sheet 86 Sheet 86
Ma~ 26 15:25 1976 unix/pc.c Page 3 Ma~ 26 15:25 1976 unix/pc.c Page 4
Reproduced under licence from the Western Electric Compan~, NY Reproduced under licence from the Western Electric Company, NY
Cop~right. J. Lions. 1976 CoPYright, J. Lions, 1976
Sheet 87 Sheet 87
May 26 15125 1976 unix/lp.c PaSe 1 May 26 15125 1976 unix/lp.c PaSe 2
8a06 *
*1 8856
8857
}
Ipll,flaS =: (INDIEJECTIOPEN);
sa07
8808
aa09 .
tinclude " •• /param.h"
tinclude •• /conf.h"
tinclude " •• /user.h"
8858
8859
8860 }
LPADDR-)lpsr =: IENABLE;
Ipcanon(FORM);
•
a810
8811
LPADDR 0177514
8861
8862
1* ------------------------- *1
8812 tdefine
8813 8863 IpcloseCdev, flaS)
a814 tdefine IENABLE 0100 8864 {
8815 tdefine DONE 0200 8865 Ipcanon(FORM);
8816 8866 Ipl1.flaS = 0;
8EI17 tr.;lefine LF'PRI 10 8867 }
8a18
8a19
tdefine
tdefine
LPLWAT
LPHWAT
50
100
8868
8869
1* ------------------------- *1
8820 tdefirie EJLINE 60 8870 lpwri te ( )
E1E121 tdefine MAXCOL 80 8871 {
El822 8872 reSister int c;
8823 strlJct { 8873
8824 int lpsr; 8874 while «c=cpassC»)=O)
8825 int IpblJf; 8875 Ipcanon(c);
8826 H 8876 )-
81327 1* ------------------------- *1 8877
8878
1* ------------------------- *1
88213
8829 strlJct { 8879 Ipcanon(c)
8830 int cc; 8880 {
8831 int cf; 8881 reSister c1, c2;
8832 int cU 8882
8833 int flaS; 8883 c1 == c;
8834 int mcc; 8884 ifClp11.flaS&CAP) {
8835 int 8885 ifCc1)='a' && cl<='z')
8836 int 8886 c 1 =t ' A' - , a ' ; else
8837 } Ipll; 8887 switchCci) {
8838 1* ------------------------- *1 8888
8839 8889 case '{':
8840 tdefine CAP 01 1* Set to 0 for 96-char printer, 8890 c2 '(';
8841 else to 01 *1 8891 goto esc; •
8842 tdefine EJECT 02 8892
8843 idefine OPEN 04 8893 case '}.f :
8844 tdefine IND 010 1* Set to 0 for no indent, 8894 c2 / ) ;/;
8845 else to 010 *1 8895 Soto esc; •
8846 8896
8847 idefine FORM 014 8897 case \ , :
;/
Reproduced under licence from the Western Electric Company, NY Reproduced under licence from the Western Electric Company, NY
·CopyriSht, J. Lions, 1976 CopyriSht, J. Lions, 1976
Sheet 88 Sheet 88
May 26 15:25 1976 unix/lp.c Page 3 May 26 15:25 1976 unix/lp.c PaSe 4
8900
:3901
::I';'()2
case "
c2
,
I ,.
~
.
~
I .. ;
8950
8951
8952
if(lpl1.ccc < Ip11.mcc) -(
IpolJtplJt('\r');
Ipl1.mcc = 0;
::1';>03 £lata esc, 8953 }
ifClpl1.ccc < MAXCOLI {
::1904
::1905 case " +N ~
.
...... , ,
8954
8955 while(lp11.ccc ) Ipl1.mcc) -{
, ::1906
::1907
c2 /.. 8956
8957
IpolJtput C' 'i;
Ipl1.l1lcc+·H
:390B esc: 8958 }
::!909 Ipcanon(c2); 8959 IpOlJtpl.Jt C(1) ;
as':lO Ipl1. ccc-·_' 8960 Ipll.mcc·H;
::IS'1:L cl = "_/; 8961 }
::IS'I::! } 8962 Ipl1.ccc++i
89:13 } 8963 }
::1914 8964 }
fl915
fl9:l6
sw itch ( c1) -( 8965 1* ------------------------- 1/
8966
as'17 case ' \ t' : 8967 Ipstal't<)
fl9:lB lpll.eec (lpll.eect8) & N7; 8968 -{
::IS':l 9 return, 8969 l'esistel' int c;
::1920 8970
:3921 ease FORM: 8971 while (LPADDR-)lpsrIDONE II (e setc(llpl1»?= 0)
tl922 case :\n": 8972 LPADDR-)lpblJf = c;
::1923 if«lpl1.flasIEJECT) == 0 :: 8973 }
::1924 Ipl:l.mcc!=O :: Ipl1.mlc!=0) { 8974 II ------------------------- 1/
:392~) Ipl1.mcc = O. 8975
~1926 Ipl1.mlc+·H 8976 lpint()
fln7 if(lp11.mlc )= EJLINE II Ip11.flasIEJECT) 8977 (
:39213 c1 " FOf(M; 8978 l'esistel' int c;
:3929 Ipoutput(cl); 8979
::1930 if(c! == FORM) 8980 lpstsl't();
::1';>31 Ipl1.mlc 0; 8981 if (lpl1.cc == LPLWAT :: Ipl1.cc 0)
::J9~52 } 8982 wakeup(llpl1);
a9~53 8983 }
::1934 case i \T' I :
8984 II ------------------------- II
::193~:; Ipl1.ccc = 0; 8985
~19:-I6 if(lp11.flasIIND) 8986 lpoutput(c)
::19~57 Ipl1.ccc = 8; 8987 {
::l9~3B return; 8988 if (lpl1.cc ?= LPHWAT)
89:-19 8989 sleep(llp11. LPPRI);
fl940 case 010: 8990 putc(c, Ilpl1);
894l if(lpl:L.cec ) 0) 8991 sp14();
::1'i'42 l.pl1.eec---; 8992 IF··stal't().
894~5 return, 8993 spIO();
• 8944
:3 ~)45 case " "!
8994
8995
}
/I
::1946 Ipl1.ccc++' 8996
fl947 l'eturn; 8997
::1948 8998
::1949 default; 8999
Reproduced undel' licence from the Western Electric Compans, NY Repl'oduced under licence fl'om the Western Electric Compans, NY
COPsl'isht. J. Lions, 1976 COPYl'isht, J. Lions. 1976
Sheet 89
Maw 26 15:25 1976 unix/mem.c Pa~e 1 Maw 26 15:25 1976 unix/mem.c Pa~e 2
Reproduced under licence from the Western Electric Cdmpanw, NY Reproduced under licence from the Western Electric Companw, NY
Copwri~ht, J. Lions, 1976 Copwri~ht, J. Lions, 1976
Sheet 90 Sheet 90