if (tmpoffset>QSIZE) {
//Wait for tail to go past end
tmpoffset=size+sizeof(int);
- while(headoffset<tailoffset)
- ;
+ if (headoffset<tailoffset)
+ return NULL;
//Wait for tail to go past new start
- while(tailoffset<=tmpoffset)
- ;
+ if (tailoffset<=tmpoffset)
+ return NULL;
*((int *)(memory+headoffset))=-1;//safe because we left space
*((int*)memory)=size+sizeof(int);
return memory+sizeof(int);
} else {
- while(headoffset<tailoffset&&tailoffset<=tmpoffset)
- ;
+ if (headoffset<tailoffset&&tailoffset<=tmpoffset)
+ return NULL;
*((int*)(memory+headoffset))=size+sizeof(int);
return memory+headoffset+sizeof(int);
}
void prefetch(int siteid, int ntuples, unsigned int *oids, unsigned short *endoffsets, short *arrayfields) {
/* Allocate for the queue node*/
int qnodesize = 2*sizeof(int) + ntuples * (sizeof(unsigned short) + sizeof(unsigned int)) + endoffsets[ntuples - 1] * sizeof(short);
- char * node= getmemory(qnodesize);
- /* Set queue node values */
int len;
+ char * node= getmemory(qnodesize);
int top=endoffsets[ntuples-1];
+
+ if (node==NULL)
+ return;
+ /* Set queue node values */
/* TODO: Remove this after testing */
evalPrefetch[siteid].callcount++;