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)
 Send a task on a channel.
msg_comm_t MSG_task_irecv (m_task_t *task, const char *alias)
 Listen on a channel for receiving a task from an asynchronous communication.
int MSG_comm_test (msg_comm_t comm)
 Test the status of a communication.
void MSG_comm_destroy (msg_comm_t comm)
 After received TRUE to MSG_comm_test(), the communication must be destroyed.
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 wait for the first completed 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.
MSG_error_t MSG_channel_select_from (m_channel_t channel, double timeout, int *PID)
 Wait for at most max_duration second for a task reception on channel.
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:
task a 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_sec a 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:
task a 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.
channel the 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().
host the 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:
task a 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.
channel the 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:
task a 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.
channel the 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_duration the 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 
)

Send a task on a channel.

This function takes two parameter.

Parameters:
task a m_task_t to send on another location.
alias the 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:
the msg_comm_t communication.
msg_comm_t MSG_task_irecv ( m_task_t task,
const char *  alias 
)

Listen on a channel for receiving a task from an asynchronous communication.

It takes two parameters.

Parameters:
task a memory location for storing a m_task_t.
alias the 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:
the msg_comm_t communication.
int MSG_comm_test ( msg_comm_t  comm  ) 

Test the status of a communication.

It takes one parameter.

Parameters:
comm the communication to test.
Returns:
the status of the communication: TRUE : the communication is completed FALSE: the communication is incompleted If the status is FALSE, don't forget to use MSG_process_sleep() after the test.
void MSG_comm_destroy ( msg_comm_t  comm  ) 

After received TRUE to MSG_comm_test(), the communication must be destroyed.

It takes one parameter.

Parameters:
comm the 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:
comm the communication to wait.
timeout Wait 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.

It takes three parameters.

Parameters:
comm a vector of communication
nb_elem is the size of the comm vector
timeout for each call of MSG_comm_wait
int MSG_comm_waitany ( xbt_dynar_t  comms  ) 

This function wait for the first completed communication.

It takes on parameter.

Parameters:
comms a vector of communication
Returns:
the position of the completed communication from the xbt_dynar_t.
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:
task a 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().
dest the destination of the message
channel the 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:
task a 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().
dest the destination of the message
channel the 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().
timeout the 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:
channel the 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:
channel the 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().
host the 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:
channel the 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
MSG_error_t MSG_channel_select_from ( m_channel_t  channel,
double  timeout,
int *  PID 
)

Wait for at most max_duration second for a task reception on channel.

PID is updated with the PID of the first process that triggered this event if any.

It takes three parameters:

Parameters:
channel the 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().
PID a memory location for storing an int.
timeout the maximum time to wait for a task before giving up. In the case of a reception, *PID will be updated with the PID of the first process to send a task.
Returns:
MSG_HOST_FAILURE if the host is shut down in the meantime and MSG_OK otherwise.
int MSG_host_is_avail ( m_host_t  h  ) 

Determine if a host is available.

Parameters:
h host to test


Back to the main Simgrid Documentation page Generated for SimGridAPI by doxygen