Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Make SIMCALL_MUTEX_TRYLOCK visible and forbid usage of MUTEX operations with...
[simgrid.git] / src / mc / mc_request.cpp
index 2c9dd02..9791660 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2014. The SimGrid Team.
+/* Copyright (c) 2008-2015. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -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,8 +657,12 @@ 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", req->issuer->pid);
+    label = bprintf("[(%lu)] Mutex LOCK", issuer->pid);
     break;
 
   case SIMCALL_MC_RANDOM: