Lab

Priority Queue


Prelab Task:

    1.Understand what we learned about priority queue and read the related book materials

    2. Read and understand the header files: d_pqueue.h, d_heap.h

Lab Task:

In this lab, you will implement a computer system running programs (processes) by assigning a priority to each process.

Priority 0 is the highest priority, and priority 39 is the lowest. Assume that when a user requests a program to be run, the operating system (OS)  inserts a process request record into a priority queue. When the CPU is available, the OS deletes the highest priority process request record and runs the corresponding process. The declaration of the process request record is given in the header file "preqrec.h", where the name attribute identifies the process.

  1. Implement the header file "preqrec.h"
  2. Copy the following files: d_except.hd_pqueue.h, d_heap.h to your working directory for this lab and you may need them for your lab.
  3. Name the program for the  lab  as lab_08.cpp. In your program,
    1. declare a miniPQ object mpq, and assign to it process request records, whose names are "Process A", "Process B",..., "Process J" and whose priority values are random integers in the range from 0 to 39.
    2. Output and delete records from the priority queue until it is empty.
  4. Run your program and compare it with a sample output.

What to Turn In