X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f70ee620c8df5cdf749f4dfbc9777359cd3cb12a..b2f752feb35d35e191205da26b5522038c04c2b6:/src/simix/libsmx.c diff --git a/src/simix/libsmx.c b/src/simix/libsmx.c index 5bbfc58106..25285dc873 100644 --- a/src/simix/libsmx.c +++ b/src/simix/libsmx.c @@ -5,10 +5,11 @@ /* */ /* This is somehow the "libc" of SimGrid */ -/* Copyright (c) 2010-2014. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2010-2015. The SimGrid Team. + * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it - * under the terms of the license (GNU LGPL) which comes with this package. */ + * under the terms of the license (GNU LGPL) which comes with this package. */ #include "mc/mc_replay.h" #include "smx_private.h" @@ -228,21 +229,20 @@ double simcall_host_get_wattmax_at(msg_host_t host, int pstate){ /** - * \ingroup simix_host_management + * \ingroup simix_process_management * \brief Creates a synchro that executes some computation of an host. * * This function creates a SURF action and allocates the data necessary * to create the SIMIX synchro. It can raise a host_error exception if the host crashed. * * \param name Name of the execution synchro to create - * \param host SIMIX host where the synchro will be executed * \param flops_amount amount Computation amount (in flops) * \param priority computation priority * \param bound * \param affinity_mask * \return A new SIMIX execution synchronization */ -smx_synchro_t simcall_host_execute(const char *name, sg_host_t host, +smx_synchro_t simcall_process_execute(const char *name, double flops_amount, double priority, double bound, unsigned long affinity_mask) { @@ -250,11 +250,11 @@ smx_synchro_t simcall_host_execute(const char *name, sg_host_t host, xbt_assert(isfinite(flops_amount), "flops_amount is not finite!"); xbt_assert(isfinite(priority), "priority is not finite!"); - return simcall_BODY_host_execute(name, host, flops_amount, priority, bound, affinity_mask); + return simcall_BODY_process_execute(name, flops_amount, priority, bound, affinity_mask); } /** - * \ingroup simix_host_management + * \ingroup simix_process_management * \brief Creates a synchro that may involve parallel computation on * several hosts and communication between them. * @@ -268,7 +268,7 @@ smx_synchro_t simcall_host_execute(const char *name, sg_host_t host, * \param rate the SURF action rate * \return A new SIMIX execution synchronization */ -smx_synchro_t simcall_host_parallel_execute(const char *name, +smx_synchro_t simcall_process_parallel_execute(const char *name, int host_nb, sg_host_t *host_list, double *flops_amount, @@ -289,7 +289,7 @@ smx_synchro_t simcall_host_parallel_execute(const char *name, xbt_assert(isfinite(amount), "amount is not finite!"); xbt_assert(isfinite(rate), "rate is not finite!"); - return simcall_BODY_host_parallel_execute(name, host_nb, host_list, + return simcall_BODY_process_parallel_execute(name, host_nb, host_list, flops_amount, bytes_amount, amount, rate); @@ -297,84 +297,84 @@ smx_synchro_t simcall_host_parallel_execute(const char *name, } /** - * \ingroup simix_host_management + * \ingroup simix_process_management * \brief Destroys an execution synchro. * * Destroys a synchro, freeing its memory. This function cannot be called if there are a conditional waiting for it. * \param execution The execution synchro to destroy */ -void simcall_host_execution_destroy(smx_synchro_t execution) +void simcall_process_execution_destroy(smx_synchro_t execution) { - simcall_BODY_host_execution_destroy(execution); + simcall_BODY_process_execution_destroy(execution); } /** - * \ingroup simix_host_management + * \ingroup simix_process_management * \brief Cancels an execution synchro. * * This functions stops the execution. It calls a surf function. * \param execution The execution synchro to cancel */ -void simcall_host_execution_cancel(smx_synchro_t execution) +void simcall_process_execution_cancel(smx_synchro_t execution) { - simcall_BODY_host_execution_cancel(execution); + simcall_BODY_process_execution_cancel(execution); } /** - * \ingroup simix_host_management + * \ingroup simix_process_management * \brief Returns how much of an execution synchro remains to be done. * * \param execution The execution synchro * \return The remaining amount */ -double simcall_host_execution_get_remains(smx_synchro_t execution) +double simcall_process_execution_get_remains(smx_synchro_t execution) { - return simcall_BODY_host_execution_get_remains(execution); + return simcall_BODY_process_execution_get_remains(execution); } /** - * \ingroup simix_host_management + * \ingroup simix_process_management * \brief Returns the state of an execution synchro. * * \param execution The execution synchro * \return The state */ -e_smx_state_t simcall_host_execution_get_state(smx_synchro_t execution) +e_smx_state_t simcall_process_execution_get_state(smx_synchro_t execution) { - return simcall_BODY_host_execution_get_state(execution); + return simcall_BODY_process_execution_get_state(execution); } /** - * \ingroup simix_host_management + * \ingroup simix_process_management * \brief Changes the priority of an execution synchro. * * This functions changes the priority only. It calls a surf function. * \param execution The execution synchro * \param priority The new priority */ -void simcall_host_execution_set_priority(smx_synchro_t execution, double priority) +void simcall_process_execution_set_priority(smx_synchro_t execution, double priority) { /* checking for infinite values */ xbt_assert(isfinite(priority), "priority is not finite!"); - simcall_BODY_host_execution_set_priority(execution, priority); + simcall_BODY_process_execution_set_priority(execution, priority); } /** - * \ingroup simix_host_management + * \ingroup simix_process_management * \brief Changes the capping (the maximum CPU utilization) of an execution synchro. * * This functions changes the capping only. It calls a surf function. * \param execution The execution synchro * \param bound The new bound */ -void simcall_host_execution_set_bound(smx_synchro_t execution, double bound) +void simcall_process_execution_set_bound(smx_synchro_t execution, double bound) { - simcall_BODY_host_execution_set_bound(execution, bound); + simcall_BODY_process_execution_set_bound(execution, bound); } /** - * \ingroup simix_host_management + * \ingroup simix_process_management * \brief Changes the CPU affinity of an execution synchro. * * This functions changes the CPU affinity of an execution synchro. See taskset(1) on Linux. @@ -382,9 +382,9 @@ void simcall_host_execution_set_bound(smx_synchro_t execution, double bound) * \param host Host * \param mask Affinity mask */ -void simcall_host_execution_set_affinity(smx_synchro_t execution, sg_host_t host, unsigned long mask) +void simcall_process_execution_set_affinity(smx_synchro_t execution, sg_host_t host, unsigned long mask) { - simcall_BODY_host_execution_set_affinity(execution, host, mask); + simcall_BODY_process_execution_set_affinity(execution, host, mask); } /** @@ -393,9 +393,9 @@ void simcall_host_execution_set_affinity(smx_synchro_t execution, sg_host_t host * * \param execution The execution synchro */ -e_smx_state_t simcall_host_execution_wait(smx_synchro_t execution) +e_smx_state_t simcall_process_execution_wait(smx_synchro_t execution) { - return simcall_BODY_host_execution_wait(execution); + return simcall_BODY_process_execution_wait(execution); } @@ -570,7 +570,6 @@ void simcall_vm_migratefrom_resumeto(sg_host_t vm, sg_host_t src_pm, sg_host_t d * * The structure and the corresponding thread are created and put in the list of ready processes. * - * \param process the process created will be stored in this pointer * \param name a name for the process. It is for user-level information and can be NULL. * \param code the main function of the process * \param data a pointer to any data one may want to attach to the new object. It is for user-level information and can be NULL. @@ -582,7 +581,7 @@ void simcall_vm_migratefrom_resumeto(sg_host_t vm, sg_host_t src_pm, sg_host_t d * \param properties the properties of the process * \param auto_restart either it is autorestarting or not. */ -void simcall_process_create(smx_process_t *process, const char *name, +smx_process_t simcall_process_create(const char *name, xbt_main_func_t code, void *data, const char *hostname, @@ -591,7 +590,7 @@ void simcall_process_create(smx_process_t *process, const char *name, xbt_dict_t properties, int auto_restart) { - simcall_BODY_process_create(process, name, code, data, hostname, + return (smx_process_t) simcall_BODY_process_create(name, code, data, hostname, kill_time, argc, argv, properties, auto_restart); } @@ -637,9 +636,9 @@ void simcall_process_cleanup(smx_process_t process) * \param process the process to migrate * \param dest name of the new host */ -void simcall_process_change_host(smx_process_t process, sg_host_t dest) +void simcall_process_set_host(smx_process_t process, sg_host_t dest) { - simcall_BODY_process_change_host(process, dest); + simcall_BODY_process_set_host(process, dest); } void simcall_process_join(smx_process_t process, double timeout) @@ -758,8 +757,6 @@ void simcall_process_set_data(smx_process_t process, void *data) /** * \ingroup simix_process_management * \brief Set the kill time of a process. - * \param process a process - * \param kill_time a double */ void simcall_process_set_kill_time(smx_process_t process, double kill_time) { @@ -772,6 +769,13 @@ void simcall_process_set_kill_time(smx_process_t process, double kill_time) } } } +/** + * \ingroup simix_process_management + * \brief Get the kill time of a process (or 0 if unset). + */ +double simcall_process_get_kill_time(smx_process_t process) { + return SIMIX_timer_get_date(process->kill_timer); +} /** * \ingroup simix_process_management @@ -946,7 +950,7 @@ smx_process_t simcall_rdv_get_receiver(smx_rdv_t rdv) /** * \ingroup simix_comm_management */ -void simcall_comm_send(smx_process_t src, smx_rdv_t rdv, double task_size, double rate, +void simcall_comm_send(smx_process_t sender, smx_rdv_t rdv, double task_size, double rate, void *src_buff, size_t src_buff_size, int (*match_fun)(void *, void *, smx_synchro_t), void (*copy_data_fun)(smx_synchro_t, void*, size_t), void *data, @@ -962,13 +966,13 @@ void simcall_comm_send(smx_process_t src, smx_rdv_t rdv, double task_size, doubl if (MC_is_active() || MC_record_replay_is_active()) { /* the model-checker wants two separate simcalls */ smx_synchro_t comm = NULL; /* MC needs the comm to be set to NULL during the simcall */ - comm = simcall_comm_isend(src, rdv, task_size, rate, + comm = simcall_comm_isend(sender, rdv, task_size, rate, src_buff, src_buff_size, match_fun, NULL, copy_data_fun, data, 0); simcall_comm_wait(comm, timeout); comm = NULL; } else { - simcall_BODY_comm_send(src, rdv, task_size, rate, src_buff, src_buff_size, + simcall_BODY_comm_send(sender, rdv, task_size, rate, src_buff, src_buff_size, match_fun, copy_data_fun, data, timeout); } } @@ -976,7 +980,7 @@ void simcall_comm_send(smx_process_t src, smx_rdv_t rdv, double task_size, doubl /** * \ingroup simix_comm_management */ -smx_synchro_t simcall_comm_isend(smx_process_t src, smx_rdv_t rdv, double task_size, double rate, +smx_synchro_t simcall_comm_isend(smx_process_t sender, smx_rdv_t rdv, double task_size, double rate, void *src_buff, size_t src_buff_size, int (*match_fun)(void *, void *, smx_synchro_t), void (*clean_fun)(void *), @@ -990,7 +994,7 @@ smx_synchro_t simcall_comm_isend(smx_process_t src, smx_rdv_t rdv, double task_s xbt_assert(rdv, "No rendez-vous point defined for isend"); - return simcall_BODY_comm_isend(src, rdv, task_size, rate, src_buff, + return simcall_BODY_comm_isend(sender, rdv, task_size, rate, src_buff, src_buff_size, match_fun, clean_fun, copy_data_fun, data, detached); } @@ -998,7 +1002,7 @@ smx_synchro_t simcall_comm_isend(smx_process_t src, smx_rdv_t rdv, double task_s /** * \ingroup simix_comm_management */ -void simcall_comm_recv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size, +void simcall_comm_recv(smx_process_t receiver, smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size, int (*match_fun)(void *, void *, smx_synchro_t), void (*copy_data_fun)(smx_synchro_t, void*, size_t), void *data, double timeout, double rate) @@ -1009,27 +1013,27 @@ void simcall_comm_recv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size, if (MC_is_active() || MC_record_replay_is_active()) { /* the model-checker wants two separate simcalls */ smx_synchro_t comm = NULL; /* MC needs the comm to be set to NULL during the simcall */ - comm = simcall_comm_irecv(rdv, dst_buff, dst_buff_size, + comm = simcall_comm_irecv(receiver, rdv, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, rate); simcall_comm_wait(comm, timeout); comm = NULL; } else { - simcall_BODY_comm_recv(rdv, dst_buff, dst_buff_size, + simcall_BODY_comm_recv(receiver, rdv, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, timeout, rate); } } /** * \ingroup simix_comm_management */ -smx_synchro_t simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t *dst_buff_size, +smx_synchro_t simcall_comm_irecv(smx_process_t receiver, smx_rdv_t rdv, void *dst_buff, size_t *dst_buff_size, int (*match_fun)(void *, void *, smx_synchro_t), void (*copy_data_fun)(smx_synchro_t, void*, size_t), void *data, double rate) { xbt_assert(rdv, "No rendez-vous point defined for irecv"); - return simcall_BODY_comm_irecv(rdv, dst_buff, dst_buff_size, + return simcall_BODY_comm_irecv(receiver, rdv, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, rate); }