dequeue
user_0531932
c_cpp
3 years ago
1.4 kB
8
Indexable
struct pcb_t *dequeue(struct queue_t *q)
{
// printf("dequeue of non MLQ used\n");
/* TODO: return a pcb whose priority is the highest
* in the queue [q] and remember to remove it from q
* */
q->slot--;
if(q->slot == 0) return NULL;
if (q->size != 0)
{
struct pcb_t *t_proc = q->proc[0];
// int highest_priority = MAX_PRIO;
// int i;
// int max_idx = 0;
// for (i = 0; i < q->size; i++)
// {
// //printf("q->proc[i]->prio: %d\n", q->proc[i]->prio);
// if (q->proc[i]->prio < highest_priority)
// {
// t_proc = q->proc[i];
// highest_priority = q->proc[i]->prio;
// //printf("highest_priority: %d\n", highest_priority);
// max_idx = i;
// }
// }
//printf("highest_priority: %d\n", highest_priority);
int i = 0;
for (i = 0; i < q->size - 1; i++)
{
q->proc[i] = q->proc[i + 1];
}
q->size--;
return t_proc;
}
return NULL;
}
Editor is loading...