/* queue1e.c++ implementation of int queue */ #include "queue1d.h" #include "myMutex.h" queue::queue() { front = rear = count = 0; } int queue::isFullQ(){ return count == MAX; } int queue::isEmptyQ(){ return count == 0; } int queue::addQ(int n){ int temp, i; if(isFullQ()) return ERROR; rear = (rear + 1) % MAX; data[rear] = n; // count = count+1; myMutexLock(lockP); temp = count; for(i=1; i<= 500000; ++i); // Delay temp = temp+1; count = temp; myMutexUnlock(*lockP) ; // make lock = 0 return OK; } int queue::frontQ(int &v){ if(isEmptyQ()) return ERROR; v = data[(front+1)%MAX] ; return OK; } int queue::deleteQ(){ int temp, i; if(isEmptyQ()) return ERROR; front = (front+1)%MAX ; myMutexLock(lockP); temp = count; for(i=1; i<= 500000; ++i); // Delay temp = temp-1; count = temp; myMutexUnlock(*lockP); // Lock is 0 return OK; }