+/*
+ * Setup the paging constants for the clock algorithm.
+ * Called after the system is initialized and the amount of memory
+ * and number of paging devices is known.
+ */
+setupclock()
+{
+
+ /*
+ * Setup thresholds for paging:
+ * lotsfree is threshold where paging daemon turns on
+ * desfree is amount of memory desired free. if less
+ * than this for extended period, do swapping
+ * minfree is minimal amount of free memory which is
+ * tolerable.
+ *
+ * Strategy of 4/22/81:
+ * lotsfree is 1/4 of memory free.
+ * desfree is 200k bytes, but at most 1/8 of memory
+ * minfree is 64k bytes, but at most 1/2 of desfree
+ */
+ if (lotsfree == 0)
+ lotsfree = LOOPPAGES / 4;
+ if (desfree == 0) {
+ desfree = (200*1024) / NBPG;
+ if (desfree > LOOPPAGES / 8)
+ desfree = LOOPPAGES / 8;
+ }
+ if (minfree == 0) {
+ minfree = (64*1024) / NBPG;
+ if (minfree > desfree/2)
+ minfree = desfree / 2;
+ }
+
+ /*
+ * Maxpgio thresholds how much paging is acceptable.
+ * This figures that 2/3 busy on an arm is all that is
+ * tolerable for paging. We assume one operation per disk rev.
+ */
+ if (maxpgio == 0)
+ maxpgio = (DISKRPM * 2) / 3;
+
+ /*
+ * Clock to scan using max of ~~10% of processor time for sampling,
+ * this estimated to allow maximum of 200 samples per second.
+ * This yields a ``fastscan'' of roughly (with CLSIZE=2):
+ * <=1m 2m 3m 4m 8m
+ * 5s 10s 15s 20s 40s
+ */
+ if (nswdev == 1 && physmem*NBPG > 2*1024*(1024-16))
+ printf("WARNING: should run interleaved swap with >= 2Mb\n");
+ if (fastscan == 0)
+ fastscan = (LOOPPAGES/CLSIZE) / 200;
+ if (fastscan < 5)
+ fastscan = 5;
+ if (nswdev >= 2)
+ maxpgio = (maxpgio * 3) / 2;
+
+ /*
+ * Set slow scan time to 1/2 the fast scan time.
+ */
+ if (slowscan == 0)
+ slowscan = 2 * fastscan;
+#ifdef notdef
+ printf("slowscan %d, fastscan %d, maxpgio %d\n",
+ slowscan, fastscan, maxpgio);
+ printf("lotsfree %d, desfree %d, minfree %d\n",
+ lotsfree, desfree, minfree);
+#endif
+}
+