1 /* Copyright (c) 2006-2017. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "src/msg/msg_private.h"
7 #include "src/simix/smx_synchro_private.hpp"
10 #include "simgrid/s4u/Mutex.hpp"
15 /** @brief Blocks the calling actor until the mutex can be obtained */
18 simcall_mutex_lock(mutex_);
21 /** @brief Release the ownership of the mutex, unleashing a blocked actor (if any)
23 * Will fail if the calling actor does not own the mutex.
27 simcall_mutex_unlock(mutex_);
30 /** @brief Acquire the mutex if it's free, and return false (without blocking) if not */
31 bool Mutex::try_lock()
33 return simcall_mutex_trylock(mutex_);
36 /** @brief Create a new mutex
40 MutexPtr Mutex::createMutex()
42 smx_mutex_t mutex = simcall_mutex_init();
43 return MutexPtr(&mutex->mutex(), false);