SimGrid 3.6.2
Scalable simulation of distributed systems
Functions
MSG Operating System Functions
MSG native

This section describes the functions that can be used by an agent for handling some task. More...

Functions

MSG_error_t MSG_get_errno (void)
 Return the last value returned by a MSG function (except MSG_get_errno...).
MSG_error_t MSG_task_execute (m_task_t task)
 Executes a task and waits for its termination.
MSG_error_t MSG_process_sleep (double nb_sec)
 Sleep for the specified number of seconds.
MSG_error_t MSG_task_get_from_host (m_task_t *task, m_channel_t channel, m_host_t host)
 Listen on channel and waits for receiving a task from host.
MSG_error_t MSG_task_get (m_task_t *task, m_channel_t channel)
 Listen on a channel and wait for receiving a task.
MSG_error_t MSG_task_get_with_timeout (m_task_t *task, m_channel_t channel, double max_duration)
 Listen on a channel and wait for receiving a task with a timeout.
msg_comm_t MSG_task_isend (m_task_t task, const char *alias)
 Sends a task on a mailbox.
msg_comm_t MSG_task_isend_with_matching (m_task_t task, const char *alias, int(*match_fun)(void *, void *), void *match_data)
 Sends a task on a mailbox, with support for matching requests.
void MSG_task_dsend (m_task_t task, const char *alias, void_f_pvoid_t cleanup)
 Sends a task on a mailbox.
msg_comm_t MSG_task_irecv (m_task_t *task, const char *name)
 Starts listening for receiving a task from an asynchronous communication.
int MSG_comm_test (msg_comm_t comm)
 Checks whether a communication is done, and if yes, finalizes it.
int MSG_comm_testany (xbt_dynar_t comms)
 This function checks if a communication is finished.
void MSG_comm_destroy (msg_comm_t comm)
 Destroys a communication.
MSG_error_t MSG_comm_wait (msg_comm_t comm, double timeout)
 Wait for the completion of a communication.
void MSG_comm_waitall (msg_comm_t *comm, int nb_elem, double timeout)
 This function is called by a sender and permit to wait for each communication.
int MSG_comm_waitany (xbt_dynar_t comms)
 This function waits for the first communication finished in a list.
MSG_error_t MSG_comm_get_status (msg_comm_t comm)
 Returns the error (if any) that occured during a finished communication.
MSG_error_t MSG_task_put (m_task_t task, m_host_t dest, m_channel_t channel)
 Put a task on a channel of an host and waits for the end of the transmission.
MSG_error_t MSG_task_put_bounded (m_task_t task, m_host_t dest, m_channel_t channel, double maxrate)
 Does exactly the same as MSG_task_put but with a bounded transmition rate.
MSG_error_t MSG_task_put_with_timeout (m_task_t task, m_host_t dest, m_channel_t channel, double timeout)
int MSG_task_Iprobe (m_channel_t channel)
 Test whether there is a pending communication on a channel.
int MSG_task_probe_from_host (int channel, m_host_t host)
 Return the number of tasks waiting to be received on a channel and sent by host.
int MSG_task_probe_from (m_channel_t channel)
 Test whether there is a pending communication on a channel, and who sent it.
int MSG_host_is_avail (m_host_t h)
 Determine if a host is available.

Detailed Description

This section describes the functions that can be used by an agent for handling some task.


Function Documentation

MSG_error_t MSG_task_execute ( m_task_t  task)

Executes a task and waits for its termination.

This function is used for describing the behavior of an agent. It takes only one parameter.

Parameters:
taska m_task_t to execute on the location on which the agent is running.
Returns:
#MSG_FATAL if task is not properly initialized and MSG_OK otherwise.
MSG_error_t MSG_process_sleep ( double  nb_sec)

Sleep for the specified number of seconds.

Makes the current process sleep until time seconds have elapsed.

Parameters:
nb_seca number of second
MSG_error_t MSG_task_get_from_host ( m_task_t task,
m_channel_t  channel,
m_host_t  host 
)

Listen on channel and waits for receiving a task from host.

It takes three parameters.

Parameters:
taska memory location for storing a m_task_t. It will hold a task when this function will return. Thus task should not be equal to NULL and *task should be equal to NULL. If one of those two condition does not hold, there will be a warning message.
channelthe channel on which the agent should be listening. This value has to be >=0 and < than the maximal number of channels fixed with MSG_set_channel_number().
hostthe host that is to be watched.
Returns:
#MSG_FATAL if task is equal to NULL, #MSG_WARNING if *task is not equal to NULL, and MSG_OK otherwise.
MSG_error_t MSG_task_get ( m_task_t task,
m_channel_t  channel 
)

