[ C++ RCOS Home | RCOS.java Home | RCOS Home | David's Home ]

RCOS C++ CRC for class pque

Name:

pque

Comment:

Priority queue used to store PIDs. May be instantiated as ordered (by Process Priority, Quantum, something), or simple FIFO.

Collaborators:

DblList

Responsibilities:

  class Pque : private DblList {
    typedef struct qmbr {     // structure used for double link list
      INT16  nKey;            // Key for ordering (normally priority)
      UINT16 uPid;            // index into array (which is the PID #)
    } QMBR;
    typedef QMBR *PQMBR;      // g++ doesn't like it being defined as
                              // part of the previous typedef???
    BOOL bOrdered;            // FIFO or priority ordering
  public:
    Pque   (BOOL = FALSE);    // default is FIFO
   ~Pque   (void);            // kill off any left-overs
    BOOL   PqEmpty (void);    // state of play
    BOOL   PqFind (UINT16);   // is this PID in the queue?
    void   PqAdd (PCB&);      // add/insert PID (perhaps in priority order)
    UINT16 PqGet (void);      // remove PID from queue (head if ordered)
    UINT16 PqGet (UINT16);    // remove specific PID from queue
    void   PqImage (UINT16*); // copy queue PID numbers to passed array
  };