SimGrid  3.13
Versatile Simulation of Distributed Systems
smx_synchro_private.h File Reference
#include "xbt/base.h"
#include "xbt/swag.h"
#include "xbt/xbt_os_thread.h"

Classes

struct  s_smx_mutex
 
struct  s_smx_cond
 
struct  s_smx_sem
 

Typedefs

typedef struct s_smx_mutex s_smx_mutex_t
 
typedef struct s_smx_cond s_smx_cond_t
 
typedef struct s_smx_sem s_smx_sem_t
 

Functions

XBT_PRIVATE void SIMIX_post_synchro (smx_synchro_t synchro)
 
XBT_PRIVATE void SIMIX_synchro_stop_waiting (smx_process_t process, smx_simcall_t simcall)
 
XBT_PRIVATE void SIMIX_synchro_destroy (smx_synchro_t synchro)
 
XBT_PRIVATE smx_mutex_t SIMIX_mutex_init (void)
 Initialize a mutex. More...
 
XBT_PRIVATE int SIMIX_mutex_trylock (smx_mutex_t mutex, smx_process_t issuer)
 Tries to lock a mutex. More...
 
XBT_PRIVATE void SIMIX_mutex_unlock (smx_mutex_t mutex, smx_process_t issuer)
 Unlocks a mutex. More...
 
XBT_PRIVATE smx_cond_t SIMIX_cond_init (void)
 Initialize a condition. More...
 
XBT_PRIVATE void SIMIX_cond_broadcast (smx_cond_t cond)
 Broadcasts a condition. More...
 
XBT_PRIVATE void SIMIX_cond_signal (smx_cond_t cond)
 Signalizes a condition. More...
 
XBT_PRIVATE XBT_PRIVATE smx_sem_t SIMIX_sem_init (unsigned int value)
 Initialize a semaphore. More...
 
XBT_PRIVATE void SIMIX_sem_release (smx_sem_t sem)
 release the semaphore More...
 
XBT_PRIVATE int SIMIX_sem_would_block (smx_sem_t sem)
 Returns true if acquiring this semaphore would block. More...
 
XBT_PRIVATE int SIMIX_sem_get_capacity (smx_sem_t sem)
 Returns the current capacity of the semaphore. More...
 

Typedef Documentation

typedef struct s_smx_mutex s_smx_mutex_t
typedef struct s_smx_cond s_smx_cond_t
typedef struct s_smx_sem s_smx_sem_t

Function Documentation

XBT_PRIVATE void SIMIX_post_synchro ( smx_synchro_t  synchro)
XBT_PRIVATE void SIMIX_synchro_stop_waiting ( smx_process_t  process,
smx_simcall_t  simcall 
)
XBT_PRIVATE void SIMIX_synchro_destroy ( smx_synchro_t  synchro)
XBT_PRIVATE smx_mutex_t SIMIX_mutex_init ( void  )

Initialize a mutex.

Allocs and creates the data for the mutex.

Returns
A mutex
XBT_PRIVATE int SIMIX_mutex_trylock ( smx_mutex_t  mutex,
smx_process_t  issuer 
)

Tries to lock a mutex.

Tries to lock a mutex, return 1 if the mutex is unlocked, else 0. This function does not block and wait for the mutex to be unlocked.

Parameters
mutexThe mutex
issuerThe process that tries to acquire the mutex
Returns
1 - mutex free, 0 - mutex used
XBT_PRIVATE void SIMIX_mutex_unlock ( smx_mutex_t  mutex,
smx_process_t  issuer 
)

Unlocks a mutex.

Unlocks the mutex and gives it to a process waiting for it. If the unlocker is not the owner of the mutex nothing happens. If there are no process waiting, it sets the mutex as free.

Parameters
mutexThe mutex
issuerThe process trying to unlock the mutex
XBT_PRIVATE smx_cond_t SIMIX_cond_init ( void  )

Initialize a condition.

Allocates and creates the data for the condition. It have to be called before the use of the condition.

Returns
A condition
XBT_PRIVATE void SIMIX_cond_broadcast ( smx_cond_t  cond)

Broadcasts a condition.

Signal ALL processes waiting on a condition. If there are no process waiting, no action is done.

Parameters
condA condition
XBT_PRIVATE void SIMIX_cond_signal ( smx_cond_t  cond)

Signalizes a condition.

Signalizes a condition and wakes up a sleeping process. If there are no process sleeping, no action is done.

Parameters
condA condition
XBT_PRIVATE XBT_PRIVATE smx_sem_t SIMIX_sem_init ( unsigned int  value)

Initialize a semaphore.

XBT_PRIVATE void SIMIX_sem_release ( smx_sem_t  sem)

release the semaphore

Unlock a process waiting on the semaphore. If no one was blocked, the semaphore capacity is increased by 1.

XBT_PRIVATE int SIMIX_sem_would_block ( smx_sem_t  sem)

Returns true if acquiring this semaphore would block.

XBT_PRIVATE int SIMIX_sem_get_capacity ( smx_sem_t  sem)

Returns the current capacity of the semaphore.