1
0
mirror of https://github.com/DoctorWkt/pdp7-unix.git synced 2026-01-25 11:47:35 +00:00

system comments

This commit is contained in:
Phil Budne 2016-03-03 02:02:46 -05:00
parent d33ce4c69f
commit df75edde3c
6 changed files with 141 additions and 115 deletions

View File

@ -3,22 +3,22 @@
.. = 0
t = 0
orig:
hlt
jmp pibreak
hlt " overwritten with interrupt return addr
jmp pibreak " dispatch to interrupt processing
. = orig+7
-1
-1 " only ever set (to -1): never read?!
. = orig+020
1f
iof
dac u.ac
lac 020
dac 1f
. = orig+020 " syscall (CAL) processing
1f " addr for "CAL I": store return here on "CAL"
iof " interrupts off
dac u.ac " save user AC
lac 020 " save user return addr
dac 1f " save as if "CAL I"
lac 1f-1
dac 020
lac u.ac
jmp 1f+1
dac 020 " restore location 20
lac u.ac " restore user AC
jmp 1f+1 " join "CAL I" processing
1f
1: 0
iof " interrupts off
@ -49,7 +49,7 @@ orig:
jmp .. i " dispatch system call
. = orig+0100
jmp coldentry
jmp coldentry " here to start kernel
jms halt
okexit:
@ -77,6 +77,7 @@ sysexit: " common system call exit code
lac u.ac " restore AC register
jmp u.rq+8 i " return to user
" scheduler / idle loop
swap: 0
ion
1:
@ -84,49 +85,49 @@ swap: 0
jmp 1f
jms lookfor; 1 " in/ready
skp
jmp 1b
dzm maxquant
jmp 1b " loop until a process becomes ready
dzm maxquant " here with in/ready (self?)
jmp 3f
1:
dac 9f+t
jms lookfor; 2 " in/notready
1: " here with out/ready process
dac 9f+t " save process pointer (swapped out) in t0
jms lookfor; 2 " in/notready " find a swapped in process to swap out?
jmp 1f
jms lookfor; 1 " in/ready
jmp 1f
jmp 2f
1:
lac swap
dac u.swapret
dac u.swapret " return to scheduler when swapped back
iof
lac o200000
lac o200000 " change status to swapped out
tad u.ulistp i
dac u.ulistp i
ion
jms dskswap; 07000
jms dskswap; 07000 " swap process out
lac u.dspbuf
sna
jmp 2f
law dspbuf
jms movdsp
2:
iof
lac o600000
iof " disable interrupts
lac o600000 " change status (1->7?)
tad 9f+t i
dac 9f+t i
ion
jms dskswap; 06000
lac u.swapret
dac swap
lac o20
ion " enable interrupts
jms dskswap; 06000 " read process in?
lac u.swapret " set our return addr
dac swap " to saved return addr
lac o20 " reset maxquant to 16 ticks
dac maxquant
lac u.dspbuf
sza
sza " using display?
"** 01-s1.pdf page 4
jms movdsp
jms movdsp " yes.
3:
dzm uquant
dzm uquant " no. reset process tick count
iof
jmp swap i
jmp swap i " return
t = t+1
swp: " system call dispatch table

View File

@ -1,15 +1,18 @@
"** 01-s1.pdf page 14
" s3
" call:
" jms searchu; addr
searchu: 0
lac searchu i
dac 9f+t+1
-mnproc
dac 9f+t
law ulist-1
dac 8
lac searchu i " fetch argument
dac 9f+t+1 " in t1
-mnproc " loop counter
dac 9f+t " in t0
law ulist-1 " ulist ptr
dac 8 " in index 8
1:
lac 8 i
lac 8 i " copy ulist entry to lu
dac lu
lac 8 i
dac lu+1
@ -17,65 +20,69 @@ searchu: 0
dac lu+2
lac 8 i
dac lu+3
jms 9f+t+1 i
isz 9f+t
jmp 1b
isz searchu
jms 9f+t+1 i " call argument as subroutine
isz 9f+t " returned: loop done?
jmp 1b " no, do it again
isz searchu " skip argument
jmp searchu i
t = t+2
" look for process:
" jms lookfor; status
" found: ulist ptr in AC
" not found
lookfor: 0
jms searchu; 1f
isz lookfor
isz lookfor
isz lookfor " skip argument
isz lookfor " give skip return
jmp lookfor i
1: 0
1: 0 " worker called by searchu
lac lu
rtl; rtl; and o7
sad lookfor i
skp
jmp 1b i
rtl; rtl; and o7 " bits 0:2 of lu
sad lookfor i " match argument?
skp " yes
jmp 1b i " no, return, keep going
-3
tad 8
tad 8 " roll index 8 back to this entry
and o17777
isz lookfor
jmp lookfor i
isz lookfor " skip argument
jmp lookfor i " non-skip return
.fork:
jms lookfor; 0 " not-used
jms lookfor; 0 " not-used " find an unused process slot
skp
jms error
dac 9f+t
isz uniqpid
jms error " none found- return error
dac 9f+t " save ulist ptr in t0
isz uniqpid " generate new pid
lac uniqpid
dac u.ac
dac u.ac " return in AC
law sysexit
dac u.swapret
lac o200000
dac u.swapret " return from system call when swapped back in
lac o200000 " change process status to out/ready
tad u.ulistp i
dac u.ulistp i
jms dskswap; 07000
lac 9f+t
dac u.ulistp
lac o100000
jms dskswap; 07000 " swap parent out
lac 9f+t " get unused ulist slot back
dac u.ulistp " set ulist pointer
lac o100000 " mark child in/ready
xor u.ulistp i
dac u.ulistp i
lac u.pid
"** 01-s1.pdf page 15
dac u.ac
dac u.ac " return parent pid in AC?
lac uniqpid
dac u.pid
dac u.pid " set child pid
isz 9f+t
dac 9f+t i
isz u.rq+8
dzm u.intflg
jmp sysexit
dac 9f+t i " set pid in process table
isz u.rq+8 " increment return address from sys call
dzm u.intflg " clear int flag
jmp sysexit " return in child process
t= t+1
badcal:
clon
badcal: " bad (unimplemented) system call
clon " clear any pending clock interrupt?
-1
dac 7
dac 7 " set location 7 to -1
.save:
lac d1
jms iget
@ -86,16 +93,16 @@ badcal:
.exit:
lac u.dspbuf
sna
jmp .+3
law dspbuf
sna " process using display?
jmp .+3 " no
law dspbuf " yes
jms movdsp
jms awake
lac u.ulistp i
and o77777
and o77777 " mark process table entry free
dac u.ulistp i
isz u.ulistp
dzm u.ulistp i
dzm u.ulistp i " clear pid in process table
jms swap
.rmes:

