#ifdef DEBUG
BAMBOO_DEBUGPRINT(0xee02);
#endif
+ int entry_index = 0;
+ if(waitconfirm) {
+ // phase 2
+ entry_index = (gcnumsrobjs_index == 0) ? 1 : 0;
+ } else {
+ // phase 1
+ entry_index = gcnumsrobjs_index;
+ }
BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
gccorestatus[BAMBOO_NUM_OF_CORE] = 0;
- gcnumsendobjs[BAMBOO_NUM_OF_CORE] = gcself_numsendobjs;
- gcnumreceiveobjs[BAMBOO_NUM_OF_CORE] = gcself_numreceiveobjs;
+ gcnumsendobjs[entry_index][BAMBOO_NUM_OF_CORE] = gcself_numsendobjs;
+ gcnumreceiveobjs[entry_index][BAMBOO_NUM_OF_CORE] = gcself_numreceiveobjs;
// check the status of all cores
bool allStall = gc_checkAllCoreStatus_I();
#ifdef DEBUG
gccorestatus[i] = 1;
// send mark phase finish confirm request msg to core i
send_msg_1(i, GCMARKCONFIRM, false);
- } // for(i = 1; i < NUMCORESACTIVE; ++i)
+ } // for(i = 1; i < NUMCORESACTIVE; ++i)
} else {
+ // Phase 2
// check if the sum of send objs and receive obj are the same
// yes->check if the info is the latest; no->go on executing
int sumsendobj = 0;
for(i = 0; i < NUMCORESACTIVE; ++i) {
- sumsendobj += gcnumsendobjs[i];
- } // for(i = 0; i < NUMCORESACTIVE; ++i)
+ sumsendobj += gcnumsendobjs[gcnumsrobjs_index][i];
+ } // for(i = 0; i < NUMCORESACTIVE; ++i)
#ifdef DEBUG
BAMBOO_DEBUGPRINT(0xee06);
BAMBOO_DEBUGPRINT_REG(sumsendobj);
#endif
for(i = 0; i < NUMCORESACTIVE; ++i) {
- sumsendobj -= gcnumreceiveobjs[i];
- } // for(i = 0; i < NUMCORESACTIVE; ++i)
+ sumsendobj -= gcnumreceiveobjs[gcnumsrobjs_index][i];
+ } // for(i = 0; i < NUMCORESACTIVE; ++i)
#ifdef DEBUG
BAMBOO_DEBUGPRINT(0xee07);
BAMBOO_DEBUGPRINT_REG(sumsendobj);
#endif
if(0 == sumsendobj) {
+ // Check if there are changes of the numsendobjs or numreceiveobjs on
+ // each core
+ bool ischanged = false;
+ for(i = 0; i < NUMCORESACTIVE; ++i) {
+ if((gcnumsendobjs[0][i] != gcnumsendobjs[1][i]) ||
+ (gcnumreceiveobjs[0][i] != gcnumreceiveobjs[1][i]) ) {
+ ischanged = true;
+ break;
+ }
+ } // for(i = 0; i < NUMCORESACTIVE; ++i)
#ifdef DEBUG
BAMBOO_DEBUGPRINT(0xee08);
+ BAMBOO_DEBUGPRINT_REG(ischanged);
#endif
- // all the core status info are the latest
- // stop mark phase
- gcphase = COMPACTPHASE;
- // restore the gcstatus for all cores
- for(i = 0; i < NUMCORESACTIVE; ++i) {
- gccorestatus[i] = 1;
- } // for(i = 0; i < NUMCORESACTIVE; ++i)
+ if(!ischanged) {
+#ifdef DEBUG
+ BAMBOO_DEBUGPRINT(0xee09);
+#endif
+ // all the core status info are the latest
+ // stop mark phase
+ gcphase = COMPACTPHASE;
+ // restore the gcstatus for all cores
+ for(i = 0; i < NUMCORESACTIVE; ++i) {
+ gccorestatus[i] = 1;
+ } // for(i = 0; i < NUMCORESACTIVE; ++i)
+ } else {
+ waitconfirm = false;
+ gcnumsrobjs_index = (gcnumsrobjs_index == 0) ? 1 : 0;
+ } // if(!ischanged)
} else {
- // wait for a while and ask for confirm again
- int h = 100;
- while(h--) {
- }
+ // There were changes between phase 1 and phase 2, can not decide
+ // whether the mark phase has been finished
waitconfirm = false;
- } // if(0 == sumsendobj) else ...
+ // As it fails in phase 2, flip the entries
+ gcnumsrobjs_index = (gcnumsrobjs_index == 0) ? 1 : 0;
+ } // if(0 == sumsendobj) else ...
BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
- } // if(!gcwaitconfirm) else()
+ } // if(!gcwaitconfirm) else()
} else {
BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
- } // if(allStall)
- } // if((!waitconfirm)...
+ } // if(allStall)
+ } // if((!waitconfirm)...
#ifdef DEBUG
BAMBOO_DEBUGPRINT(0xee0a);
#endif
if(STARTUPCORE == BAMBOO_NUM_OF_CORE) {
for(i = 0; i < NUMCORES4GC; ++i) {
gccorestatus[i] = 1;
- gcnumsendobjs[i] = 0;
- gcnumreceiveobjs[i] = 0;
+ gcnumsendobjs[0][i] = gcnumsendobjs[1][i] = 0;
+ gcnumreceiveobjs[0][i] = gcnumreceiveobjs[1][i] = 0;
gcloads[i] = 0;
gcrequiredmems[i] = 0;
gcfilledblocks[i] = 0;
} // for(i = 0; i < NUMCORES4GC; ++i)
for(i = NUMCORES4GC; i < NUMCORESACTIVE; ++i) {
gccorestatus[i] = 1;
- gcnumsendobjs[i] = 0;
- gcnumreceiveobjs[i] = 0;
+ gcnumsendobjs[0][i] = gcnumsendobjs[1][i] = 0;
+ gcnumreceiveobjs[0][i] = gcnumreceiveobjs[1][i] = 0;
}
gcheaptop = 0;
gctopcore = 0;
BAMBOO_DEBUGPRINT(0xed08);
#endif
gccorestatus[BAMBOO_NUM_OF_CORE] = 0;
- gcnumsendobjs[BAMBOO_NUM_OF_CORE] = gcself_numsendobjs;
- gcnumreceiveobjs[BAMBOO_NUM_OF_CORE] = gcself_numreceiveobjs;
+ gcnumsendobjs[gcnumsrobjs_index][BAMBOO_NUM_OF_CORE]=gcself_numsendobjs;
+ gcnumreceiveobjs[gcnumsrobjs_index][BAMBOO_NUM_OF_CORE]=
+ gcself_numreceiveobjs;
gcloads[BAMBOO_NUM_OF_CORE] = gccurr_heaptop;
} else {
if(!sendStall) {
volatile int gccorestatus[NUMCORESACTIVE]; // records status of each core
// 1: running gc
// 0: stall
-volatile int gcnumsendobjs[NUMCORESACTIVE]; //records how many objects sent out
-volatile int gcnumreceiveobjs[NUMCORESACTIVE]; //records how many objects
- //received
+volatile int gcnumsendobjs[2][NUMCORESACTIVE]; // the # of objects sent out
+volatile int gcnumreceiveobjs[2][NUMCORESACTIVE]; // the # of objects received
+volatile int gcnumsrobjs_index; // indicates which entry to record the info
+ // received before phase 1 of the mark finish
+ // checking process
+ // the info received in phase 2 must be
+ // recorded in the other entry
volatile bool gcbusystatus;
int gcself_numsendobjs;
int gcself_numreceiveobjs;
{0, -1, -1, -1, -1, -1, -1, -1, -1}
};
#elif defined GC_56
-int core2test[56][5] = {
+int core2test[56][NUM_CORES2TEST] = {
{ 0, -1, 7, -1, 1, -1, 14, -1, 2}, { 1, -1, 8, 0, 2, -1, 15, -1, 3},
{ 2, -1, 9, 1, 3, -1, 16, 0, 4}, { 3, -1, 10, 2, 4, -1, 17, 1, 5},
{ 4, -1, 11, 3, 5, -1, 18, 2, 6}, { 5, -1, 12, 4, 6, -1, 19, 3, -1},
{54, 47, -1, 53, 55, 40, -1, 52, -1}, {55, 48, -1, 54, -1, 41, -1, 53, -1}
};
#elif defined GC_62
-int core2test[62][5] = {
+int core2test[62][NUM_CORES2TEST] = {
{ 0, -1, 6, -1, 1, -1, 14, -1, 2}, { 1, -1, 7, 0, 2, -1, 15, -1, 3},
{ 2, -1, 8, 1, 3, -1, 16, 0, 4}, { 3, -1, 9, 2, 4, -1, 17, 1, 5},
{ 4, -1, 10, 3, 5, -1, 18, 2, -1}, { 5, -1, 11, 4, -1, -1, 19, 3, -1},
#endif
#ifdef MULTICORE_GC
gccorestatus[i] = 1;
- gcnumsendobjs[i] = 0;
- gcnumreceiveobjs[i] = 0;
+ gcnumsendobjs[0][i] = gcnumsendobjs[1][i] = 0;
+ gcnumreceiveobjs[0][i] = gcnumreceiveobjs[1][i] = 0;
#endif
} // for(i = 0; i < NUMCORESACTIVE; ++i)
#ifdef MULTICORE_GC
// all cores should do mark
if(data1 < NUMCORESACTIVE) {
gccorestatus[data1] = 0;
- gcnumsendobjs[data1] = data2;
- gcnumreceiveobjs[data1] = data3;
+ int entry_index = 0;
+ if(waitconfirm) {
+ // phase 2
+ entry_index = (gcnumsrobjs_index == 0) ? 1 : 0;
+ } else {
+ // phase 1
+ entry_index = gcnumsrobjs_index;
+ }
+ gcnumsendobjs[entry_index][data1] = data2;
+ gcnumreceiveobjs[entry_index][data1] = data3;
}
}
#endif
BAMBOO_EXIT(0xb007);
} else {
+ int entry_index = 0;
if(waitconfirm) {
+ // phse 2
numconfirm--;
- }
+ entry_index = (gcnumsrobjs_index == 0) ? 1 : 0;
+ } else {
+ // can never reach here
+ // phase 1
+ entry_index = gcnumsrobjs_index;
+ }
gccorestatus[data1] = data2;
- gcnumsendobjs[data1] = data3;
- gcnumreceiveobjs[data1] = data4;
+ gcnumsendobjs[entry_index][data1] = data3;
+ gcnumreceiveobjs[entry_index][data1] = data4;
}
}