Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into depencencies
[simgrid.git] / src / kernel / activity / MutexImpl.cpp
index 7d528fa..8505e91 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -68,12 +68,11 @@ void MutexImpl::unlock(actor::ActorImpl* issuer)
              owner_->get_cname(), owner_->get_pid());
 
   if (not sleeping_.empty()) {
-    /* pick one actor to wake up */
-    actor::ActorImpl* act = &sleeping_.front();
+    /* Give the ownership to the first waiting actor */
+    owner_ = &sleeping_.front();
     sleeping_.pop_front();
-    act->waiting_synchro = nullptr;
-    owner_             = act;
-    act->simcall_answer();
+    owner_->waiting_synchro = nullptr;
+    owner_->simcall_answer();
   } else {
     /* nobody to wake up */
     locked_ = false;
@@ -102,15 +101,15 @@ void MutexImpl::unref()
 
 void simcall_HANDLER_mutex_lock(smx_simcall_t simcall, smx_mutex_t mutex)
 {
-  mutex->lock(simcall->issuer);
+  mutex->lock(simcall->issuer_);
 }
 
 int simcall_HANDLER_mutex_trylock(smx_simcall_t simcall, smx_mutex_t mutex)
 {
-  return mutex->try_lock(simcall->issuer);
+  return mutex->try_lock(simcall->issuer_);
 }
 
 void simcall_HANDLER_mutex_unlock(smx_simcall_t simcall, smx_mutex_t mutex)
 {
-  mutex->unlock(simcall->issuer);
+  mutex->unlock(simcall->issuer_);
 }