-/*
- * 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()
-{
- int nclust, nkb;
-
- /*
- * 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 32k bytes.
- */
- if (lotsfree == 0)
- lotsfree = LOOPPAGES / 4;
- if (desfree == 0) {
- desfree = (200*1024) / NBPG;
- if (desfree > LOOPPAGES / 8)
- desfree = LOOPPAGES / 8;
- }
- if (minfree == 0)
- minfree = (32*1024) / NBPG;
-
- /*
- * 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 400 samples per second.
- * Allow slighly higher angular velocity if 2 or more swap devices,
- * allow max of 600 samples per second (but only >= 2m)
- * Basic scan time for ``fastscan'', the time for a clock rev
- * with given memory and CLSIZE=2:
- * swap ilv <=1m 2m 3m 4m 6m 8m
- * one-way 4s 5s 7s XXX XXX XXX
- * two-way 4s 4s 5s 6s 10s 13s
- * XXXs here are situations we should not be in.
- */
- if (fastscan == 0) {
- nclust = LOOPPAGES / CLSIZE;
- nkb = (LOOPPAGES * NBPG) / 1024;
- if (nswdev == 1 && nkb >= 2*1024)
- printf("WARNING: should run interleaved swap with >= 2Mb\n");
- if (nswdev == 1 || nkb < 2*1024)
- fastscan = nclust / 400;
- else {
- maxpgio = (maxpgio * 3) / 2;
- fastscan = nclust / 600;
- }
- }
- if (fastscan < 4)
- fastscan = 4;
- if (fastscan > maxslp)
- fastscan = maxslp;
-
- /*
- * Set slow scan time to 1/3 the fast scan time but at most
- * maxslp (a macroscopic slow).
- */
- if (slowscan == 0)
- slowscan = 3 * fastscan;
- if (slowscan > maxslp)
- slowscan = maxslp;
-#ifdef defined(BERT) || defined(ERNIE)
- printf("slowscan %d, fastscan %d, maxpgio %d\n",
- slowscan, fastscan, maxpgio);
- printf("lotsfree %d, desfree %d, minfree %d\n",
- lotsfree, desfree, minfree);
-#endif
-}
-