1 /* Copyright (c) 2007-2019. 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/kernel/activity/ConditionVariableImpl.hpp"
7 #include "src/kernel/activity/MutexImpl.hpp"
8 #include "src/kernel/activity/SemaphoreImpl.hpp"
9 #include "src/kernel/context/Context.hpp"
10 #include "src/simix/smx_synchro_private.hpp"
12 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_synchro, simix, "SIMIX Synchronization (mutex, semaphores and conditions)");
14 /***************************** Raw synchronization *********************************/
16 void SIMIX_synchro_stop_waiting(smx_actor_t process, smx_simcall_t simcall)
18 XBT_IN("(%p, %p)",process,simcall);
19 switch (simcall->call) {
21 case SIMCALL_MUTEX_LOCK:
22 simgrid::xbt::intrusive_erase(simcall_mutex_lock__get__mutex(simcall)->sleeping, *process);
25 case SIMCALL_COND_WAIT:
26 simgrid::xbt::intrusive_erase(simcall_cond_wait__get__cond(simcall)->sleeping, *process);
29 case SIMCALL_COND_WAIT_TIMEOUT:
30 simgrid::xbt::intrusive_erase(simcall_cond_wait_timeout__get__cond(simcall)->sleeping, *process);
31 simcall_cond_wait_timeout__set__result(simcall, 1); // signal a timeout
34 case SIMCALL_SEM_ACQUIRE:
35 simgrid::xbt::intrusive_erase(simcall_sem_acquire__get__sem(simcall)->sleeping_, *process);
38 case SIMCALL_SEM_ACQUIRE_TIMEOUT:
39 simgrid::xbt::intrusive_erase(simcall_sem_acquire_timeout__get__sem(simcall)->sleeping_, *process);
40 simcall_sem_acquire_timeout__set__result(simcall, 1); // signal a timeout