Example #1
0
static void lru_pageit(Pentry q[MAXPROCESSES],int tick)
{
    int proc,pg,evicted;
    
    for(proc=0;proc<MAXPROCESSES;proc++)
    {
        pg=q[proc].pc/PAGESIZE;
        timestamps[proc][pg]=tick;
        
        if(pagein(proc,pg))
            continue;

        if(pages_alloc(q,proc)<1) 
            continue;

        lru_page(q,proc,tick,&evicted);
        pageout(proc,evicted);
    }
}
static void lru_pageit(Pentry q[MAXPROCESSES], uint32_t tick) {
	int proc, page, state, evicted;
	
	for(proc = 0; proc < MAXPROCESSES; proc++) {
		if(!q[proc].active) /* done if its not active */
			continue;

		page = q[proc].pc/PAGESIZE;
		/* note this time for future eviction decisions */
		timestamps[proc][page] = tick; 
		
		/* done if the page is already in memory */
		if(q[proc].pages[page]) 
			continue;

		/* the page is not in memory.
		 * if pagein give 1 the page is either 
		 * on its way already or we just got it
		 * started, so we are done with this process
		 */
		if(pagein(proc, page, &state) )
			continue;

		/* either the page is swapping out or 
		 * there are no free physical pages
		 */
		if(state == SWAPOUT) 
			continue; /* just have to wait... */

		/* there are no free physical pages */
		if(pages_alloc(q, proc) < 1) 
			continue; /* must have at least one page to evict */

		lru_page(q, proc, tick, &evicted);

		if(!pageout(proc, evicted) ) {
			endit();
		}
	}
}