-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpriority_queue.h
80 lines (65 loc) · 1.89 KB
/
priority_queue.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
12/6/2017
Authors: Connor Lundberg, Jacob Ackerman, Jasmine Dacones
*/
#ifndef PRIORITY_QUEUE_H
#define PRIORITY_QUEUE_H
#include "pcb.h"
#include "fifo_queue.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
typedef struct priority_queue {
ReadyQueue queues[NUM_PRIORITIES];
} PQ_s;
typedef struct priority_queue * PriorityQueue;
/*
* Creates a priority queue.
*
* Return: A new priority queue on success, NULL on failure.
*/
PriorityQueue pq_create();
/*
* Destroys the provided priority queue, freeing all contents.
*
* Arguments: PQ: The Priority Queue to destroy.
*/
void pq_destroy(PriorityQueue PQ);
/*
* Enqueues a PCB to the provided priority queue, into the correct priority bin.
*
* Arguments: PQ: The Priority Queue to enqueue to.
* pcb: the PCB to enqueue.
*/
void pq_enqueue(PriorityQueue PQ, PCB pcb);
/*
* Dequeues a PCB from the provided priority queue.
*
* Arguments: PQ: The Priority Queue to dequeue from.
* Return: The highest priority proccess in the queue, NULL if none exists.
*/
PCB pq_dequeue(PriorityQueue PQ);
PCB pq_remove_matching_pcb(PriorityQueue PQ, PCB toFind);
int getNextQuantumSize (PriorityQueue PQ);
/*
* Peeks at the top value from the provided priority queue.
*
* Arguments: PQ: The Priority Queue to peek at.
* Return: The highest priority proccess in the queue, NULL if none exists.
*/
PCB pq_peek(PriorityQueue PQ);
/*
* Checks if the provided priority queue is empty.
*
* Arguments: PQ: The Priority Queue to test.
* Return: 1 if the queue is empty, 0 otherwise.
*/
char pq_is_empty(PriorityQueue PQ);
/*
* Creates a string representation of the provided priority queue, and returns it.
*
* Arguments: PQ: the Priority Queue to create a string representation of.
* Return: A string representation of the provided Priority Queue, or NULL on failure.
*/
void toStringPriorityQueue(PriorityQueue PQ);
#endif