1 /* Copyright (c) 2006-2015. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
8 #include "src/msg/msg_private.h"
9 #include "src/simix/smx_synchro_private.h"
11 #include "simgrid/s4u/Mutex.hpp"
16 /** @brief Blocks the calling actor until the mutex can be obtained */
19 simcall_mutex_lock(mutex_);
22 /** @brief Release the ownership of the mutex, unleashing a blocked actor (if any)
24 * Will fail if the calling actor does not own the mutex.
28 simcall_mutex_unlock(mutex_);
31 /** @brief Acquire the mutex if it's free, and return false (without blocking) if not */
32 bool Mutex::try_lock()
34 return simcall_mutex_trylock(mutex_);
37 /** @brief Create a new mutex
41 MutexPtr Mutex::createMutex()
43 smx_mutex_t mutex = simcall_mutex_init();
44 return MutexPtr(&mutex->mutex(), false);