Delivering a single message in the queue conditionally
authorFilippo Gioachin <gioachin@uiuc.edu>
Fri, 28 May 2010 18:22:52 +0000 (13:22 -0500)
committerFilippo Gioachin <gioachin@uiuc.edu>
Fri, 28 May 2010 18:22:52 +0000 (13:22 -0500)
src/ck-core/debug-charm.C
src/ck-core/debug-charm.h

index e7aa698f096ac71b91fa38da3f1d50da4c3d4486..c26abb7e6a94add33432d9b9187e81aca2a36191 100644 (file)
@@ -532,6 +532,56 @@ void CpdDeliverMessage(char * msg) {
   while ((m=CdsFifo_Dequeue(debugQ)) != (void*)(-1)) CdsFifo_Enqueue(debugQ, m);  
 }
 
+void CpdConditionalDeliveryScheduler() {
+  CsdSchedulerState_t state;
+  CsdSchedulerState_new(&state);
+  while (CpvAccess(conditionalDelivery)) {
+#if NODE_0_IS_CONVHOST
+    if (CmiMyPe()==0) CcsServerCheck(); /*Make sure we can get CCS messages*/
+#endif
+    msg = CsdNextMessage(&state);
+    
+  }
+}
+
+#include <sys/wait.h>
+void CpdDeliverMessageConditionally(char * msg) {
+  int msgNum;
+  void *m;
+  sscanf(msg+CmiMsgHeaderSizeBytes, "%d", &msgNum);
+  //CmiPrintf("received deliver request %d\n",msgNum);
+
+  pid_t pid = fork();
+  if (pid > 0) {
+    CmiPrintf("parent %d\n",pid);
+    CpdConditionalDeliveryScheduler();
+    wait(NULL);
+    return;
+  }
+  
+  //while (true);
+  printf("child\n");
+  //while (1);
+  //_exit(0);
+  _replaySystem = 1;
+
+  void *debugQ=CpvAccess(debugQueue);
+  CdsFifo_Enqueue(debugQ, (void*)(-1)); // Enqueue a guard
+  for (int i=0; i<msgNum; ++i) CdsFifo_Enqueue(debugQ, CdsFifo_Dequeue(debugQ));
+  CkpvAccess(skipBreakpoint) = 1;
+  char *queuedMsg = (char *)CdsFifo_Dequeue(debugQ);
+#if CMK_BLUEGENE_CHARM
+  stopVTimer();
+  BgProcessMessageDefault(cta(threadinfo), queuedMsg);
+  startVTimer();
+#else
+  CmiHandleMessage(queuedMsg);
+#endif
+  CkpvAccess(skipBreakpoint) = 0;
+  _exit(0);
+  while ((m=CdsFifo_Dequeue(debugQ)) != (void*)(-1)) CdsFifo_Enqueue(debugQ, m);  
+}
+
 class CpdList_msgStack : public CpdListAccessor {
   virtual const char * getPath(void) const {return "charm/messageStack";}
   virtual size_t getLength(void) const {
@@ -855,6 +905,7 @@ void CpdCharmInit()
   CpdListRegister(new CpdListAccessor_c("hostinfo",hostInfoLength,0,hostInfo,0));
   CpdListRegister(new CpdList_localQ());
   CcsRegisterHandler("deliverMessage",(CmiHandler)CpdDeliverMessage);
+  CcsRegisterHandler("deliverConditional",(CmiHandler)CpdDeliverMessageConditionally);
   CpdListRegister(new CpdList_arrayElementNames());
   CpdListRegister(new CpdList_arrayElements());
   CpdListRegister(new CpdList_objectNames());
index e2b2a29bde8e7ca5352694c1307835d5afbd78a2..047e042ba8799e83285026d12f5354c9e7bbe7bb 100644 (file)
@@ -15,7 +15,7 @@
 #include "cklists.h"
 
 #define CHARMDEBUG_MAJOR   10
-#define CHARMDEBUG_MINOR    1
+#define CHARMDEBUG_MINOR    2
 
 void *CpdGetCurrentObject();
 void *CpdGetCurrentMsg();