XBT_PUBLIC(void) simcall_cond_wait_timeout(smx_cond_t cond, smx_mutex_t mutex, double max_duration);
XBT_PUBLIC(void) simcall_cond_broadcast(smx_cond_t cond);
-XBT_PUBLIC(smx_sem_t) simcall_sem_init(int capacity);
XBT_PUBLIC(void) SIMIX_sem_destroy(smx_sem_t sem);
-XBT_PUBLIC(void) simcall_sem_release(smx_sem_t sem);
-XBT_PUBLIC(int) simcall_sem_would_block(smx_sem_t sem);
XBT_PUBLIC(void) simcall_sem_acquire(smx_sem_t sem);
XBT_PUBLIC(void) simcall_sem_acquire_timeout(smx_sem_t sem, double max_duration);
-XBT_PUBLIC(int) simcall_sem_get_capacity(smx_sem_t sem);
/***************************** File **********************************/
XBT_PUBLIC(sg_size_t) simcall_file_read(surf_file_t fd, sg_size_t size);
#include "xbt/ex.hpp"
#include "msg_private.h"
+#include "src/simix/smx_private.h"
#include "xbt/synchro.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_synchro, msg, "Logging specific to MSG (synchro)");
/** @brief creates a semaphore object of the given initial capacity */
msg_sem_t MSG_sem_init(int initial_value) {
- return simcall_sem_init(initial_value);
+ return simgrid::simix::kernelImmediate([initial_value] { return SIMIX_sem_init(initial_value); });
}
/** @brief locks on a semaphore object */
/** @brief releases the semaphore object */
void MSG_sem_release(msg_sem_t sem) {
- simcall_sem_release(sem);
+ simgrid::simix::kernelImmediate([sem] { SIMIX_sem_release(sem); });
}
int MSG_sem_get_capacity(msg_sem_t sem) {
- return simcall_sem_get_capacity(sem);
+ return simgrid::simix::kernelImmediate([sem] { return SIMIX_sem_get_capacity(sem); });
}
void MSG_sem_destroy(msg_sem_t sem) {
* But that's a classical semaphore issue, and SimGrid's semaphore are not different to usual ones here.
*/
int MSG_sem_would_block(msg_sem_t sem) {
- return simcall_sem_would_block(sem);
+ return simgrid::simix::kernelImmediate([sem] { return SIMIX_sem_would_block(sem); });
}
/*-**** barrier related functions ****-*/
simcall_BODY_cond_broadcast(cond);
}
-/**
- * \ingroup simix_synchro_management
- *
- */
-smx_sem_t simcall_sem_init(int capacity)
-{
- return simcall_BODY_sem_init(capacity);
-}
-
-/**
- * \ingroup simix_synchro_management
- *
- */
-void simcall_sem_release(smx_sem_t sem)
-{
- simcall_BODY_sem_release(sem);
-}
-
-/**
- * \ingroup simix_synchro_management
- *
- */
-int simcall_sem_would_block(smx_sem_t sem)
-{
- return simcall_BODY_sem_would_block(sem);
-}
-
/**
* \ingroup simix_synchro_management
*
simcall_BODY_sem_acquire_timeout(sem, timeout);
}
-/**
- * \ingroup simix_synchro_management
- *
- */
-int simcall_sem_get_capacity(smx_sem_t sem)
-{
- return simcall_BODY_sem_get_capacity(sem);
-}
-
/**
* \ingroup simix_file_management
*
simgrid::simix::marshal<smx_cond_t>(simcall->args[0], arg);
}
-static inline unsigned int simcall_sem_init__get__capacity(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal<unsigned int>(simcall->args[0]);
-}
-static inline unsigned int simcall_sem_init__getraw__capacity(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal_raw<unsigned int>(simcall->args[0]);
-}
-static inline void simcall_sem_init__set__capacity(smx_simcall_t simcall, unsigned int arg)
-{
- simgrid::simix::marshal<unsigned int>(simcall->args[0], arg);
-}
-static inline smx_sem_t simcall_sem_init__get__result(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal<smx_sem_t>(simcall->result);
-}
-static inline smx_sem_t simcall_sem_init__getraw__result(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal_raw<smx_sem_t>(simcall->result);
-}
-static inline void simcall_sem_init__set__result(smx_simcall_t simcall, smx_sem_t result){
- simgrid::simix::marshal<smx_sem_t>(simcall->result, result);
-}
-
-static inline smx_sem_t simcall_sem_release__get__sem(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal<smx_sem_t>(simcall->args[0]);
-}
-static inline smx_sem_t simcall_sem_release__getraw__sem(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal_raw<smx_sem_t>(simcall->args[0]);
-}
-static inline void simcall_sem_release__set__sem(smx_simcall_t simcall, smx_sem_t arg)
-{
- simgrid::simix::marshal<smx_sem_t>(simcall->args[0], arg);
-}
-
-static inline smx_sem_t simcall_sem_would_block__get__sem(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal<smx_sem_t>(simcall->args[0]);
-}
-static inline smx_sem_t simcall_sem_would_block__getraw__sem(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal_raw<smx_sem_t>(simcall->args[0]);
-}
-static inline void simcall_sem_would_block__set__sem(smx_simcall_t simcall, smx_sem_t arg)
-{
- simgrid::simix::marshal<smx_sem_t>(simcall->args[0], arg);
-}
-static inline int simcall_sem_would_block__get__result(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal<int>(simcall->result);
-}
-static inline int simcall_sem_would_block__getraw__result(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal_raw<int>(simcall->result);
-}
-static inline void simcall_sem_would_block__set__result(smx_simcall_t simcall, int result){
- simgrid::simix::marshal<int>(simcall->result, result);
-}
-
static inline smx_sem_t simcall_sem_acquire__get__sem(smx_simcall_t simcall)
{
return simgrid::simix::unmarshal<smx_sem_t>(simcall->args[0]);
simgrid::simix::marshal<double>(simcall->args[1], arg);
}
-static inline smx_sem_t simcall_sem_get_capacity__get__sem(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal<smx_sem_t>(simcall->args[0]);
-}
-static inline smx_sem_t simcall_sem_get_capacity__getraw__sem(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal_raw<smx_sem_t>(simcall->args[0]);
-}
-static inline void simcall_sem_get_capacity__set__sem(smx_simcall_t simcall, smx_sem_t arg)
-{
- simgrid::simix::marshal<smx_sem_t>(simcall->args[0], arg);
-}
-static inline int simcall_sem_get_capacity__get__result(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal<int>(simcall->result);
-}
-static inline int simcall_sem_get_capacity__getraw__result(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal_raw<int>(simcall->result);
-}
-static inline void simcall_sem_get_capacity__set__result(smx_simcall_t simcall, int result){
- simgrid::simix::marshal<int>(simcall->result, result);
-}
-
static inline surf_file_t simcall_file_read__get__fd(smx_simcall_t simcall)
{
return simgrid::simix::unmarshal<surf_file_t>(simcall->args[0]);
XBT_PRIVATE int simcall_HANDLER_mutex_trylock(smx_simcall_t simcall, smx_mutex_t mutex);
XBT_PRIVATE void simcall_HANDLER_cond_wait(smx_simcall_t simcall, smx_cond_t cond, smx_mutex_t mutex);
XBT_PRIVATE void simcall_HANDLER_cond_wait_timeout(smx_simcall_t simcall, smx_cond_t cond, smx_mutex_t mutex, double timeout);
-XBT_PRIVATE void simcall_HANDLER_sem_release(smx_simcall_t simcall, smx_sem_t sem);
-XBT_PRIVATE int simcall_HANDLER_sem_would_block(smx_simcall_t simcall, smx_sem_t sem);
XBT_PRIVATE void simcall_HANDLER_sem_acquire(smx_simcall_t simcall, smx_sem_t sem);
XBT_PRIVATE void simcall_HANDLER_sem_acquire_timeout(smx_simcall_t simcall, smx_sem_t sem, double timeout);
-XBT_PRIVATE int simcall_HANDLER_sem_get_capacity(smx_simcall_t simcall, smx_sem_t sem);
XBT_PRIVATE void simcall_HANDLER_file_read(smx_simcall_t simcall, surf_file_t fd, sg_size_t size);
XBT_PRIVATE void simcall_HANDLER_file_write(smx_simcall_t simcall, surf_file_t fd, sg_size_t size);
XBT_PRIVATE int simcall_HANDLER_mc_random(smx_simcall_t simcall, int min, int max);
\ No newline at end of file
return simcall<void, smx_cond_t>(SIMCALL_COND_BROADCAST, cond);
}
-inline static smx_sem_t simcall_BODY_sem_init(unsigned int capacity) {
- /* Go to that function to follow the code flow through the simcall barrier */
- if (0) SIMIX_sem_init(capacity);
- return simcall<smx_sem_t, unsigned int>(SIMCALL_SEM_INIT, capacity);
- }
-
-inline static void simcall_BODY_sem_release(smx_sem_t sem) {
- /* Go to that function to follow the code flow through the simcall barrier */
- if (0) simcall_HANDLER_sem_release(&SIMIX_process_self()->simcall, sem);
- return simcall<void, smx_sem_t>(SIMCALL_SEM_RELEASE, sem);
- }
-
-inline static int simcall_BODY_sem_would_block(smx_sem_t sem) {
- /* Go to that function to follow the code flow through the simcall barrier */
- if (0) simcall_HANDLER_sem_would_block(&SIMIX_process_self()->simcall, sem);
- return simcall<int, smx_sem_t>(SIMCALL_SEM_WOULD_BLOCK, sem);
- }
-
inline static void simcall_BODY_sem_acquire(smx_sem_t sem) {
/* Go to that function to follow the code flow through the simcall barrier */
if (0) simcall_HANDLER_sem_acquire(&SIMIX_process_self()->simcall, sem);
return simcall<void, smx_sem_t, double>(SIMCALL_SEM_ACQUIRE_TIMEOUT, sem, timeout);
}
-inline static int simcall_BODY_sem_get_capacity(smx_sem_t sem) {
- /* Go to that function to follow the code flow through the simcall barrier */
- if (0) simcall_HANDLER_sem_get_capacity(&SIMIX_process_self()->simcall, sem);
- return simcall<int, smx_sem_t>(SIMCALL_SEM_GET_CAPACITY, sem);
- }
-
inline static sg_size_t simcall_BODY_file_read(surf_file_t fd, sg_size_t size)
{
/* Go to that function to follow the code flow through the simcall barrier */
SIMCALL_COND_WAIT,
SIMCALL_COND_WAIT_TIMEOUT,
SIMCALL_COND_BROADCAST,
- SIMCALL_SEM_INIT,
- SIMCALL_SEM_RELEASE,
- SIMCALL_SEM_WOULD_BLOCK,
SIMCALL_SEM_ACQUIRE,
SIMCALL_SEM_ACQUIRE_TIMEOUT,
- SIMCALL_SEM_GET_CAPACITY,
SIMCALL_FILE_READ,
SIMCALL_FILE_WRITE,
SIMCALL_MC_RANDOM,
"SIMCALL_COND_WAIT",
"SIMCALL_COND_WAIT_TIMEOUT",
"SIMCALL_COND_BROADCAST",
- "SIMCALL_SEM_INIT",
- "SIMCALL_SEM_RELEASE",
- "SIMCALL_SEM_WOULD_BLOCK",
"SIMCALL_SEM_ACQUIRE",
"SIMCALL_SEM_ACQUIRE_TIMEOUT",
- "SIMCALL_SEM_GET_CAPACITY",
"SIMCALL_FILE_READ",
"SIMCALL_FILE_WRITE",
"SIMCALL_MC_RANDOM",
SIMIX_simcall_answer(simcall);
break;
-case SIMCALL_SEM_INIT:
- simgrid::simix::marshal<smx_sem_t>(simcall->result, SIMIX_sem_init(simgrid::simix::unmarshal<unsigned int>(simcall->args[0])));
- SIMIX_simcall_answer(simcall);
- break;
-
-case SIMCALL_SEM_RELEASE:
- simcall_HANDLER_sem_release(simcall, simgrid::simix::unmarshal<smx_sem_t>(simcall->args[0]));
- SIMIX_simcall_answer(simcall);
- break;
-
-case SIMCALL_SEM_WOULD_BLOCK:
- simgrid::simix::marshal<int>(simcall->result, simcall_HANDLER_sem_would_block(simcall, simgrid::simix::unmarshal<smx_sem_t>(simcall->args[0])));
- SIMIX_simcall_answer(simcall);
- break;
-
case SIMCALL_SEM_ACQUIRE:
simcall_HANDLER_sem_acquire(simcall, simgrid::simix::unmarshal<smx_sem_t>(simcall->args[0]));
break;
simcall_HANDLER_sem_acquire_timeout(simcall, simgrid::simix::unmarshal<smx_sem_t>(simcall->args[0]), simgrid::simix::unmarshal<double>(simcall->args[1]));
break;
-case SIMCALL_SEM_GET_CAPACITY:
- simgrid::simix::marshal<int>(simcall->result, simcall_HANDLER_sem_get_capacity(simcall, simgrid::simix::unmarshal<smx_sem_t>(simcall->args[0])));
- SIMIX_simcall_answer(simcall);
- break;
-
case SIMCALL_FILE_READ:
simcall_HANDLER_file_read(simcall, simgrid::simix::unmarshal<surf_file_t>(simcall->args[0]),
simgrid::simix::unmarshal<sg_size_t>(simcall->args[1]));
void cond_wait_timeout(smx_cond_t cond, smx_mutex_t mutex, double timeout) [[block]];
void cond_broadcast(smx_cond_t cond) [[nohandler]];
-smx_sem_t sem_init(unsigned int capacity) [[nohandler]];
-void sem_release(smx_sem_t sem);
-int sem_would_block(smx_sem_t sem);
void sem_acquire(smx_sem_t sem) [[block]];
void sem_acquire_timeout(smx_sem_t sem, double timeout) [[block]];
-int sem_get_capacity(smx_sem_t sem);
sg_size_t file_read(surf_file_t fd, sg_size_t size) [[block]];
sg_size_t file_write(surf_file_t fd, sg_size_t size) [[block]];
XBT_OUT();
}
-void simcall_HANDLER_sem_release(smx_simcall_t simcall, smx_sem_t sem){
- SIMIX_sem_release(sem);
-}
/** @brief release the semaphore
*
* Unlock a process waiting on the semaphore.
return (sem->value <= 0);
}
-int simcall_HANDLER_sem_get_capacity(smx_simcall_t simcall, smx_sem_t sem){
- return SIMIX_sem_get_capacity(sem);
-}
/** @brief Returns the current capacity of the semaphore */
int SIMIX_sem_get_capacity(smx_sem_t sem)
{
_SIMIX_sem_wait(sem, timeout, simcall->issuer, simcall);
XBT_OUT();
}
-int simcall_HANDLER_sem_would_block(smx_simcall_t simcall, smx_sem_t sem) {
- return SIMIX_sem_would_block(sem);
-}