Skip to content

Commit

Permalink
added comments to dequeue
Browse files Browse the repository at this point in the history
  • Loading branch information
Azoam committed Feb 4, 2018
1 parent cff58ff commit e36eea6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Asst1/util.c
Expand Up @@ -37,17 +37,24 @@ threadNode* dequeue ()

int curr = 0;
threadQ* threadq = NULL;
//Find the first threadQ that is non_empty
threadq = _scan_non_empty(&curr)
//If NULL is returned, this means we either have nothing to Dequeue or and error has happened
//Error could be you dequeued before you enqueued (ya idoit)
if (threadq == NULL)
{
return NULL;
}
if(threadq->threshold == 0 && curr < LEVELS){
//Current will be altered withint the scan function. When the notice that the threshold
//Has been set to 0, we scan for another non empty queue after the threshold.
curr += 1;
//Fudge Sri and SaraAnn; Shut up Mom
//We need to store the old threadQ and the new threadQ so that we can updates both thresholds
threadQ * temp = threadq;
threadQ * ptr = _scan_non_empty(&curr);
if(ptr != NULL){
//Because curr represents the level, our thershold will be MAXTHD - curr;
temp->threshold = MAXTHD - curr;
ptr->threshold -= 1;
threadNode * tNode = threadq -> front;
Expand Down

0 comments on commit e36eea6

Please sign in to comment.