From aeffaec504f135576bdd3373be3b27ace5dfcb9f Mon Sep 17 00:00:00 2001 From: bdemsky Date: Wed, 6 Apr 2011 21:55:59 +0000 Subject: [PATCH] fix SOR bug --- Robust/src/Runtime/oooJava/hashStructure.c | 29 +++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Robust/src/Runtime/oooJava/hashStructure.c b/Robust/src/Runtime/oooJava/hashStructure.c index e285d9d5..1cda5680 100644 --- a/Robust/src/Runtime/oooJava/hashStructure.c +++ b/Robust/src/Runtime/oooJava/hashStructure.c @@ -157,14 +157,7 @@ inline int rcr_BWRITEBINCASE(HashStructure *T, int key, SESEcommon *task, struct if(unlikely(td->task == task)) { //if it matches, then we remove it and the code below will upgrade it to a write. ((ReadBinItem_rcr *)bintail)->index--; - if (((INTPTR)task)&PARENTBIN) { - //have parent task...need to worry about CAS - void * val=(void *)LOCKXCHG((unsigned INTPTR*)&(td->task), (unsigned INTPTR)NULL); - if (val!=NULL) { - atomic_dec(&bintail->total); - } - } else - atomic_dec(&bintail->total); + atomic_dec(&bintail->total); rdmask=td->bitindex; if (bintail->status!=READY) wrmask=rdmask; @@ -369,20 +362,24 @@ int rcr_WTREADBINCASE(HashStructure *T, int key, SESEcommon * task, struct rcrRe if (readbintail->index==RNUMREAD) { // create new read group ReadBinItem_rcr* rb=rcr_createReadBinItem( T ); td = &rb->array[rb->index++]; - + td->task=task; + td->bitindex=ONEVAL<item.total=1; rb->item.status=status; T->array[key].tail->next=(BinItem_rcr*)rb; T->array[key].tail=(BinItem_rcr*)rb; enqueuerecord(rcrrec, key, (BinItem_rcr *) rb); } else { // group into old tail - td = &readbintail->array[readbintail->index++]; + td = &readbintail->array[readbintail->index]; + td->task=task; + td->bitindex=ONEVAL<index++; atomic_inc(&readbintail->item.total); enqueuerecord(rcrrec, key, (BinItem_rcr *) readbintail); } - td->task=task; - td->bitindex=ONEVAL<array[key].head=val;//released lock return retval; @@ -419,7 +416,6 @@ void rcr_RETIREHASHTABLE(HashStructure *T, SESEcommon *task, int key, BinItem_rc do { val=(BinItem_rcr*)LOCKXCHG((unsigned INTPTR*)&(be->head), (unsigned INTPTR)val); } while(val==(BinItem_rcr*)0x1); - for (i=0;iindex;i++) { TraverserData * td=&rptr->array[i]; if (task==td->task) { @@ -427,10 +423,15 @@ void rcr_RETIREHASHTABLE(HashStructure *T, SESEcommon *task, int key, BinItem_rc td->task=NULL; break; } - } + } be->head=val; } if (b->next==NULL || b->total>0) { + //need to remove ourself to avoid writecombining problems + ReadBinItem_rcr* rptr=(ReadBinItem_rcr*)b; + TraverserData * td=&rptr->array[rptr->index-1]; + if (td->task==task) + td->task=NULL; return; } } -- 2.34.1