コード例 #1
0
int testPQ() {
    printf("\nTestPQ started\n");
    PCB pcb = {new, 1, 23, 0, 2, 23, 23, 4, 5}; 
    //toString(&pcb);   
    fifo_queue *thePQ = createPriorityQueue();
    printf("Testing priority queue toString on empty\n");
    PriorityQueuetoString(thePQ);
    printf("Testing priority queue addPCB\n");   
    addPCB(&pcb, thePQ);
    printf("Testing priority queue toString\n");
    PriorityQueuetoString(thePQ);
    printf("Testing that I didn't mess up any queues with the last toString\n");
    PriorityQueuetoString(thePQ);
    printf("Testing GetNext \n");
    toString(GetNext(thePQ));
    printf("Testing GetNext on Empty PQ\n");
    toString(GetNext(thePQ));
    return (EXIT_SUCCESS);
}
コード例 #2
0
ファイル: pcbqueue.cpp プロジェクト: danielj11/potatOS
//performs compaction on the queue
void pcbQueue::compact()
{
    cout << "-BEFORE COMPACTION-" << endl;
    printQueue();

    pcb* tempPCB = new pcb;
    tempPCB -> processName = "empty";
    tempPCB -> memory = 0;

    for (int i = 0; i < queueSize; i++)
    {
        tempPCB -> memory = tempPCB -> memory + heldItems[i] -> memory;
    }

    heldItems.clear();
    addPCB(tempPCB);

    cout << "-AFTER COMPACTION-" << endl;
    printQueue();

    queueSize = heldItems.size();

    cout << endl;
}