-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueue_test.c
More file actions
47 lines (35 loc) · 778 Bytes
/
queue_test.c
File metadata and controls
47 lines (35 loc) · 778 Bytes
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
//
// Created by Xavier McNulty on 5/2/16.
//
#include <stdio.h>
#include <stdlib.h>
#include "my_pqueue.h"
/* prints a tcb */
void printTCB(my_tcb tcb) {
if (tcb)
printf("(%d [%d])", tcb->my_tcb, tcb->priority);
else
printf("null");
}
/* prints a priority queue */
void printQueue (my_pqueue_t *q) {
if (q) {
my_tcb cur = q->q_head;
while (cur) {
printTCB(cur);
printf(" <-> ");
cur = cur->next;
}
}
}
/* main method */
int main(int argc, char **argv) {
my_pqueue_t q;
my_pqueue_init(&q);
my_tcb tcb = malloc(sizeof(tcb));
tcb->priority = MY_PRIO_STD;
tcb->my_tcb = 10;
my_pqueue_insert(&q, MY_PRIO_STD, tcb);
printQueue(&q);
printf("\n");
}