Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
07a4ab63b732653c249d5ada2746faa8df2206da
[simgrid.git] / src / simix / smx_synchro.cpp
1 /* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
2
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. */
5
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"
11
12 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_synchro, simix, "SIMIX Synchronization (mutex, semaphores and conditions)");
13
14 /***************************** Raw synchronization *********************************/
15
16 void SIMIX_synchro_stop_waiting(smx_actor_t process, smx_simcall_t simcall)
17 {
18   XBT_IN("(%p, %p)",process,simcall);
19   switch (simcall->call) {
20
21     case SIMCALL_MUTEX_LOCK:
22       simgrid::xbt::intrusive_erase(simcall_mutex_lock__get__mutex(simcall)->sleeping, *process);
23       break;
24
25     case SIMCALL_COND_WAIT:
26       simgrid::xbt::intrusive_erase(simcall_cond_wait__get__cond(simcall)->sleeping, *process);
27       break;
28
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
32       break;
33
34     case SIMCALL_SEM_ACQUIRE:
35       simgrid::xbt::intrusive_erase(simcall_sem_acquire__get__sem(simcall)->sleeping_, *process);
36       break;
37
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
41       break;
42
43     default:
44       THROW_IMPOSSIBLE;
45   }
46   XBT_OUT();
47 }