SimGrid
3.18
Versatile Simulation of Distributed Systems
|
This section describes the process structure of MSG (msg_process_t) and the functions for managing it.
Processes (msg_process_t) are independent agents that can do stuff on their own.
They are in charge of executing your code interacting with the simulated world. A process may be defined as a code with some private data. Processes must be located on hosts (msg_host_t), and they exchange data by sending tasks (msg_task_t) that are similar to envelops containing data.
Typedefs | |
typedef s4u_Actor * | msg_process_t |
Process datatype. More... | |
Functions | |
msg_process_t | MSG_process_create (const char *name, xbt_main_func_t code, void *data, msg_host_t host) |
Creates and runs a new msg_process_t. More... | |
msg_process_t | MSG_process_create_with_arguments (const char *name, xbt_main_func_t code, void *data, msg_host_t host, int argc, char **argv) |
Creates and runs a new msg_process_t. More... | |
msg_process_t | MSG_process_create_with_environment (const char *name, xbt_main_func_t code, void *data, msg_host_t host, int argc, char **argv, xbt_dict_t properties) |
Creates and runs a new msg_process_t. More... | |
void | MSG_process_kill (msg_process_t process) |
msg_error_t | MSG_process_migrate (msg_process_t process, msg_host_t host) |
Migrates a process to another location. More... | |
void * | MSG_process_get_data (msg_process_t process) |
Returns the user data of a process. More... | |
msg_error_t | MSG_process_set_data (msg_process_t process, void *data) |
Sets the user data of a process. More... | |
void | MSG_process_set_data_cleanup (void_f_pvoid_t data_cleanup) |
Sets a cleanup function to be called to free the userdata of a process when a process is destroyed. More... | |
msg_host_t | MSG_process_get_host (msg_process_t process) |
Return the location on which a process is running. More... | |
msg_process_t | MSG_process_from_PID (int PID) |
Return a msg_process_t given its PID. More... | |
msg_error_t | MSG_process_set_kill_time (msg_process_t process, double kill_time) |
Set the kill time of a process. More... | |
int | MSG_process_get_PID (msg_process_t process) |
Returns the process ID of process. More... | |
int | MSG_process_get_PPID (msg_process_t process) |
Returns the process ID of the parent of process. More... | |
const char * | MSG_process_get_name (msg_process_t process) |
Return the name of a process. More... | |
const char * | MSG_process_get_property_value (msg_process_t process, const char *name) |
Returns the value of a given process property. More... | |
xbt_dict_t | MSG_process_get_properties (msg_process_t process) |
Return the list of properties. More... | |
int | MSG_process_self_PID () |
Return the PID of the current process. More... | |
int | MSG_process_self_PPID () |
Return the PPID of the current process. More... | |
const char * | MSG_process_self_name () |
Return the name of the current process. More... | |
msg_process_t | MSG_process_self () |
Return the current process. More... | |
msg_error_t | MSG_process_suspend (msg_process_t process) |
Suspend the process. More... | |
msg_error_t | MSG_process_resume (msg_process_t process) |
Resume a suspended process. More... | |
int | MSG_process_is_suspended (msg_process_t process) |
Returns true if the process is suspended . More... | |
void | MSG_process_on_exit (int_f_pvoid_pvoid_t fun, void *data) |
Add a function to the list of "on_exit" functions for the current process. More... | |
void | MSG_process_auto_restart_set (msg_process_t process, int auto_restart) |
Sets the "auto-restart" flag of the process. More... | |
msg_process_t | MSG_process_restart (msg_process_t process) |
Restarts a process from the beginning. More... | |
void | MSG_process_daemonize (msg_process_t process) |
This process will be terminated automatically when the last non-daemon process finishes. More... | |
void | MSG_process_ref (msg_process_t process) |
Take an extra reference on that process to prevent it to be garbage-collected. More... | |
void | MSG_process_unref (msg_process_t process) |
Release a reference on that process so that it can get be garbage-collected. More... | |
typedef s4u_Actor* msg_process_t |
Process datatype.
A process may be defined as a code, with some private data, executing in a location.
You should not access directly to the fields of the pointed structure, but always use the provided API to interact with processes.
msg_process_t MSG_process_create | ( | const char * | name, |
xbt_main_func_t | code, | ||
void * | data, | ||
msg_host_t | host | ||
) |
Creates and runs a new msg_process_t.
Does exactly the same as MSG_process_create_with_arguments but without providing standard arguments (argc, argv, start_time, kill_time).
msg_process_t MSG_process_create_with_arguments | ( | const char * | name, |
xbt_main_func_t | code, | ||
void * | data, | ||
msg_host_t | host, | ||
int | argc, | ||
char ** | argv | ||
) |
Creates and runs a new msg_process_t.
A constructor for msg_process_t taking four arguments and returning the corresponding object. The structure (and the corresponding thread) is created, and put in the list of ready process.
name | a name for the object. It is for user-level information and can be nullptr. |
code | is a function describing the behavior of the process. It should then only use functions described in Process Management Functions (to create a new msg_process_t for example), in Host Management Functions (only the read-only functions i.e. whose name contains the word get), in Task Management Functions (to create or destroy some msg_task_t for example) and in Task Actions (to handle file transfers and task processing). |
data | a pointer to any data one may want to attach to the new object. It is for user-level information and can be nullptr. It can be retrieved with the function MSG_process_get_data. |
host | the location where the new process is executed. |
argc | first argument passed to code |
argv | second argument passed to code |
msg_process_t MSG_process_create_with_environment | ( | const char * | name, |
xbt_main_func_t | code, | ||
void * | data, | ||
msg_host_t | host, | ||
int | argc, | ||
char ** | argv, | ||
xbt_dict_t | properties | ||
) |
Creates and runs a new msg_process_t.
A constructor for msg_process_t taking four arguments and returning the corresponding object. The structure (and the corresponding thread) is created, and put in the list of ready process.
name | a name for the object. It is for user-level information and can be nullptr. |
code | is a function describing the behavior of the process. It should then only use functions described in Process Management Functions (to create a new msg_process_t for example), in Host Management Functions (only the read-only functions i.e. whose name contains the word get), in Task Management Functions (to create or destroy some msg_task_t for example) and in Task Actions (to handle file transfers and task processing). |
data | a pointer to any data one may want to attach to the new object. It is for user-level information and can be nullptr. It can be retrieved with the function MSG_process_get_data. |
host | the location where the new process is executed. |
argc | first argument passed to code |
argv | second argument passed to code. WARNING, these strings are freed by the SimGrid kernel when the process exits, so they cannot be static nor shared between several processes. |
properties | list a properties defined for this process |
void MSG_process_kill | ( | msg_process_t | process | ) |
process | poor victim |
This function simply kills a process... scary isn't it ? :)
msg_error_t MSG_process_migrate | ( | msg_process_t | process, |
msg_host_t | host | ||
) |
Migrates a process to another location.
This function checks whether process and host are valid pointers and change the value of the msg_host_t on which process is running.
void* MSG_process_get_data | ( | msg_process_t | process | ) |
Returns the user data of a process.
This function checks whether process is a valid pointer and returns the user data associated to this process.
msg_error_t MSG_process_set_data | ( | msg_process_t | process, |
void * | data | ||
) |
Sets the user data of a process.
This function checks whether process is a valid pointer and sets the user data associated to this process.
void MSG_process_set_data_cleanup | ( | void_f_pvoid_t | data_cleanup | ) |
Sets a cleanup function to be called to free the userdata of a process when a process is destroyed.
data_cleanup | a cleanup function for the userdata of a process, or nullptr to call no function |
msg_host_t MSG_process_get_host | ( | msg_process_t | process | ) |
Return the location on which a process is running.
process | a process (nullptr means the current one) |
msg_process_t MSG_process_from_PID | ( | int | PID | ) |
Return a msg_process_t given its PID.
This function search in the list of all the created msg_process_t for a msg_process_t whose PID is equal to PID. If no host is found, nullptr
is returned. Note that the PID are uniq in the whole simulation, not only on a given host.
msg_error_t MSG_process_set_kill_time | ( | msg_process_t | process, |
double | kill_time | ||
) |
Set the kill time of a process.
process | a process |
kill_time | the time when the process is killed. |
int MSG_process_get_PID | ( | msg_process_t | process | ) |
Returns the process ID of process.
This function checks whether process is a valid pointer and return its PID (or 0 in case of problem).
int MSG_process_get_PPID | ( | msg_process_t | process | ) |
Returns the process ID of the parent of process.
This function checks whether process is a valid pointer and return its PID. Returns -1 if the process has not been created by any other process.
const char* MSG_process_get_name | ( | msg_process_t | process | ) |
Return the name of a process.
This function checks whether process is a valid pointer and return its name.
const char* MSG_process_get_property_value | ( | msg_process_t | process, |
const char * | name | ||
) |
Returns the value of a given process property.
process | a process |
name | a property name |
xbt_dict_t MSG_process_get_properties | ( | msg_process_t | process | ) |
Return the list of properties.
This function returns all the parameters associated with a process
int MSG_process_self_PID | ( | ) |
Return the PID of the current process.
This function returns the PID of the currently running msg_process_t.
int MSG_process_self_PPID | ( | ) |
Return the PPID of the current process.
This function returns the PID of the parent of the currently running msg_process_t.
const char* MSG_process_self_name | ( | ) |
Return the name of the current process.
msg_process_t MSG_process_self | ( | ) |
Return the current process.
This function returns the currently running msg_process_t.
msg_error_t MSG_process_suspend | ( | msg_process_t | process | ) |
Suspend the process.
This function suspends the process by suspending the task on which it was waiting for the completion.
msg_error_t MSG_process_resume | ( | msg_process_t | process | ) |
Resume a suspended process.
This function resumes a suspended process by resuming the task on which it was waiting for the completion.
int MSG_process_is_suspended | ( | msg_process_t | process | ) |
Returns true if the process is suspended .
This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion.
void MSG_process_on_exit | ( | int_f_pvoid_pvoid_t | fun, |
void * | data | ||
) |
Add a function to the list of "on_exit" functions for the current process.
The on_exit functions are the functions executed when your process is killed. You should use them to free the data used by your process.
void MSG_process_auto_restart_set | ( | msg_process_t | process, |
int | auto_restart | ||
) |
Sets the "auto-restart" flag of the process.
If the flag is set to 1, the process will be automatically restarted when its host comes back up.
msg_process_t MSG_process_restart | ( | msg_process_t | process | ) |
Restarts a process from the beginning.
void MSG_process_daemonize | ( | msg_process_t | process | ) |
This process will be terminated automatically when the last non-daemon process finishes.
void MSG_process_ref | ( | msg_process_t | process | ) |
Take an extra reference on that process to prevent it to be garbage-collected.
void MSG_process_unref | ( | msg_process_t | process | ) |
Release a reference on that process so that it can get be garbage-collected.