|
|
1.1 root 1: /*
2: * Seek sort for disks.
3: *
4: * actf and actl are the ends of an ordered list of buffers
5: * bp is a new buffer, to be inserted in the list in a good place
6: * the buffers are ordered by `cylinder' which is expected in b_resid.
7: *
8: * the list is two ascending lists: those greater than the head end
9: * (the block being read or written now), and those less.
10: * the idea is to sweep across the disk slowly doing io, then
11: * seek quickly back and sweep again
12: */
13: #include "sys/param.h"
14: #include "sys/buf.h"
15:
16: #define b_cylin b_resid
17:
18: disksort(actf, actl, bp)
19: register struct buf **actf, **actl, *bp;
20: {
21: register struct buf *ap;
22: register long cyl;
23:
24: if((ap = *actf) == NULL) {
25: *actf = *actl = bp;
26: bp->av_forw = NULL;
27: return;
28: }
29: if(bp->b_cylin < ap->b_cylin) {
30: while(ap->av_forw) {
31: if(ap->av_forw->b_cylin < ap->b_cylin) {
32: cyl = 0;
33: break;
34: }
35: ap = ap->av_forw;
36: }
37: }
38: else
39: cyl = ap->b_cylin;
40: while(ap->av_forw) {
41: if(ap->av_forw->b_cylin < cyl ||
42: bp->b_cylin < ap->av_forw->b_cylin)
43: break;
44: ap = ap->av_forw;
45: cyl = ap->b_cylin;
46: }
47: bp->av_forw = ap->av_forw;
48: ap->av_forw = bp;
49: if(ap == *actl)
50: *actl = bp;
51: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.