Search code examples
cunixassemblypdp-11

UNIX V6 processes swap time


Trying to get how famous UNIX level six kernel works. The question is about where in the source code https://pages.lip6.fr/Pierre.Sens/srcv6/ process switching is triggered?

In the Lions commentary on UNIX source code I meet clock() function in the line 3725. Does it trigger processes swap or does not?

Though enough information on this source code I am stuck due to different style of 197x and 201x programming texts and terminology.


Solution

  • Comment of Margaret Bloom above gave me a clue but I do not see the check mark otherwise I would accept it as an answer. (Apparently because it is just a comment) More unfolded version could be the next:

    1) line 1923 of slp.c says : "Although it is not remarkably evident, the basic synchronization here is on the runin flag, which is slept on and is set once per second by the clock routine. Core shuffling therefore takes place once per second".

    2) Lion's commentary in chapter 11 Clock Interrupts says: "Which ever clock is used, interrupts are generated at line frequency (i.e. with a 50 Hz power supply, every 20 milliseconds)".

    3) line 0147 of the source code: #define HZ 60 / Ticks/second of the clock /.

    4) Chapter 14 Program swapping (par. 14.2): Process #0 executes “sched”. Etc. about runin and runout.

    So clock() is an interrupt service routine (IRS). Function sched() is the process number 0.