In 4th Ed the relevant code is in nsys/ken/clock.c, where the clock interrupt (60Hz, US mains frequency) increments the time[0]:time[1] count every 60 interrupts, more or less:
The time() syscall then just copies the current values of time[0]:time[1] to the user's registers.
The only earlier extant kernel code than this is 1st Ed, which is in assembly (in file u4.s), and just increments the time variable pair unconditionally on every clock interrupt:
clock: / interrupt from 60 cycle clock
mov r0,-(sp) / save r0
tst *$lks / restart clock?
mov $s.time+2,r0 / increment the time of day
inc (r0)
bne 1f
inc -(r0)
1:
I wouldn't be surprised if changing the frequency of time() was one of the things that happened in the asm-to-C conversion (given that 3rd Ed was also asm).
no subject
Date: 2014-11-22 23:23 (UTC)The only earlier extant kernel code than this is 1st Ed, which is in assembly (in file u4.s), and just increments the time variable pair unconditionally on every clock interrupt:
I wouldn't be surprised if changing the frequency of time() was one of the things that happened in the asm-to-C conversion (given that 3rd Ed was also asm).