Listen on a channel and wait for receiving a task.

It takes two parameters.

Parameters:
taska memory location for storing a m_task_t. It will hold a task when this function will return. Thus task should not be equal to NULL and *task should be equal to NULL. If one of those two condition does not hold, there will be a warning message.
channelthe channel on which the agent should be listening. This value has to be >=0 and < than the maximal number of channels fixed with MSG_set_channel_number().
Returns:
#MSG_FATAL if task is equal to NULL, #MSG_WARNING if *task is not equal to NULL, and MSG_OK otherwise.
MSG_error_t MSG_task_get_with_timeout ( m_task_t task,
m_channel_t  channel,
double  max_duration 
)

Listen on a channel and wait for receiving a task with a timeout.

It takes three parameters.

Parameters:
taska memory location for storing a m_task_t. It will hold a task when this function will return. Thus task should not be equal to NULL and *task should be equal to NULL. If one of those two condition does not hold, there will be a warning message.
channelthe channel on which the agent should be listening. This value has to be >=0 and < than the maximal number of channels fixed with MSG_set_channel_number().
max_durationthe maximum time to wait for a task before giving up. In such a case, MSG_TRANSFER_FAILURE will be returned, task will not be modified and will still be equal to NULL when returning.
Returns:
#MSG_FATAL if task is equal to NULL, #MSG_WARNING if *task is not equal to NULL, and MSG_OK otherwise.
msg_comm_t MSG_task_isend ( m_task_t  task,
const char *  alias 
)

Sends a task on a mailbox.

This is a non blocking function: use MSG_comm_wait() or MSG_comm_test() to end the communication.

Parameters:
taska m_task_t to send on another location.
aliasname of the mailbox to sent the task to
Returns:
the msg_comm_t communication created
msg_comm_t MSG_task_isend_with_matching ( m_task_t  task,
const char *  alias,
int(*)(void *, void *)  match_fun,
void *  match_data 
)

Sends a task on a mailbox, with support for matching requests.

This is a non blocking function: use MSG_comm_wait() or MSG_comm_test() to end the communication.

Parameters:
taska m_task_t to send on another location.
aliasname of the mailbox to sent the task to
match_funboolean function taking the #match_data provided by sender (here), and the one of the receiver (if any) and returning whether they match
match_datauser provided data passed to match_fun
Returns:
the msg_comm_t communication created
void MSG_task_dsend ( m_task_t  task,
const char *  alias,
void_f_pvoid_t  cleanup 
)

Sends a task on a mailbox.

This is a non blocking detached send function. Think of it as a best effort send. The communication object will be destroyed by the receiver (if any).

Parameters:
taska m_task_t to send on another location.
aliasname of the mailbox to sent the task to
cleanupa function to destroy the task if the communication fails (if NULL, MSG_task_destroy() will be used by default)
msg_comm_t MSG_task_irecv ( m_task_t task,
const char *  name 
)

Starts listening for receiving a task from an asynchronous communication.

This is a non blocking function: use MSG_comm_wait() or MSG_comm_test() to end the communication.

Parameters:
taska memory location for storing a m_task_t.
nameof the mailbox to receive the task on
Returns:
the msg_comm_t communication created
int MSG_comm_test ( msg_comm_t  comm)

Checks whether a communication is done, and if yes, finalizes it.

Parameters:
commthe communication to test
Returns:
TRUE if the communication is finished (but it may have failed, use MSG_comm_get_status() to know its status) or FALSE if the communication is not finished yet If the status is FALSE, don't forget to use MSG_process_sleep() after the test.
int MSG_comm_testany ( xbt_dynar_t  comms)

This function checks if a communication is finished.

Parameters:
commsa vector of communications
Returns:
the position of the finished communication if any (but it may have failed, use MSG_comm_get_status() to know its status), or -1 if none is finished
void MSG_comm_destroy ( msg_comm_t  comm)

Destroys a communication.

Parameters:
commthe communication to destroy.
MSG_error_t MSG_comm_wait ( msg_comm_t  comm,
double  timeout 
)

Wait for the completion of a communication.

It takes two parameters.

Parameters:
commthe communication to wait.
timeoutWait until the communication terminates or the timeout occurs
Returns:
MSG_error_t
void MSG_comm_waitall ( msg_comm_t comm,
int  nb_elem,
double  timeout 
)

This function is called by a sender and permit to wait for each communication.

Parameters:
comma vector of communication
nb_elemis the size of the comm vector
timeoutfor each call of MSG_comm_wait
int MSG_comm_waitany ( xbt_dynar_t  comms)

