pandaemonia
February 26th, 2009, 07:21 AM
I have the code
Bool enqueue(Queue *AQueue, int processId, int arrivalTime,
int serviceTime, int remainingTime) {
Node *head;
head = AQueue->head;
Node *tail;
tail = AQueue->tail;
Node *tempnode;
tempnode = (Node*)malloc(sizeof(Node));
tempnode->processId = processId;
tempnode->arrivalTime = arrivalTime;
tempnode->serviceTime = serviceTime;
tempnode->remainingTime = remainingTime;
tempnode->next = NULL;
if (tail == NULL){
tail = tempnode;
head = tempnode;
} else {
(tail)->next = tempnode;
tail = tempnode;
}
return TRUE;
}.
The .h file is as follows:
typedef struct node{
int processId;
int arrivalTime;
int serviceTime;
int remainingTime;
struct node *next; // points to the next node
} Node;
typedef struct queue{
Node *head;
Node *tail;
} Queue;
It's not actually adding anything to the queue. Why?
Bool enqueue(Queue *AQueue, int processId, int arrivalTime,
int serviceTime, int remainingTime) {
Node *head;
head = AQueue->head;
Node *tail;
tail = AQueue->tail;
Node *tempnode;
tempnode = (Node*)malloc(sizeof(Node));
tempnode->processId = processId;
tempnode->arrivalTime = arrivalTime;
tempnode->serviceTime = serviceTime;
tempnode->remainingTime = remainingTime;
tempnode->next = NULL;
if (tail == NULL){
tail = tempnode;
head = tempnode;
} else {
(tail)->next = tempnode;
tail = tempnode;
}
return TRUE;
}.
The .h file is as follows:
typedef struct node{
int processId;
int arrivalTime;
int serviceTime;
int remainingTime;
struct node *next; // points to the next node
} Node;
typedef struct queue{
Node *head;
Node *tail;
} Queue;
It's not actually adding anything to the queue. Why?