Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Code refactor: move the functions associated to the request enabledness to mc_request.c
authorcristianrosa <cristianrosa@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 20 Jan 2011 15:45:53 +0000 (15:45 +0000)
committercristianrosa <cristianrosa@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 20 Jan 2011 15:45:53 +0000 (15:45 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9463 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/mc/mc_dpor.c
src/mc/mc_global.c
src/mc/mc_request.c
src/mc/mc_state.c
src/mc/private.h
src/simix/process_private.h
src/simix/smurf_private.h
src/simix/smx_process.c
src/simix/smx_smurf.c

index 7b481c9..ee8abeb 100644 (file)
@@ -32,7 +32,7 @@ void MC_dpor_init()
   MC_SET_RAW_MEM;
   /* Get an enabled process and insert it in the interleave set of the initial state */
   xbt_swag_foreach(process, simix_global->process_list){
-    if(SIMIX_process_is_enabled(process)){
+    if(MC_process_is_enabled(process)){
       MC_state_interleave_process(initial_state, process);
       break;
     }
@@ -105,7 +105,7 @@ void MC_dpor(void)
 
       /* Get an enabled process and insert it in the interleave set of the next state */
       xbt_swag_foreach(process, simix_global->process_list){
-        if(SIMIX_process_is_enabled(process)){
+        if(MC_process_is_enabled(process)){
           MC_state_interleave_process(next_state, process);
           break;
         }
index 7c77d37..4ac7758 100644 (file)
@@ -78,7 +78,7 @@ void MC_wait_for_requests(void)
   do {
     SIMIX_context_runall(simix_global->process_to_run);
     while((req = SIMIX_request_pop())){
-      if(!SIMIX_request_is_visible(req))
+      if(!MC_request_is_visible(req))
         SIMIX_request_pre(req, 0);
       else if(XBT_LOG_ISENABLED(mc_global, xbt_log_priority_debug)){
         req_str = MC_request_to_string(req);
@@ -97,7 +97,7 @@ int MC_deadlock_check()
     deadlock = TRUE;
     xbt_swag_foreach(process, simix_global->process_list){
       if(process->request.call != REQ_NO_REQ
-         && SIMIX_request_is_enabled(&process->request)){
+         && MC_request_is_enabled(&process->request)){
         deadlock = FALSE;
         break;
       }
index e50fe39..ac8840e 100644 (file)
@@ -145,3 +145,77 @@ unsigned int MC_request_testany_fail(smx_req_t req)
 
   return TRUE;
 }
+
+int MC_request_is_visible(smx_req_t req)
+{
+  return req->call == REQ_COMM_ISEND
+     || req->call == REQ_COMM_IRECV
+     || req->call == REQ_COMM_WAIT
+     || req->call == REQ_COMM_WAITANY
+     || req->call == REQ_COMM_TEST
+     || req->call == REQ_COMM_TESTANY;
+}
+
+int MC_request_is_enabled(smx_req_t req)
+{
+  unsigned int index = 0;
+  smx_action_t act;
+
+  switch (req->call) {
+
+    case REQ_COMM_WAIT:
+      /* FIXME: check also that src and dst processes are not suspended */
+
+      /* If there is a timeout it will be always enabled because, if the
+       * communication is not ready, it can timeout.
+       * This avoids false positives on dead-locks */
+      if(req->comm_wait.timeout >= 0)
+        return TRUE;
+
+      act = req->comm_wait.comm;
+      return (act->comm.src_proc && act->comm.dst_proc);
+      break;
+
+    case REQ_COMM_WAITANY:
+      xbt_dynar_foreach(req->comm_waitany.comms, index, act) {
+        if (act->comm.src_proc && act->comm.dst_proc){
+          return TRUE;
+        }
+      }
+      return FALSE;
+      break;
+
+    default:
+      return TRUE;
+  }
+}
+
+int MC_request_is_enabled_by_idx(smx_req_t req, unsigned int idx)
+{
+  smx_action_t act;
+
+  switch (req->call) {
+
+    case REQ_COMM_WAIT:
+      /* FIXME: check also that src and dst processes are not suspended */
+      act = req->comm_wait.comm;
+      return (act->comm.src_proc && act->comm.dst_proc);
+      break;
+
+    case REQ_COMM_WAITANY:
+      act = xbt_dynar_get_as(req->comm_waitany.comms, idx, smx_action_t);
+      return (act->comm.src_proc && act->comm.dst_proc);
+      break;
+
+    default:
+      return TRUE;
+  }
+}
+
+int MC_process_is_enabled(smx_process_t process)
+{
+  if (process->request.call != REQ_NO_REQ && MC_request_is_enabled(&process->request))
+    return TRUE;
+
+  return FALSE;
+}
index 5d6e506..9a5db9f 100644 (file)
@@ -116,12 +116,12 @@ smx_req_t MC_state_get_request(mc_state_t state, int *value)
     procstate = &state->proc_status[process->pid];
 
     if(procstate->state == MC_INTERLEAVE){
-      if(SIMIX_process_is_enabled(process)){
+      if(MC_process_is_enabled(process)){
         switch(process->request.call){
           case REQ_COMM_WAITANY:
             *value = -1;
             while(procstate->interleave_count < xbt_dynar_length(process->request.comm_waitany.comms)){
-              if(SIMIX_request_is_enabled_by_idx(&process->request, procstate->interleave_count++)){
+              if(MC_request_is_enabled_by_idx(&process->request, procstate->interleave_count++)){
                 *value = procstate->interleave_count-1;
                 break;
               }
@@ -143,7 +143,7 @@ smx_req_t MC_state_get_request(mc_state_t state, int *value)
             }
 
             while(procstate->interleave_count < xbt_dynar_length(process->request.comm_testany.comms)){
-              if(SIMIX_request_is_enabled_by_idx(&process->request, procstate->interleave_count++)){
+              if(MC_request_is_enabled_by_idx(&process->request, procstate->interleave_count++)){
                 *value = procstate->interleave_count - 1;
                 break;
               }
index a219245..359560e 100644 (file)
@@ -53,7 +53,11 @@ void MC_dump_stack(xbt_fifo_t stack);
 int MC_request_depend(smx_req_t req1, smx_req_t req2);
 char* MC_request_to_string(smx_req_t req);
 unsigned int MC_request_testany_fail(smx_req_t req);
-int MC_waitany_is_enabled_by_comm(smx_req_t req, unsigned int comm);
+/*int MC_waitany_is_enabled_by_comm(smx_req_t req, unsigned int comm);*/
+int MC_request_is_visible(smx_req_t req);
+int MC_request_is_enabled(smx_req_t req);
+int MC_request_is_enabled_by_idx(smx_req_t req, unsigned int idx);
+int MC_process_is_enabled(smx_process_t process);
 
 /********************************** DPOR **************************************/
 void MC_dpor_init(void);
index b7fc26b..e1c44b0 100644 (file)
@@ -69,7 +69,6 @@ void SIMIX_process_set_data(smx_process_t process, void *data);
 smx_host_t SIMIX_process_get_host(smx_process_t process);
 const char* SIMIX_process_get_name(smx_process_t process);
 int SIMIX_process_is_suspended(smx_process_t process);
-int SIMIX_process_is_enabled(smx_process_t process);
 xbt_dict_t SIMIX_process_get_properties(smx_process_t process);
 void SIMIX_pre_process_sleep(smx_req_t req);
 smx_action_t SIMIX_process_sleep(smx_process_t process, double duration);
index 7667dc7..2d6c1be 100644 (file)
@@ -476,9 +476,6 @@ smx_req_t SIMIX_request_pop(void);
 void SIMIX_request_answer(smx_req_t);
 void SIMIX_request_pre(smx_req_t, int);
 void SIMIX_request_post(smx_action_t);
-int SIMIX_request_is_visible(smx_req_t req);
-int SIMIX_request_is_enabled(smx_req_t req);
-int SIMIX_request_is_enabled_by_idx(smx_req_t req, unsigned int idx);
 XBT_INLINE smx_req_t SIMIX_req_mine(void);
 
 #endif
index 094a05d..ccd61f5 100644 (file)
@@ -405,14 +405,6 @@ int SIMIX_process_is_suspended(smx_process_t process)
   return process->suspended;
 }
 
-int SIMIX_process_is_enabled(smx_process_t process)
-{
-  if (process->request.call != REQ_NO_REQ && SIMIX_request_is_enabled(&process->request))
-    return TRUE;
-
-  return FALSE;
-}
-
 xbt_dict_t SIMIX_process_get_properties(smx_process_t process)
 {
   return process->properties;
index c873e2c..f80b6ce 100644 (file)
@@ -71,71 +71,6 @@ void SIMIX_request_answer(smx_req_t req)
   }
 }
 
-int SIMIX_request_is_visible(smx_req_t req)
-{
-  return req->call == REQ_COMM_ISEND
-     || req->call == REQ_COMM_IRECV
-     || req->call == REQ_COMM_WAIT
-     || req->call == REQ_COMM_WAITANY
-     || req->call == REQ_COMM_TEST
-     || req->call == REQ_COMM_TESTANY;
-}
-
-int SIMIX_request_is_enabled(smx_req_t req)
-{
-  unsigned int index = 0;
-  smx_action_t act;
-
-  switch (req->call) {
-
-    case REQ_COMM_WAIT:
-      /* FIXME: check also that src and dst processes are not suspended */
-      /* If there is a timeout it will be always enabled because, if the
-       * communication is not ready, it can timeout.
-       * This avoids false positives on dead-locks */
-      if(req->comm_wait.timeout >= 0)
-        return TRUE;
-
-      act = req->comm_wait.comm;
-      return (act->comm.src_proc && act->comm.dst_proc);
-      break;
-
-    case REQ_COMM_WAITANY:
-      xbt_dynar_foreach(req->comm_waitany.comms, index, act) {
-        if (act->comm.src_proc && act->comm.dst_proc){
-          return TRUE;
-        }
-      }
-      return FALSE;
-      break;
-
-    default:    
-      return TRUE;
-  }
-}
-
-int SIMIX_request_is_enabled_by_idx(smx_req_t req, unsigned int idx)
-{
-  smx_action_t act;
-
-  switch (req->call) {
-
-    case REQ_COMM_WAIT:
-      /* FIXME: check also that src and dst processes are not suspended */
-      act = req->comm_wait.comm;
-      return (act->comm.src_proc && act->comm.dst_proc);
-      break;
-
-    case REQ_COMM_WAITANY:
-      act = xbt_dynar_get_as(req->comm_waitany.comms, idx, smx_action_t);
-      return (act->comm.src_proc && act->comm.dst_proc);
-      break;
-
-    default:
-      return TRUE;
-  }
-}
-
 void SIMIX_request_pre(smx_req_t req, int value)
 {
   switch (req->call) {