This function waits for the first communication finished in a list.

Parameters:
commsa vector of communications
Returns:
the position of the first finished communication (but it may have failed, use MSG_comm_get_status() to know its status)
MSG_error_t MSG_comm_get_status ( msg_comm_t  comm)

Returns the error (if any) that occured during a finished communication.

Parameters:
comma finished communication
Returns:
the status of the communication, or MSG_OK if no error occured during the communication
MSG_error_t MSG_task_put ( m_task_t  task,
m_host_t  dest,
m_channel_t  channel 
)

Put a task on a channel of an host and waits for the end of the transmission.

This function is used for describing the behavior of an agent. It takes three parameter.

Parameters:
taska m_task_t to send on another location. This task will not be usable anymore when the function will return. There is no automatic task duplication and you have to save your parameters before calling this function. Tasks are unique and once it has been sent to another location, you should not access it anymore. You do not need to call MSG_task_destroy() but to avoid using, as an effect of inattention, this task anymore, you definitely should renitialize it with MSG_TASK_UNINITIALIZED. Note that this task can be transfered iff it has been correctly created with MSG_task_create().
destthe destination of the message
channelthe channel on which the agent should put this task. This value has to be >=0 and < than the maximal number of channels fixed with MSG_set_channel_number().
Returns:
#MSG_FATAL if task is not properly initialized and MSG_OK otherwise. Returns MSG_HOST_FAILURE if the host on which this function was called was shut down. Returns MSG_TRANSFER_FAILURE if the transfer could not be properly done (network failure, dest failure)
MSG_error_t MSG_task_put_bounded ( m_task_t  task,
m_host_t  dest,
m_channel_t  channel,
double  maxrate 
)

Does exactly the same as MSG_task_put but with a bounded transmition rate.

See also:
MSG_task_put
MSG_error_t MSG_task_put_with_timeout ( m_task_t  task,
m_host_t  dest,
m_channel_t  channel,
double  timeout 
)

\ host (with a timeout on the waiting of the destination host) and waits for the end of the transmission.

This function is used for describing the behavior of an agent. It takes four parameter.

Parameters:
taska m_task_t to send on another location. This task will not be usable anymore when the function will return. There is no automatic task duplication and you have to save your parameters before calling this function. Tasks are unique and once it has been sent to another location, you should not access it anymore. You do not need to call MSG_task_destroy() but to avoid using, as an effect of inattention, this task anymore, you definitely should renitialize it with MSG_TASK_UNINITIALIZED. Note that this task can be transfered iff it has been correctly created with MSG_task_create().
destthe destination of the message
channelthe channel on which the agent should put this task. This value has to be >=0 and < than the maximal number of channels fixed with MSG_set_channel_number().
timeoutthe maximum time to wait for a task before giving up. In such a case, MSG_TRANSFER_FAILURE will be returned, task will not be modified
Returns:
#MSG_FATAL if task is not properly initialized and MSG_OK otherwise. Returns MSG_HOST_FAILURE if the host on which this function was called was shut down. Returns MSG_TRANSFER_FAILURE if the transfer could not be properly done (network failure, dest failure, timeout...)
int MSG_task_Iprobe ( m_channel_t  channel)

Test whether there is a pending communication on a channel.

It takes one parameter.

Parameters:
channelthe channel on which the agent should be listening. This value has to be >=0 and < than the maximal number of channels fixed with MSG_set_channel_number().
Returns:
1 if there is a pending communication and 0 otherwise
int MSG_task_probe_from_host ( int  channel,
m_host_t  host 
)

Return the number of tasks waiting to be received on a channel and sent by host.

It takes two parameters.

Parameters:
channelthe channel on which the agent should be listening. This value has to be >=0 and < than the maximal number of channels fixed with MSG_set_channel_number().
hostthe host that is to be watched.
Returns:
the number of tasks waiting to be received on channel and sent by host.
int MSG_task_probe_from ( m_channel_t  channel)

Test whether there is a pending communication on a channel, and who sent it.

It takes one parameter.

Parameters:
channelthe channel on which the agent should be listening. This value has to be >=0 and < than the maximal number of channels fixed with MSG_set_channel_number().
Returns:
-1 if there is no pending communication and the PID of the process who sent it otherwise
int MSG_host_is_avail ( m_host_t  h)

Determine if a host is available.

Parameters:
hhost to test


Back to the main Simgrid Documentation page The version of Simgrid documented here is v3.6.2.
Documentation of other versions can be found in their respective archive files (directory doc/html).
Generated for SimGridAPI by doxygen