pagequeue.c


/*************************************************************************
*                                                                        *
*   Modulo: pagequeue.c                                                  *
*                                                                        *
*   realizzato dal Gruppo 17 di Lab2 Anno Accademico 1995/96             *
*                                                                        *
*   Lorenzo     Claudio       Valerio    Riccardo    Emiliano            *
*   Coronati    Lanconelli    Paolini    Solmi       Trentini            *
*                                                                        *
**************************************************************************/

#include "../h/supconst.h"
#include "../h/memory.h"
#include "../h/queue.e"

int free_pages;                     /* numero di pagine libere */

HIDDEN frame_t frameTable[MAXFRAMES];
HIDDEN frame_t *ftfp;               /* lista pagine libere */

void
initPage(first_page, last_page)
int first_page, last_page;
{
    register frame_t *p = frameTable;
    register int real_pages = last_page - first_page;   /* + 1; */
    register int noelem = MIN(MAXFRAMES, real_pages);

    free_pages = noelem;
    while (--noelem)
    {
        p->f_pd = NULL;
        p->f_frameno = first_page++;
        p = p->f_next = (frame_t *) ((char *) p + sizeof(frame_t));
    }
    p->f_next = p->f_pd = NULL;
    p->f_frameno = first_page;
    ftfp = frameTable;
}

frame_t *
allocPage()
{
    register frame_t *retp = ftfp;

    if (retp != NULL)
    {
        free_pages--;
        ftfp = ftfp->f_next;
    }

    return retp;
}

void
freePage(p)
frame_t *p;
{
    freeQueue(p, &ftfp);
    free_pages++;
}



[INDICE CODICE]