#include "llookup.h"
#include "threadnotify.h"
#include "prefetch.h"
+#include <sched.h>
#ifdef COMPILER
#include "thread.h"
#endif
case READ_REQUEST:
/* Read oid requested and search if available */
recv_data((int)acceptfd, &oid, sizeof(unsigned int));
- if((srcObj = mhashSearch(oid)) == NULL) {
- printf("Error: Object 0x%x is not found in Main Object Store %s, %d\n", oid, __FILE__, __LINE__);
- break;
+ while((srcObj = mhashSearch(oid)) == NULL) {
+ int ret;
+ if((ret = sched_yield()) != 0) {
+ printf("%s(): error no %d in thread yield\n", __func__, errno);
+ }
}
h = (objheader_t *) srcObj;
GETSIZE(size, h);
return 1;
}
GETSIZE(tmpsize,header);
-
+
{
struct ___Object___ *dst=(struct ___Object___*)((char*)header+sizeof(objheader_t));
struct ___Object___ *src=(struct ___Object___*)((char*)modptr+sizeof(objheader_t)+offset);
} //end of for
}
} //end of while
- //Release socket
+ //Release socket
if (mid!=-1)
freeSockWithLock(transPResponseSocketPool, mid, sd);
objheader_t *header;
header = searchObj(dfsList[prev]);
if(header == NULL) {
- printf("%s() Error Object not found at %s , %d\n", __func__, __FILE__, __LINE__);
- return NULL;
+ dfsList[top] = 0;
} else {
//if Array
if(TYPE(header) > NUMCLASSES) {
} else { //linked list
dfsList[top] = getNextPointerOid(offsetarray, dfsList, &top, &depth);
}
- goto labelL1;
}
+ goto labelL1;
} else { // increment and go down the tree
//Increment top
top += 2;
objheader_t * header;
header = searchObj(dfsList[prev]);
if(header == NULL) {
- printf("%s() Error Object not found at %s , %d\n", __func__, __FILE__, __LINE__);
- return NULL;
+ dfsList[top] = 0;
} else {
//if Array
if(TYPE(header) > NUMCLASSES) {
} else { //linked list
dfsList[top] = getNextPointerOid(offsetarray, dfsList, &top, &depth);
}
- goto labelL1;
}
+ goto labelL1;
} else
continue;
}
} else if ((header = (objheader_t *) prehashSearch(oid)) != NULL) {
return header;
} else {
- //printf("Error: Cannot find header %s, %d\n", __func__, __LINE__);
+ ;
}
return NULL;
}
} else {
prehashInsert(oid, ptr);
}
+ objheader_t *head = prehashSearch(oid);
pthread_mutex_lock(&pflookup.lock);
pthread_cond_broadcast(&pflookup.cond);
pthread_mutex_unlock(&pflookup.lock);
} else if(control == OBJECT_NOT_FOUND) {
oid = *((unsigned int *)(recvbuffer + sizeof(char)));
- //printf("%s() Error: OBJ NOT FOUND.. THIS SHOULD NOT HAPPEN\n", __func__);
} else {
printf("%s() Error: in Decoding the control value %d, %s\n", __func__, __LINE__, __FILE__);
}
oidAtDepth_t odep;
/* Initialize */
+ perMcPrefetchList_t *head = NULL;
odep.oid = 0;
odep.depth = 0;
int i;
printf("%s() Error in sendOidNotFound() at line %d in %s()\n", __func__, __LINE__, __FILE__);
return -1;
}
+ //If not found forward request
+ forwardRequest(dfsList, &top, &depth, &numoffset, offsetarray);
+
//go up the tree
while((dfsList[top+1] == *(offsetarray + depth + 1)) && (depth >= 0)) {
if(top == depth) {
objheader_t *header;
header = searchObj(dfsList[prev]);
if(header == NULL) {
- printf("%s() Error Object not found at %s , %d\n", __func__, __FILE__, __LINE__);
- return -1;
- //return 0;
+ dfsList[top] = 0;
} else {
//if Array
if(TYPE(header) > NUMCLASSES) {
objheader_t * header;
header = searchObj(dfsList[prev]);
if(header == NULL) {
- printf("%s() Error Object not found at %s , %d\n", __func__, __FILE__, __LINE__);
- return -1;
- //return 0;
+ dfsList[top] = 0;
} else {
//if Array
if(TYPE(header) > NUMCLASSES) {
} else { //linked list
dfsList[top] = getNextPointerOid(offsetarray, dfsList, &top, &depth);
}
- goto labelL1;
}
+ goto labelL1;
} else
continue;
}
}
objheader_t *header = searchObj(oid);
if(header == NULL) {
- printf("%s() Error: Object not found at %s , %d\n", __func__, __FILE__, __LINE__);
return 0;
} else {
short stride = GET_STRIDE(*(offsetarray+(*depth) + 1));
unsigned int getNextPointerOid(short *offsetarray, unsigned int *dfsList, int *top, int* depth) {
int prev;
if(*(dfsList + *top + 1) > 1) { //tells which offset to calculate the oid from
- //(if range > 1 then use available oid to compute next oid else go to previous oid)
+ //(if range > 1 then use available oid to compute next oid else go to previous oid)
prev = *top;
} else {
prev = *top - 2;
}
objheader_t *header = searchObj(oid);
if(header == NULL) {
- printf("%s() Error: Object not found at %s , %d\n", __func__, __FILE__, __LINE__);
return 0;
} else {
int startelement = *(offsetarray + *depth);
} else if((header = (objheader_t *) prehashSearch(oid))!=NULL) {
;
} else {
- printf("%s() Error: THIS SHOULD NOT HAPPEN at line %d in %s()\n", __func__, __LINE__, __FILE__);
- return -1;
+ return 0;
}
int incr = 0;
sendPrefetchResponse(sd, &control, sendbuffer, &size);
return 0;
}
+
+void forwardRequest(unsigned int * dfsList, int *top, int *depth, int *numoffset, short * offsetarray) {
+ perMcPrefetchList_t *head = NULL;
+ unsigned int machinenum = lhashSearch(*(dfsList + *top));
+ insertPrefetch(machinenum, *(dfsList + *top), (*numoffset)-(*depth), &offsetarray[*depth], &head);
+
+ if(head!=NULL) {
+ // Get sock from shared pool
+ int sd = getSock2(transPrefetchSockPool, machinenum);
+ /* Send Prefetch Request */
+ sendRangePrefetchReq(head, sd);
+ /* Deallocated pilehead */
+ proPrefetchQDealloc(head);
+ }
+ return;
+}