Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Make SIMCALL_MUTEX_TRYLOCK visible and forbid usage of MUTEX operations with...
authorGabriel Corona <gabriel.corona@loria.fr>
Fri, 28 Aug 2015 09:01:45 +0000 (11:01 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Fri, 28 Aug 2015 09:01:45 +0000 (11:01 +0200)
- DPOR currently does not handle SIMCALL_MUTEX operations;

- MUTEX_TRYLOCK should be visible: depending on the interleavigns it
  might succeed or fail.

src/mc/mc_base.cpp
src/mc/mc_request.cpp
src/mc/mc_safety.cpp

index 8c8610f..74c8268 100644 (file)
@@ -142,6 +142,9 @@ int MC_request_is_enabled(smx_simcall_t req)
     return FALSE;
   }
 
+  case SIMCALL_MUTEX_TRYLOCK:
+    return TRUE;
+
   case SIMCALL_MUTEX_LOCK: {
     smx_mutex_t mutex = simcall_mutex_lock__get__mutex(req);
 #ifdef HAVE_MC
@@ -179,6 +182,7 @@ int MC_request_is_visible(smx_simcall_t req)
       || req->call == SIMCALL_COMM_TESTANY
       || req->call == SIMCALL_MC_RANDOM
       || req->call == SIMCALL_MUTEX_LOCK
+      || req->call == SIMCALL_MUTEX_TRYLOCK
 #ifdef HAVE_MC
       || req->call == SIMCALL_MC_SNAPSHOT
       || req->call == SIMCALL_MC_COMPARE_SNAPSHOTS
index 4503597..9791660 100644 (file)
@@ -401,12 +401,20 @@ char *MC_request_to_string(smx_simcall_t req, int value, e_mc_request_type_t req
     }
     break;
 
+  case SIMCALL_MUTEX_TRYLOCK:
   case SIMCALL_MUTEX_LOCK: {
-    type = "Mutex LOCK";
+    if (req->call == SIMCALL_MUTEX_LOCK)
+      type = "Mutex LOCK";
+    else
+      type = "Mutex TRYLOCK";
 
     s_smx_mutex_t mutex;
     mc_model_checker->process().read_bytes(&mutex, sizeof(mutex),
-      remote(simcall_mutex_lock__get__mutex(req)));
+      remote(
+        req->call == SIMCALL_MUTEX_LOCK
+        ? simcall_mutex_lock__get__mutex(req)
+        : simcall_mutex_trylock__get__mutex(req)
+      ));
     s_xbt_swag_t mutex_sleeping;
     mc_model_checker->process().read_bytes(&mutex_sleeping, sizeof(mutex_sleeping),
       remote(mutex.sleeping));
@@ -649,6 +657,10 @@ char *MC_request_get_dot_output(smx_simcall_t req, int value)
     }
     break;
 
+  case SIMCALL_MUTEX_TRYLOCK:
+    label = bprintf("[(%lu)] Mutex TRYLOCK", issuer->pid);
+    break;
+
   case SIMCALL_MUTEX_LOCK:
     label = bprintf("[(%lu)] Mutex LOCK", issuer->pid);
     break;
index 2ca64ec..7336489 100644 (file)
@@ -199,6 +199,9 @@ void MC_modelcheck_safety(void)
       while ((state = (mc_state_t) xbt_fifo_shift(mc_stack))) {
         if (mc_reduce_kind == e_mc_reduce_dpor) {
           req = MC_state_get_internal_request(state);
+          if (req->call == SIMCALL_MUTEX_LOCK || req->call == SIMCALL_MUTEX_TRYLOCK)
+            xbt_die("Mutex is currently not supported with DPOR, "
+              "use --cfg=model-check/reduction:dpor");
           const smx_process_t issuer = MC_smx_simcall_get_issuer(req);
           xbt_fifo_foreach(mc_stack, item, prev_state, mc_state_t) {
             if (MC_request_depend(req, MC_state_get_internal_request(prev_state))) {