if(val==NULL) {
//queue is null, first case
if(*(r->pointer)!=0) {
- // check whether pointer is already resolved, or not.
- table->unresolvedQueue=NULL; //released lock;
- return ADDTABLEITEM(table,r,TRUE);
+ // check whether pointer is already resolved, or not.
+ table->unresolvedQueue=NULL; //released lock;
+ return ADDTABLEITEM(table,r,TRUE);
}
struct Queue* queue=createQueue();
addNewItemBack(queue,r);
if (T->item.status==READY) {
for(; val!=NULL; val=val->next) {
if (val==((BinItem *)b)) {
- //ready to retire
- retval=READY;
- if (isParent(r)) {
- b->item.status=retval; //unsure if really needed at this point..
- be->head=NULL; // released lock
- return retval;
- }
- break;
+ //ready to retire
+ retval=READY;
+ if (isParent(r)) {
+ b->item.status=retval; //unsure if really needed at this point..
+ be->head=NULL; // released lock
+ return retval;
+ }
+ break;
} else if (val->total!=0) {
- break;
+ break;
}
}
}
flag=(void*)LOCKXCHG((unsigned INTPTR*)&(V->array[index]), (unsigned INTPTR)flag);
if (flag!=NULL) {
if (isParentCoarse(r)) { //parent's retire immediately
- atomic_dec(&V->item.total);
- V->index--;
+ atomic_dec(&V->item.total);
+ V->index--;
} else {
#if defined(RCR)&&!defined(OOO_DISABLE_TASKMEMPOOL)
- if (atomic_sub_and_test(1, &r->count))
- poolfreeinto(Q->rentrypool, r);
+ if (atomic_sub_and_test(1, &r->count))
+ poolfreeinto(Q->rentrypool, r);
#endif
}
return READY;
if (flag!=NULL) {
#if defined(RCR)&&!defined(OOO_DISABLE_TASKMEMPOOL)
if (atomic_sub_and_test(1, &r->count))
- poolfreeinto(Q->rentrypool, r);
+ poolfreeinto(Q->rentrypool, r);
#endif
return READY;
} else {
int i;
while (ptr!=NULL) {
if (isReadBinItem(ptr)) {
- ReadBinItem* rptr=(ReadBinItem*)ptr;
- if (rptr->item.status==NOTREADY) {
- for (i=0; i<rptr->index; i++) {
- resolveDependencies(rptr->array[i]);
- if (isParent(rptr->array[i])) {
- //parents go immediately
- atomic_dec(&rptr->item.total);
- atomic_dec(&T->item.total);
- }
- }
- }
- rptr->item.status=READY;
- if (rptr->item.next==NULL) {
- break;
- }
- if (rptr->item.total!=0) {
- haveread=TRUE;
- } else if ((BinItem*)rptr==val) {
- val=val->next;
- }
+ ReadBinItem* rptr=(ReadBinItem*)ptr;
+ if (rptr->item.status==NOTREADY) {
+ for (i=0; i<rptr->index; i++) {
+ resolveDependencies(rptr->array[i]);
+ if (isParent(rptr->array[i])) {
+ //parents go immediately
+ atomic_dec(&rptr->item.total);
+ atomic_dec(&T->item.total);
+ }
+ }
+ }
+ rptr->item.status=READY;
+ if (rptr->item.next==NULL) {
+ break;
+ }
+ if (rptr->item.total!=0) {
+ haveread=TRUE;
+ } else if ((BinItem*)rptr==val) {
+ val=val->next;
+ }
} else if(isWriteBinItem(ptr)) {
- if (haveread)
- break;
- if(ptr->status==NOTREADY) {
- resolveDependencies(((WriteBinItem*)ptr)->val);
- ptr->status=READY;
- if(isParent(((WriteBinItem*)ptr)->val)) {
- atomic_dec(&T->item.total);
- val=val->next;
- } else
- break;
- } else { // write bin is already resolved
- val=val->next;
- }
- /*
- if(ptr->status==NOTREADY) {
- resolveDependencies(((WriteBinItem*)ptr)->val);
- }
- ptr->status=READY;
- if (isParent(((WriteBinItem*)ptr)->val)) {
- atomic_dec(&T->item.total);
- //val=val->next;
- val=ptr->next;
- } else
- break;
- }
- */
+ if (haveread)
+ break;
+ if(ptr->status==NOTREADY) {
+ resolveDependencies(((WriteBinItem*)ptr)->val);
+ ptr->status=READY;
+ if(isParent(((WriteBinItem*)ptr)->val)) {
+ atomic_dec(&T->item.total);
+ val=val->next;
+ } else
+ break;
+ } else { // write bin is already resolved
+ val=val->next;
+ }
+ /*
+ if(ptr->status==NOTREADY) {
+ resolveDependencies(((WriteBinItem*)ptr)->val);
+ }
+ ptr->status=READY;
+ if (isParent(((WriteBinItem*)ptr)->val)) {
+ atomic_dec(&T->item.total);
+ //val=val->next;
+ val=ptr->next;
+ } else
+ break;
+ }
+ */
}
ptr=ptr->next;
}
if (head->next==NULL||head->total!=0) {
//item is not finished
if (head->status!=READY) {
- //need to update status
- head->status=READY;
- if (isHashtable(head)) {
- RESOLVEHASHTABLE(Q, (Hashtable *) head);
- } else if (isVector(head)) {
- RESOLVEVECTOR(Q, (Vector *) head);
- } else if (isSingleItem(head)) {
- RESOLVESCC(Q, (SCC *)head);
- }
- if (head->next==NULL)
- break;
- if (head->total!=0)
- break;
+ //need to update status
+ head->status=READY;
+ if (isHashtable(head)) {
+ RESOLVEHASHTABLE(Q, (Hashtable *) head);
+ } else if (isVector(head)) {
+ RESOLVEVECTOR(Q, (Vector *) head);
+ } else if (isSingleItem(head)) {
+ RESOLVESCC(Q, (SCC *)head);
+ }
+ if (head->next==NULL)
+ break;
+ if (head->total!=0)
+ break;
} else
- break;
+ break;
}
MemoryQueueItem* nextitem=head->next;
CAS((unsigned INTPTR*)&(Q->head), (unsigned INTPTR)head, (unsigned INTPTR)nextitem);
BinItem* ptr=val;
if(ptr!=NULL&&ptr->status==NOTREADY) {
do {
- if (isWriteBinItem(ptr)) {
- if (haveread)
- break;
- resolveDependencies(((WriteBinItem*)ptr)->val);
- ptr->status=READY;
- if (isParent(((WriteBinItem*)ptr)->val)) {
- atomic_dec(&T->item.total);
- val=val->next;
- } else
- break;
- } else if (isReadBinItem(ptr)) {
- int i;
- ReadBinItem* rptr=(ReadBinItem*)ptr;
- for(i=0; i<rptr->index; i++) {
- resolveDependencies(rptr->array[i]);
- if (isParent(rptr->array[i])) {
- atomic_dec(&rptr->item.total);
- atomic_dec(&T->item.total);
- }
- }
- if (rptr->item.next==NULL||rptr->item.total!=0) {
- haveread=TRUE;
- } else if((BinItem*)rptr==val) {
- val=val->next;
- }
- rptr->item.status=READY;
- }
- ptr=ptr->next;
+ if (isWriteBinItem(ptr)) {
+ if (haveread)
+ break;
+ resolveDependencies(((WriteBinItem*)ptr)->val);
+ ptr->status=READY;
+ if (isParent(((WriteBinItem*)ptr)->val)) {
+ atomic_dec(&T->item.total);
+ val=val->next;
+ } else
+ break;
+ } else if (isReadBinItem(ptr)) {
+ int i;
+ ReadBinItem* rptr=(ReadBinItem*)ptr;
+ for(i=0; i<rptr->index; i++) {
+ resolveDependencies(rptr->array[i]);
+ if (isParent(rptr->array[i])) {
+ atomic_dec(&rptr->item.total);
+ atomic_dec(&T->item.total);
+ }
+ }
+ if (rptr->item.next==NULL||rptr->item.total!=0) {
+ haveread=TRUE;
+ } else if((BinItem*)rptr==val) {
+ val=val->next;
+ }
+ rptr->item.status=READY;
+ }
+ ptr=ptr->next;
} while(ptr!=NULL);
}
bin->head=val; // released lock;
REntry* val=NULL;
val=(REntry*)LOCKXCHG((unsigned INTPTR*)&(tmp->array[i]), (unsigned INTPTR)val);
if (val!=NULL) {
- SESEcommon *seseCommon=val->seseRec;
- resolveDependencies(val);
- if (isParent(val)) {
- atomic_dec(&tmp->item.total);
+ SESEcommon *seseCommon=val->seseRec;
+ resolveDependencies(val);
+ if (isParent(val)) {
+ atomic_dec(&tmp->item.total);
#ifdef RCR
- poolfreeinto(q->rentrypool,val);
+ poolfreeinto(q->rentrypool,val);
#endif
- }
+ }
#if defined(RCR)&&!defined(OOO_DISABLE_TASKMEMPOOL)
- else if (atomic_sub_and_test(1, &((REntry *)val)->count))
- poolfreeinto(q->rentrypool,val);
- RELEASE_REFERENCE_TO(seseCommon);
+ else if (atomic_sub_and_test(1, &((REntry *)val)->count))
+ poolfreeinto(q->rentrypool,val);
+ RELEASE_REFERENCE_TO(seseCommon);
#endif
}
}
mask=mask>>shift;
index+=shift;
if(atomic_sub_and_test(1, &array[index].flag)) {
- if(atomic_sub_and_test(1, &(seseCommon->unresolvedDependencies)))
- workScheduleSubmit((void *)seseCommon);
+ if(atomic_sub_and_test(1, &(seseCommon->unresolvedDependencies)))
+ workScheduleSubmit((void *)seseCommon);
}
}
} else if (type==PARENTCOARSE) {
if(r->type==WRITE) {
int key=generateKey(OBJPTRPTR_2_OBJOID(r->pointer) );
if(q->binbuf[key]==NULL) {
- // for multiple writes, add only the first write that hashes to the same bin
- q->binbuf[key]=r;
+ // for multiple writes, add only the first write that hashes to the same bin
+ q->binbuf[key]=r;
} else {
- q->buf[i]=NULL;
+ q->buf[i]=NULL;
}
}
}
if(r!=NULL && r->type==READ) {
int key=generateKey(OBJPTRPTR_2_OBJOID(r->pointer) );
if(q->binbuf[key]==NULL) {
- // read item that hashes to the bin which doen't contain any write
- seseCommon->rentryArray[seseCommon->rentryIdx++]=r;
- if(ADDTABLEITEM(table, r, FALSE)==READY) {
- resolveDependencies(r);
- }
+ // read item that hashes to the bin which doen't contain any write
+ seseCommon->rentryArray[seseCommon->rentryIdx++]=r;
+ if(ADDTABLEITEM(table, r, FALSE)==READY) {
+ resolveDependencies(r);
+ }
}
q->buf[i]=NULL;
}
if(r!=NULL) {
seseCommon->rentryArray[seseCommon->rentryIdx++]=r;
if(ADDTABLEITEM(table, r, FALSE)==READY) {
- resolveDependencies(r);
+ resolveDependencies(r);
}
}
}
r->queue=q;
r->isBufMode=TRUE;
if(ADDRENTRY(q,r)==NOTREADY) {
- localCount++;
+ localCount++;
}
}
return localCount;
if(r->type==WRITE) {
int key=generateKey(OBJPTRPTR_2_OBJOID(r->pointer) );
if(q->binbuf[key]==NULL) {
- // for multiple writes, add only the first write that hashes to the same bin
- q->binbuf[key]=r;
+ // for multiple writes, add only the first write that hashes to the same bin
+ q->binbuf[key]=r;
} else {
- q->buf[i]=NULL;
+ q->buf[i]=NULL;
}
}
}
if(r!=NULL && r->type==READ) {
int key=generateKey(OBJPTRPTR_2_OBJOID(r->pointer) );
if(q->binbuf[key]==NULL) {
- // read item that hashes to the bin which doen't contain any write
- seseCommon->rentryArray[seseCommon->rentryIdx++]=r;
- if(ADDRENTRY(q,r)==NOTREADY) {
- localCount++;
- }
+ // read item that hashes to the bin which doen't contain any write
+ seseCommon->rentryArray[seseCommon->rentryIdx++]=r;
+ if(ADDRENTRY(q,r)==NOTREADY) {
+ localCount++;
+ }
}
q->buf[i]=NULL;
}
if(r!=NULL) {
seseCommon->rentryArray[seseCommon->rentryIdx++]=r;
if(ADDRENTRY(q,r)==NOTREADY) {
- localCount++;
+ localCount++;
}
}
}
do {
struct QueueItem* head=getHead(val);
if(head!=NULL) {
- REntry* rentry=(REntry*)head->objectptr;
- if(*(rentry->pointer)==0) {
- // encounters following unresolved pointer
- table->unresolvedQueue=val; //released lock
- break;
- }
- removeItem(val,head);
-
- //now, address is resolved
-
- //check if rentry is buffer mode
- if(rentry->isBufMode==TRUE) {
- if(currentSESE==0) {
- queue=rentry->queue;
- INITIALIZEBUF(queue);
- currentSESE=(INTPTR)rentry;
- ADDRENTRYTOBUF(queue,rentry);
- } else if(currentSESE==(INTPTR)rentry) {
- ADDRENTRYTOBUF(queue,rentry);
- } else if(currentSESE!=(INTPTR)rentry) {
- RESOLVEBUFFORHASHTABLE(queue,table,(SESEcommon*)rentry->seseRec);
- currentSESE=(INTPTR)rentry;
- INITIALIZEBUF(queue);
- ADDRENTRYTOBUF(rentry->queue,rentry);
- }
- } else {
- if(currentSESE!=0) {
- //previous SESE has buf mode, need to invoke resolve buffer
- RESOLVEBUFFORHASHTABLE(queue,table,(SESEcommon*)rentry->seseRec);
- currentSESE=0;
- }
- //normal mode
- if(ADDTABLEITEM(table, rentry, FALSE)==READY) {
- resolveDependencies(rentry);
- }
- }
+ REntry* rentry=(REntry*)head->objectptr;
+ if(*(rentry->pointer)==0) {
+ // encounters following unresolved pointer
+ table->unresolvedQueue=val; //released lock
+ break;
+ }
+ removeItem(val,head);
+
+ //now, address is resolved
+
+ //check if rentry is buffer mode
+ if(rentry->isBufMode==TRUE) {
+ if(currentSESE==0) {
+ queue=rentry->queue;
+ INITIALIZEBUF(queue);
+ currentSESE=(INTPTR)rentry;
+ ADDRENTRYTOBUF(queue,rentry);
+ } else if(currentSESE==(INTPTR)rentry) {
+ ADDRENTRYTOBUF(queue,rentry);
+ } else if(currentSESE!=(INTPTR)rentry) {
+ RESOLVEBUFFORHASHTABLE(queue,table,(SESEcommon*)rentry->seseRec);
+ currentSESE=(INTPTR)rentry;
+ INITIALIZEBUF(queue);
+ ADDRENTRYTOBUF(rentry->queue,rentry);
+ }
+ } else {
+ if(currentSESE!=0) {
+ //previous SESE has buf mode, need to invoke resolve buffer
+ RESOLVEBUFFORHASHTABLE(queue,table,(SESEcommon*)rentry->seseRec);
+ currentSESE=0;
+ }
+ //normal mode
+ if(ADDTABLEITEM(table, rentry, FALSE)==READY) {
+ resolveDependencies(rentry);
+ }
+ }
} else {
- table->unresolvedQueue=NULL; // set hashtable as normal-mode.
- break;
+ table->unresolvedQueue=NULL; // set hashtable as normal-mode.
+ break;
}
} while(TRUE);
} else {