Beispiel #1
0
void dispatch()
{
    PCB *pcb;
	
    if(PTBR->pcb->status == running)
    {   /*insert process in ready queue*/
		insert_ready(PTBR->pcb);
	}
    //pcb = hf; //if pcb = head here, would it ever go to hb?
    
    if(pcb == hf)
       {
            PTBR = pcb->page_tbl;
            prepage(pcb);
            pcb->status = running;
            pcb->last_dispatch = get_clock();
            set_timer(Quantum);
            insert_background(PTBR->pcb);
        }
        else if (pcb == hb)
        {
            PTBR = pcb->page_tbl;
            prepage(pcb);
            pcb->status = running;
            pcb->last_dispatch = get_clock();
            set_timer(Quantum);
        }

        else
        {
            PTBR = NULL;
        }
}
Beispiel #2
0
void dispatch() {
    if (PTBR != NULL && PTBR->pcb->status == running) {
        if (Int_Vector.cause != timeint) {
            PTBR->pcb->last_dispatch = get_clock();
            return;
        }
        else if (Int_Vector.cause == timeint) {
            insert_ready(PTBR->pcb);
            PTBR = NULL;
        }
    }
    PCB *nextPCB = deQueue(&maQ);
    if (nextPCB == NULL) {
        PTBR = NULL;
        return;
    }
    else {
        PTBR = nextPCB->page_tbl;
        prepage(nextPCB); // External routine.
        nextPCB->status = running;
        nextPCB->last_dispatch = get_clock();
        set_timer(Quantum); // Same. Must be implemented in OSP.
    }
}