Exemplo n.º 1
0
    PCB* SetupPCB(string name, int priority, int processClass)
    {
        if (FindPCB(name) != NULL)
        {
            cout << "Process Name already in use" << endl;
            return NULL;
        }
        if (priority > 128 || priority < -127)
        {
            cout << "Priority must be between -127 and 128" << endl;
            return NULL;
        }
        if (processClass < 1 || processClass > 2)
        {
            cout << "Process Class must either be 1-Application or 2-System" << endl;
            return NULL;
        }
        PCB *pcb = AllocatePCB();
        pcb->setProcessName(name);
        pcb->setPriority(priority);
        pcb->setProcessClass(processClass);
        pcb->setState(2);
        return pcb;


    }
Exemplo n.º 2
0
    void OSTest2() //PCB Tests
    {
        PCB *a = pcbControl.SetupPCB("a",12,1);
        PCB *b = pcbControl.SetupPCB("b",-12,2);
        PCB *c = pcbControl.SetupPCB("c",32,1);
        PCB *d = pcbControl.SetupPCB("d",34,1);
        PCB *e = pcbControl.SetupPCB("e",12,2);
        PCB *f = pcbControl.SetupPCB("f",16,1);
        PCB *g = pcbControl.SetupPCB("g",12,1);

        b->setState(3);
        c->setState(4);
        d->setState(5);
        e->setState(3);
        g->setState(5);

        pcbControl.InsertPCB(a);
        pcbControl.InsertPCB(b);
        pcbControl.InsertPCB(c);
        pcbControl.InsertPCB(d);
        pcbControl.InsertPCB(e);
        pcbControl.InsertPCB(f);

        pcbControl.showQueue(5);

        pcbControl.RemovePCB(a);
        pcbControl.RemovePCB(b);
        pcbControl.RemovePCB(c);
        pcbControl.RemovePCB(d);
        pcbControl.RemovePCB(e);
        pcbControl.RemovePCB(f);

        pcbControl.FreePCB(a);
        pcbControl.FreePCB(b);
        pcbControl.FreePCB(c);
        pcbControl.FreePCB(d);
        pcbControl.FreePCB(e);
        pcbControl.FreePCB(f);

        pcbControl.showQueue(5);
    }