View File

@ -1,31 +1,34 @@
"** 01-s1.pdf page 28
" s5
" read/write a process from/to swap space
" call:
" AC/ first word of process table
" jms dskswap; DSLD bits
dskswap: 0
cll; als 3
dac 9f+t
jms dsktrans; -64; userdata; 9f+t; dskswap
lac 9f+t
tad o20
dac 9f+t
jms dsktrans; -4096; 4096; 9f+t; dskswap
isz dskswap
jmp dskswap i
cll; als 3 " get process disk address
dac 9f+t " save in t0
jms dsktrans; -64; userdata; 9f+t; dskswap " read/write user area
lac 9f+t " get swap addr back
tad o20 " advance by 16??
dac 9f+t " save
jms dsktrans; -4096; 4096; 9f+t; dskswap " read/write user memory
isz dskswap " skip bits
jmp dskswap i " return
t = t+1
access: 0
lac i.flags
lmq
lac u.uid
spa
jmp access i
sad i.uid
lrs 2
lacq
and mode " mode from system call
sza
jmp access i
jms error
lmq " save in MQ
lac u.uid " get user id
spa " negative?
jmp access i " yes: super user, return
sad i.uid " compare to file owner
lrs 2 " same: shift flags down two
lacq " get flags back
and mode " mode from system call
sza " access allowed?
jmp access i " yes: return
jms error " no: return error from system call
fassign: 0
-10

View File

@ -255,29 +255,29 @@ pget: 0
t = t+3
iwrite: 0
dac 9f+t
lac iwrite
dac 9f+t " save arg in t0
lac iwrite " load return address
"** 01-s1.pdf page 38
dac iread
dac iread " save as iread return addr
lac cskp
dac iwrite
dac iwrite " set our return addr to "cskp"
jmp 1f
iread: 0
dac 9f+t
lac cnop
lac cnop " set iwrite return to "cnop"
dac iwrite
1:
-1
tad iread i
dac 10
tad iread i " get word before return addr
dac 10 " store in index 8 & 9
dac 11
isz iread
lac iread i
dac 9f+t+1
isz iread
isz iread " increment return addr
lac iread i " load word
dac 9f+t+1 " save in t1
isz iread " increment return addr
lac o70000
xct iwrite
lac i.size

View File

@ -36,11 +36,13 @@ pibreak: " priority interrupt processing "chain"
isz uquant " increment user quantum counter
"** written: ttydelay -> ttyd1
"** written: ttyrestart -> ttyres1
" referenced in iread:
cnop:
nop
-1
dac 7
clon
dac 7 " set location 7 to -1
clon " enable clock interrupts, reset flag
lac ttydelay
spa
isz ttydelay

View File

@ -164,6 +164,16 @@ sysdata:
s.fblks: .=.+10 " free block numbers
s.uniq: .=.+1 " next unique value
s.tim: .=.+2 " (up)time(?) in 60Hz ticks (low, high)
" process table
" first word
" bits 0:2 -- status
" 0: free slot
" 1: in/ready
" 2: in/notready
" 3: out/ready
" 4: out/notready??
" bits 3:17 -- disk swap address/8
" second word: pid
ulist:
0131000;1;0;0
0031040;0;0;0
@ -182,7 +192,7 @@ userdata:
u.uid: -1 " user id
u.pid: 1 " process id
u.cdir: 3 " connected directory (inode number?)
u.ulistp: ulist
u.ulistp: ulist " pointer to process table entry
u.swapret: 0
u.base: 0
u.count: 0
@ -197,9 +207,12 @@ inode:
i.flags: .=.+1 " inode flags
" 400000 free?? (checked/toggled by icreat)
" 200000 large file
" 000040 special? (checked by read/write)
" 000040 special device (indicated by inum)?
" 000020 directory
" 000017 can be changed by chmod.
" 000010 owner read
" 000004 owner write
" 000002 world read
" 000001 world write
i.dskps: .=.+7 " disk block pointers (indirect if "large file")
i.uid: .=.+1 " owner
i.nlks: .=.+1 " link count