|
|
1.1 root 1: /*
2: * static char ID_sjrnc[] = "@(#) sojourn.c: 1.1 1/8/82";
3: */
4:
5: sojourn(itemid, partnbr, readaction)
6: long itemid;
7: int partnbr, readaction;
8: {
9:
10: register int index1;
11: register char *index2;
12: int framenbr;
13:
14: /*
15: * Search the page frame contents, to see if the desired item is
16: * already present
17: */
18:
19: for( index1 = 0; index1 < NUMBERFRAMES; index1++ )
20: if( itemid == manager[index1].page_id )
21: return( index1 );
22:
23: if( (partnbr < 0) || (partnbr > num_partitions) )
24: return( fatal("illegal frame partition supplied") );
25:
26: /*
27: * A frame must be selected for a item not currently in memory
28: */
29:
30: if( (framenbr = lru[partnbr]) == NOFRAMES )
31: return( fatal("no unlocked frames available") );
32:
33: if( manager[framenbr].ref_chng == WRTN )
34: if( writeframe(framenbr) != PAGESIZE )
35: return( fatal("page write failed to output entire page") );
36:
37: if( readaction == YES ) {
38: if( readpage(itemid, framenbr) != PAGESIZE )
39: return( fatal("page read failed to input entire page") );
40: }
41: else
42: for( index2 = manager[framenbr].frame_pntr; index2 < manager[framenbr].frame_pntr+PAGESIZE; *index2++ = 0 )
43: ;
44:
45: manager[framenbr].page_id = itemid;
46: manager[framenbr].ref_chng = RNLY;
47:
48: return( framenbr );
49: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.