4 #define _ISO_C99_SOURCE
5 #include <math.h> /* isfinite() */
7 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
9 static const char* request_names[] = {
10 #undef SIMIX_REQ_ENUM_ELEMENT
11 #define SIMIX_REQ_ENUM_ELEMENT(x) #x /* generate strings from the enumeration values */
13 #undef SIMIX_REQ_ENUM_ELEMENT
17 * \brief Returns a host given its name.
19 * \param name The name of the host to get
20 * \return The corresponding host
22 smx_host_t SIMIX_req_host_get_by_name(const char *name)
24 smx_req_t req = SIMIX_req_mine();
26 req->call = REQ_HOST_GET_BY_NAME;
27 req->host_get_by_name.name = name;
29 return req->host_get_by_name.result;
33 * \brief Returns the name of a host.
35 * \param host A SIMIX host
36 * \return The name of this host
38 const char* SIMIX_req_host_get_name(smx_host_t host)
40 smx_req_t req = SIMIX_req_mine();
42 req->call = REQ_HOST_GET_NAME;
43 req->host_get_name.host = host;
45 return req->host_get_name.result;
49 * \brief Returns a dict of the properties assigned to a host.
52 * \return The properties of this host
54 xbt_dict_t SIMIX_req_host_get_properties(smx_host_t host)
56 smx_req_t req = SIMIX_req_mine();
58 req->call = REQ_HOST_GET_PROPERTIES;
59 req->host_get_properties.host = host;
61 return req->host_get_properties.result;
65 * \brief Returns the speed of the processor.
67 * The speed returned does not take into account the current load on the machine.
68 * \param host A SIMIX host
69 * \return The speed of this host (in Mflop/s)
71 double SIMIX_req_host_get_speed(smx_host_t host)
73 smx_req_t req = SIMIX_req_mine();
75 req->call = REQ_HOST_GET_SPEED;
76 req->host_get_speed.host = host;
78 return req->host_get_speed.result;
82 * \brief Returns the available speed of the processor.
84 * \return Speed currently available (in Mflop/s)
86 double SIMIX_req_host_get_available_speed(smx_host_t host)
88 smx_req_t req = SIMIX_req_mine();
90 req->call = REQ_HOST_GET_AVAILABLE_SPEED;
91 req->host_get_available_speed.host = host;
93 return req->host_get_available_speed.result;
97 * \brief Returns the state of a host.
99 * Two states are possible: 1 if the host is active or 0 if it has crashed.
100 * \param host A SIMIX host
101 * \return 1 if the host is available, 0 otherwise
103 int SIMIX_req_host_get_state(smx_host_t host)
105 smx_req_t req = SIMIX_req_mine();
107 req->call = REQ_HOST_GET_STATE;
108 req->host_get_state.host = host;
109 SIMIX_request_push();
110 return req->host_get_state.result;
114 * \brief Returns the user data associated to a host.
116 * \param host SIMIX host
117 * \return the user data of this host
119 void* SIMIX_req_host_get_data(smx_host_t host)
121 smx_req_t req = SIMIX_req_mine();
123 req->call = REQ_HOST_GET_DATA;
124 req->host_get_data.host = host;
125 SIMIX_request_push();
126 return req->host_get_data.result;
130 * \brief Sets the user data associated to a host.
132 * The host must not have previous user data associated to it.
133 * \param A host SIMIX host
134 * \param data The user data to set
136 void SIMIX_req_host_set_data(smx_host_t host, void *data)
138 smx_req_t req = SIMIX_req_mine();
140 req->call = REQ_HOST_SET_DATA;
141 req->host_set_data.host = host;
142 req->host_set_data.data = data;
143 SIMIX_request_push();
146 /** \brief Creates an action that executes some computation of an host.
148 * This function creates a SURF action and allocates the data necessary
149 * to create the SIMIX action. It can raise a host_error exception if the host crashed.
151 * \param name Name of the execution action to create
152 * \param host SIMIX host where the action will be executed
153 * \param amount Computation amount (in bytes)
154 * \return A new SIMIX execution action
156 smx_action_t SIMIX_req_host_execute(const char *name, smx_host_t host,
157 double computation_amount,
160 /* checking for infinite values */
161 xbt_assert(isfinite(computation_amount), "computation_amount is not finite!");
162 xbt_assert(isfinite(priority), "priority is not finite!");
164 smx_req_t req = SIMIX_req_mine();
166 req->call = REQ_HOST_EXECUTE;
167 req->host_execute.name = name;
168 req->host_execute.host = host;
169 req->host_execute.computation_amount = computation_amount;
170 req->host_execute.priority = priority;
171 SIMIX_request_push();
172 return req->host_execute.result;
175 /** \brief Creates an action that may involve parallel computation on
176 * several hosts and communication between them.
178 * \param name Name of the execution action to create
179 * \param host_nb Number of hosts where the action will be executed
180 * \param host_list Array (of size host_nb) of hosts where the action will be executed
181 * \param computation_amount Array (of size host_nb) of computation amount of hosts (in bytes)
182 * \param communication_amount Array (of size host_nb * host_nb) representing the communication
183 * amount between each pair of hosts
184 * \param amount the SURF action amount
185 * \param rate the SURF action rate
186 * \return A new SIMIX execution action
188 smx_action_t SIMIX_req_host_parallel_execute(const char *name,
190 smx_host_t *host_list,
191 double *computation_amount,
192 double *communication_amount,
197 /* checking for infinite values */
198 for (i = 0 ; i < host_nb ; ++i) {
199 xbt_assert(isfinite(computation_amount[i]), "computation_amount[%d] is not finite!", i);
200 for (j = 0 ; j < host_nb ; ++j) {
201 xbt_assert(isfinite(communication_amount[i + host_nb * j]),
202 "communication_amount[%d+%d*%d] is not finite!", i, host_nb, j);
206 xbt_assert(isfinite(amount), "amount is not finite!");
207 xbt_assert(isfinite(rate), "rate is not finite!");
209 smx_req_t req = SIMIX_req_mine();
211 req->call = REQ_HOST_PARALLEL_EXECUTE;
212 req->host_parallel_execute.name = name;
213 req->host_parallel_execute.host_nb = host_nb;
214 req->host_parallel_execute.host_list = host_list;
215 req->host_parallel_execute.computation_amount = computation_amount;
216 req->host_parallel_execute.communication_amount = communication_amount;
217 req->host_parallel_execute.amount = amount;
218 req->host_parallel_execute.rate = rate;
219 SIMIX_request_push();
220 return req->host_parallel_execute.result;
224 * \brief Destroys an execution action.
226 * Destroys an action, freing its memory. This function cannot be called if there are a conditional waiting for it.
227 * \param action The execution action to destroy
229 void SIMIX_req_host_execution_destroy(smx_action_t execution)
231 smx_req_t req = SIMIX_req_mine();
233 req->call = REQ_HOST_EXECUTION_DESTROY;
234 req->host_execution_destroy.execution = execution;
235 SIMIX_request_push();
239 * \brief Cancels an execution action.
241 * This functions stops the execution. It calls a surf function.
242 * \param action The execution action to cancel
244 void SIMIX_req_host_execution_cancel(smx_action_t execution)
246 smx_req_t req = SIMIX_req_mine();
248 req->call = REQ_HOST_EXECUTION_CANCEL;
249 req->host_execution_cancel.execution = execution;
250 SIMIX_request_push();
254 * \brief Returns how much of an execution action remains to be done.
256 * \param Action The execution action
257 * \return The remaining amount
259 double SIMIX_req_host_execution_get_remains(smx_action_t execution)
261 smx_req_t req = SIMIX_req_mine();
263 req->call = REQ_HOST_EXECUTION_GET_REMAINS;
264 req->host_execution_get_remains.execution = execution;
265 SIMIX_request_push();
266 return req->host_execution_get_remains.result;
270 * \brief Returns the state of an execution action.
272 * \param execution The execution action
275 e_smx_state_t SIMIX_req_host_execution_get_state(smx_action_t execution)
277 smx_req_t req = SIMIX_req_mine();
279 req->call = REQ_HOST_EXECUTION_GET_STATE;
280 req->host_execution_get_state.execution = execution;
281 SIMIX_request_push();
282 return req->host_execution_get_state.result;
286 * \brief Changes the priority of an execution action.
288 * This functions changes the priority only. It calls a surf function.
289 * \param execution The execution action
290 * \param priority The new priority
292 void SIMIX_req_host_execution_set_priority(smx_action_t execution, double priority)
294 /* checking for infinite values */
295 xbt_assert(isfinite(priority), "priority is not finite!");
297 smx_req_t req = SIMIX_req_mine();
299 req->call = REQ_HOST_EXECUTION_SET_PRIORITY;
300 req->host_execution_set_priority.execution = execution;
301 req->host_execution_set_priority.priority = priority;
302 SIMIX_request_push();
306 * \brief Waits for the completion of an execution action and destroy it.
308 * \param execution The execution action
310 e_smx_state_t SIMIX_req_host_execution_wait(smx_action_t execution)
312 smx_req_t req = SIMIX_req_mine();
314 req->call = REQ_HOST_EXECUTION_WAIT;
315 req->host_execution_wait.execution = execution;
316 SIMIX_request_push();
317 return req->host_execution_wait.result;
321 * \brief Creates and runs a new SIMIX process.
323 * The structure and the corresponding thread are created and put in the list of ready processes.
325 * \param process the process created will be stored in this pointer
326 * \param name a name for the process. It is for user-level information and can be NULL.
327 * \param code the main function of the process
328 * \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.
329 * It can be retrieved with the function \ref SIMIX_req_process_get_data.
330 * \param hostname name of the host where the new agent is executed.
331 * \param argc first argument passed to \a code
332 * \param argv second argument passed to \a code
333 * \param properties the properties of the process
335 void SIMIX_req_process_create(smx_process_t *process, const char *name,
336 xbt_main_func_t code,
338 const char *hostname,
339 int argc, char **argv,
340 xbt_dict_t properties)
342 smx_req_t req = SIMIX_req_mine();
344 req->call = REQ_PROCESS_CREATE;
345 req->process_create.process = process;
346 req->process_create.name = name;
347 req->process_create.code = code;
348 req->process_create.data = data;
349 req->process_create.hostname = hostname;
350 req->process_create.argc = argc;
351 req->process_create.argv = argv;
352 req->process_create.properties = properties;
353 SIMIX_request_push();
356 /** \brief Kills a SIMIX process.
358 * This function simply kills a process.
360 * \param process poor victim
362 void SIMIX_req_process_kill(smx_process_t process)
364 smx_req_t req = SIMIX_req_mine();
366 req->call = REQ_PROCESS_KILL;
367 req->process_kill.process = process;
368 SIMIX_request_push();
371 /** \brief Kills all SIMIX processes.
373 void SIMIX_req_process_killall(void)
375 smx_req_t req = SIMIX_req_mine();
377 req->call = REQ_PROCESS_KILLALL;
378 SIMIX_request_push();
381 /** \brief Cleans up a SIMIX process.
382 * \param process poor victim (must have already been killed)
384 void SIMIX_req_process_cleanup(smx_process_t process)
386 smx_req_t req = SIMIX_req_mine();
388 req->call = REQ_PROCESS_CLEANUP;
389 req->process_cleanup.process = process;
390 SIMIX_request_push();
394 * \brief Migrates an agent to another location.
396 * This function changes the value of the host on which \a process is running.
398 * \param process the process to migrate
399 * \param source name of the previous host
400 * \param dest name of the new host
402 void SIMIX_req_process_change_host(smx_process_t process, smx_host_t dest)
404 smx_req_t req = SIMIX_req_mine();
406 req->call = REQ_PROCESS_CHANGE_HOST;
407 req->process_change_host.process = process;
408 req->process_change_host.dest = dest;
409 SIMIX_request_push();
413 * \brief Suspends a process.
415 * This function suspends the process by suspending the action
416 * it was waiting for completion.
418 * \param process a SIMIX process
420 void SIMIX_req_process_suspend(smx_process_t process)
422 xbt_assert(process, "Invalid parameters");
424 smx_req_t req = SIMIX_req_mine();
426 req->call = REQ_PROCESS_SUSPEND;
427 req->process_suspend.process = process;
428 SIMIX_request_push();
432 * \brief Resumes a suspended process.
434 * This function resumes a suspended process by resuming the action
435 * it was waiting for completion.
437 * \param process a SIMIX process
439 void SIMIX_req_process_resume(smx_process_t process)
441 smx_req_t req = SIMIX_req_mine();
443 req->call = REQ_PROCESS_RESUME;
444 req->process_resume.process = process;
445 SIMIX_request_push();
449 * \brief Returns the amount of SIMIX processes in the system
451 * Maestro internal process is not counted, only user code processes are
453 int SIMIX_req_process_count(void)
455 smx_req_t req = SIMIX_req_mine();
457 req->call = REQ_PROCESS_COUNT;
458 SIMIX_request_push();
459 return req->process_count.result;
463 * \brief Return the user data of a #smx_process_t.
465 * This functions checks whether \a process is a valid pointer or not and return the user data associated to \a process if it is possible.
466 * \param process SIMIX process
467 * \return A void pointer to the user data
469 void* SIMIX_req_process_get_data(smx_process_t process)
471 if (process == SIMIX_process_self()) {
472 /* avoid a request if this function is called by the process itself */
473 return SIMIX_process_self_get_data();
476 smx_req_t req = SIMIX_req_mine();
478 req->call = REQ_PROCESS_GET_DATA;
479 req->process_get_data.process = process;
480 SIMIX_request_push();
481 return req->process_get_data.result;
485 * \brief Set the user data of a #m_process_t.
487 * This functions checks whether \a process is a valid pointer or not and set the user data associated to \a process if it is possible.
488 * \param process SIMIX process
489 * \param data User data
491 void SIMIX_req_process_set_data(smx_process_t process, void *data)
493 if (process == SIMIX_process_self()) {
494 /* avoid a request if this function is called by the process itself */
495 SIMIX_process_self_set_data(data);
499 smx_req_t req = SIMIX_req_mine();
501 req->call = REQ_PROCESS_SET_DATA;
502 req->process_set_data.process = process;
503 req->process_set_data.data = data;
504 SIMIX_request_push();
509 * \brief Return the location on which an agent is running.
511 * This functions checks whether \a process is a valid pointer or not and return the m_host_t corresponding to the location on which \a process is running.
512 * \param process SIMIX process
515 smx_host_t SIMIX_req_process_get_host(smx_process_t process)
517 smx_req_t req = SIMIX_req_mine();
519 req->call = REQ_PROCESS_GET_HOST;
520 req->process_get_host.process = process;
521 SIMIX_request_push();
522 return req->process_get_host.result;
526 * \brief Return the name of an agent.
528 * This functions checks whether \a process is a valid pointer or not and return its name.
529 * \param process SIMIX process
530 * \return The process name
532 const char* SIMIX_req_process_get_name(smx_process_t process)
534 if (process == SIMIX_process_self()) {
535 /* avoid a request if this function is called by the process itself */
536 return process->name;
539 smx_req_t req = SIMIX_req_mine();
541 req->call = REQ_PROCESS_GET_NAME;
542 req->process_get_name.process = process;
543 SIMIX_request_push();
544 return req->process_get_name.result;
548 * \brief Returns true if the process is suspended .
550 * This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion.
551 * \param process SIMIX process
552 * \return 1, if the process is suspended, else 0.
554 int SIMIX_req_process_is_suspended(smx_process_t process)
556 smx_req_t req = SIMIX_req_mine();
558 req->call = REQ_PROCESS_IS_SUSPENDED;
559 req->process_is_suspended.process = process;
560 SIMIX_request_push();
561 return req->process_is_suspended.result;
564 /** \ingroup m_process_management
565 * \brief Return the properties
567 * This functions returns the properties associated with this process
569 xbt_dict_t SIMIX_req_process_get_properties(smx_process_t process)
571 smx_req_t req = SIMIX_req_mine();
573 req->call = REQ_PROCESS_GET_PROPERTIES;
574 req->process_get_properties.process = process;
575 SIMIX_request_push();
576 return req->process_get_properties.result;
579 /** \brief Creates a new sleep SIMIX action.
581 * This function creates a SURF action and allocates the data necessary
582 * to create the SIMIX action. It can raise a host_error exception if the
583 * host crashed. The default SIMIX name of the action is "sleep".
585 * \param duration Time duration of the sleep.
586 * \return A result telling whether the sleep was successful
588 e_smx_state_t SIMIX_req_process_sleep(double duration)
590 /* checking for infinite values */
591 xbt_assert(isfinite(duration), "duration is not finite!");
593 smx_req_t req = SIMIX_req_mine();
595 req->call = REQ_PROCESS_SLEEP;
596 req->process_sleep.duration = duration;
597 SIMIX_request_push();
598 return req->process_sleep.result;
602 * \brief Creates a new rendez-vous point
603 * \param name The name of the rendez-vous point
604 * \return The created rendez-vous point
606 smx_rdv_t SIMIX_req_rdv_create(const char *name)
608 smx_req_t req = SIMIX_req_mine();
610 req->call = REQ_RDV_CREATE;
611 req->rdv_create.name = name;
613 SIMIX_request_push();
614 return req->rdv_create.result;
619 * \brief Destroy a rendez-vous point
620 * \param name The rendez-vous point to destroy
622 void SIMIX_req_rdv_destroy(smx_rdv_t rdv)
624 smx_req_t req = SIMIX_req_mine();
626 req->call = REQ_RDV_DESTROY;
627 req->rdv_destroy.rdv = rdv;
629 SIMIX_request_push();
632 smx_rdv_t SIMIX_req_rdv_get_by_name(const char *name)
634 xbt_assert(name != NULL, "Invalid parameter for SIMIX_req_rdv_get_by_name (name is NULL)");
636 /* FIXME: this is a horrible lost of performance, so we hack it out by
637 * skipping the request (for now). It won't work on distributed but
638 * probably we will change MSG for that. */
640 smx_req_t req = SIMIX_req_mine();
641 req->call = REQ_RDV_GEY_BY_NAME;
642 req->rdv_get_by_name.name = name;
643 SIMIX_request_push();
644 return req->rdv_get_by_name.result;*/
646 return SIMIX_rdv_get_by_name(name);
650 * \brief counts the number of communication requests of a given host pending
651 * on a rendez-vous point
652 * \param rdv The rendez-vous point
653 * \param host The host to be counted
654 * \return The number of comm request pending in the rdv
656 int SIMIX_req_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host)
658 smx_req_t req = SIMIX_req_mine();
660 req->call = REQ_RDV_COMM_COUNT_BY_HOST;
661 req->rdv_comm_count_by_host.rdv = rdv;
662 req->rdv_comm_count_by_host.host = host;
664 SIMIX_request_push();
665 return req->rdv_comm_count_by_host.result;
669 * \brief returns the communication at the head of the rendez-vous
670 * \param rdv The rendez-vous point
671 * \return The communication or NULL if empty
673 smx_action_t SIMIX_req_rdv_get_head(smx_rdv_t rdv)
675 smx_req_t req = SIMIX_req_mine();
677 req->call = REQ_RDV_GET_HEAD;
678 req->rdv_get_head.rdv = rdv;
680 SIMIX_request_push();
681 return req->rdv_get_head.result;
684 void SIMIX_req_comm_send(smx_rdv_t rdv, double task_size, double rate,
685 void *src_buff, size_t src_buff_size,
686 int (*match_fun)(void *, void *), void *data,
689 /* checking for infinite values */
690 xbt_assert(isfinite(task_size), "task_size is not finite!");
691 xbt_assert(isfinite(rate), "rate is not finite!");
692 xbt_assert(isfinite(timeout), "timeout is not finite!");
694 xbt_assert(rdv, "No rendez-vous point defined for send");
697 /* the model-checker wants two separate requests */
698 smx_action_t comm = SIMIX_req_comm_isend(rdv, task_size, rate,
699 src_buff, src_buff_size, match_fun, data, 0);
700 SIMIX_req_comm_wait(comm, timeout);
703 smx_req_t req = SIMIX_req_mine();
705 req->call = REQ_COMM_SEND;
706 req->comm_send.rdv = rdv;
707 req->comm_send.task_size = task_size;
708 req->comm_send.rate = rate;
709 req->comm_send.src_buff = src_buff;
710 req->comm_send.src_buff_size = src_buff_size;
711 req->comm_send.match_fun = match_fun;
712 req->comm_send.data = data;
713 req->comm_send.timeout = timeout;
715 SIMIX_request_push();
719 smx_action_t SIMIX_req_comm_isend(smx_rdv_t rdv, double task_size, double rate,
720 void *src_buff, size_t src_buff_size,
721 int (*match_fun)(void *, void *), void *data,
724 /* checking for infinite values */
725 xbt_assert(isfinite(task_size), "task_size is not finite!");
726 xbt_assert(isfinite(rate), "rate is not finite!");
728 xbt_assert(rdv, "No rendez-vous point defined for isend");
730 smx_req_t req = SIMIX_req_mine();
732 req->call = REQ_COMM_ISEND;
733 req->comm_isend.rdv = rdv;
734 req->comm_isend.task_size = task_size;
735 req->comm_isend.rate = rate;
736 req->comm_isend.src_buff = src_buff;
737 req->comm_isend.src_buff_size = src_buff_size;
738 req->comm_isend.match_fun = match_fun;
739 req->comm_isend.data = data;
740 req->comm_isend.detached = detached;
742 SIMIX_request_push();
743 return req->comm_isend.result;
746 void SIMIX_req_comm_recv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
747 int (*match_fun)(void *, void *), void *data, double timeout)
749 xbt_assert(isfinite(timeout), "timeout is not finite!");
750 xbt_assert(rdv, "No rendez-vous point defined for recv");
753 /* the model-checker wants two separate requests */
754 smx_action_t comm = SIMIX_req_comm_irecv(rdv, dst_buff, dst_buff_size,
756 SIMIX_req_comm_wait(comm, timeout);
759 smx_req_t req = SIMIX_req_mine();
761 req->call = REQ_COMM_RECV;
762 req->comm_recv.rdv = rdv;
763 req->comm_recv.dst_buff = dst_buff;
764 req->comm_recv.dst_buff_size = dst_buff_size;
765 req->comm_recv.match_fun = match_fun;
766 req->comm_recv.data = data;
767 req->comm_recv.timeout = timeout;
769 SIMIX_request_push();
773 smx_action_t SIMIX_req_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
774 int (*match_fun)(void *, void *), void *data)
776 xbt_assert(rdv, "No rendez-vous point defined for irecv");
778 smx_req_t req = SIMIX_req_mine();
780 req->call = REQ_COMM_IRECV;
781 req->comm_irecv.rdv = rdv;
782 req->comm_irecv.dst_buff = dst_buff;
783 req->comm_irecv.dst_buff_size = dst_buff_size;
784 req->comm_irecv.match_fun = match_fun;
785 req->comm_irecv.data = data;
787 SIMIX_request_push();
788 return req->comm_irecv.result;
791 void SIMIX_req_comm_destroy(smx_action_t comm)
793 xbt_assert(comm, "Invalid parameter");
795 /* FIXME remove this request type: comms are auto-destroyed now,
796 * but what happens with unfinished comms? */
799 smx_req_t req = SIMIX_req_mine();
801 req->call = REQ_COMM_DESTROY;
802 req->comm_destroy.comm = comm;
804 SIMIX_request_push();
808 void SIMIX_req_comm_cancel(smx_action_t comm)
810 smx_req_t req = SIMIX_req_mine();
812 req->call = REQ_COMM_CANCEL;
813 req->comm_cancel.comm = comm;
815 SIMIX_request_push();
818 unsigned int SIMIX_req_comm_waitany(xbt_dynar_t comms)
820 smx_req_t req = SIMIX_req_mine();
822 req->call = REQ_COMM_WAITANY;
823 req->comm_waitany.comms = comms;
825 SIMIX_request_push();
826 return req->comm_waitany.result;
829 int SIMIX_req_comm_testany(xbt_dynar_t comms)
831 smx_req_t req = SIMIX_req_mine();
832 if (xbt_dynar_length(comms)==0)
835 req->call = REQ_COMM_TESTANY;
836 req->comm_testany.comms = comms;
838 SIMIX_request_push();
839 return req->comm_testany.result;
842 void SIMIX_req_comm_wait(smx_action_t comm, double timeout)
844 xbt_assert(isfinite(timeout), "timeout is not finite!");
846 smx_req_t req = SIMIX_req_mine();
848 req->call = REQ_COMM_WAIT;
849 req->comm_wait.comm = comm;
850 req->comm_wait.timeout = timeout;
852 SIMIX_request_push();
857 * \brief Set the category of an action.
859 * This functions changes the category only. It calls a surf function.
860 * \param execution The execution action
861 * \param category The tracing category
863 void SIMIX_req_set_category(smx_action_t action, const char *category)
865 if (category == NULL) {
869 smx_req_t req = SIMIX_req_mine();
871 req->call = REQ_SET_CATEGORY;
872 req->set_category.action = action;
873 req->set_category.category = category;
875 SIMIX_request_push();
879 int SIMIX_req_comm_test(smx_action_t comm)
881 smx_req_t req = SIMIX_req_mine();
883 req->call = REQ_COMM_TEST;
884 req->comm_test.comm = comm;
886 SIMIX_request_push();
887 return req->comm_test.result;
890 double SIMIX_req_comm_get_remains(smx_action_t comm)
892 smx_req_t req = SIMIX_req_mine();
894 req->call = REQ_COMM_GET_REMAINS;
895 req->comm_get_remains.comm = comm;
897 SIMIX_request_push();
898 return req->comm_get_remains.result;
901 e_smx_state_t SIMIX_req_comm_get_state(smx_action_t comm)
903 smx_req_t req = SIMIX_req_mine();
905 req->call = REQ_COMM_GET_STATE;
906 req->comm_get_state.comm = comm;
908 SIMIX_request_push();
909 return req->comm_get_state.result;
912 void *SIMIX_req_comm_get_src_data(smx_action_t comm)
914 smx_req_t req = SIMIX_req_mine();
916 req->call = REQ_COMM_GET_SRC_DATA;
917 req->comm_get_src_data.comm = comm;
919 SIMIX_request_push();
920 return req->comm_get_src_data.result;
923 void *SIMIX_req_comm_get_dst_data(smx_action_t comm)
925 smx_req_t req = SIMIX_req_mine();
927 req->call = REQ_COMM_GET_DST_DATA;
928 req->comm_get_dst_data.comm = comm;
930 SIMIX_request_push();
931 return req->comm_get_dst_data.result;
934 smx_process_t SIMIX_req_comm_get_src_proc(smx_action_t comm)
936 smx_req_t req = SIMIX_req_mine();
938 req->call = REQ_COMM_GET_SRC_PROC;
939 req->comm_get_src_proc.comm = comm;
941 SIMIX_request_push();
942 return req->comm_get_src_proc.result;
945 smx_process_t SIMIX_req_comm_get_dst_proc(smx_action_t comm)
947 smx_req_t req = SIMIX_req_mine();
949 req->call = REQ_COMM_GET_DST_PROC;
950 req->comm_get_dst_proc.comm = comm;
952 SIMIX_request_push();
953 return req->comm_get_dst_proc.result;
956 #ifdef HAVE_LATENCY_BOUND_TRACKING
957 int SIMIX_req_comm_is_latency_bounded(smx_action_t comm)
959 smx_req_t req = SIMIX_req_mine();
961 req->call = REQ_COMM_IS_LATENCY_BOUNDED;
962 req->comm_is_latency_bounded.comm = comm;
964 SIMIX_request_push();
965 return req->comm_is_latency_bounded.result;
969 smx_mutex_t SIMIX_req_mutex_init(void)
971 smx_req_t req = SIMIX_req_mine();
973 req->call = REQ_MUTEX_INIT;
975 SIMIX_request_push();
976 return req->mutex_init.result;
979 void SIMIX_req_mutex_destroy(smx_mutex_t mutex)
981 smx_req_t req = SIMIX_req_mine();
983 req->call = REQ_MUTEX_DESTROY;
984 req->mutex_destroy.mutex = mutex;
986 SIMIX_request_push();
989 void SIMIX_req_mutex_lock(smx_mutex_t mutex)
991 smx_req_t req = SIMIX_req_mine();
993 req->call = REQ_MUTEX_LOCK;
994 req->mutex_lock.mutex = mutex;
996 SIMIX_request_push();
999 int SIMIX_req_mutex_trylock(smx_mutex_t mutex)
1001 smx_req_t req = SIMIX_req_mine();
1003 req->call = REQ_MUTEX_TRYLOCK;
1004 req->mutex_trylock.mutex = mutex;
1006 SIMIX_request_push();
1007 return req->mutex_trylock.result;
1010 void SIMIX_req_mutex_unlock(smx_mutex_t mutex)
1012 smx_req_t req = SIMIX_req_mine();
1014 req->call = REQ_MUTEX_UNLOCK;
1015 req->mutex_unlock.mutex = mutex;
1017 SIMIX_request_push();
1021 smx_cond_t SIMIX_req_cond_init(void)
1023 smx_req_t req = SIMIX_req_mine();
1025 req->call = REQ_COND_INIT;
1027 SIMIX_request_push();
1028 return req->cond_init.result;
1031 void SIMIX_req_cond_destroy(smx_cond_t cond)
1033 smx_req_t req = SIMIX_req_mine();
1035 req->call = REQ_COND_DESTROY;
1036 req->cond_destroy.cond = cond;
1038 SIMIX_request_push();
1041 void SIMIX_req_cond_signal(smx_cond_t cond)
1043 smx_req_t req = SIMIX_req_mine();
1045 req->call = REQ_COND_SIGNAL;
1046 req->cond_signal.cond = cond;
1048 SIMIX_request_push();
1051 void SIMIX_req_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
1053 smx_req_t req = SIMIX_req_mine();
1055 req->call = REQ_COND_WAIT;
1056 req->cond_wait.cond = cond;
1057 req->cond_wait.mutex = mutex;
1059 SIMIX_request_push();
1062 void SIMIX_req_cond_wait_timeout(smx_cond_t cond,
1066 xbt_assert(isfinite(timeout), "timeout is not finite!");
1068 smx_req_t req = SIMIX_req_mine();
1070 req->call = REQ_COND_WAIT_TIMEOUT;
1071 req->cond_wait_timeout.cond = cond;
1072 req->cond_wait_timeout.mutex = mutex;
1073 req->cond_wait_timeout.timeout = timeout;
1075 SIMIX_request_push();
1078 void SIMIX_req_cond_broadcast(smx_cond_t cond)
1080 smx_req_t req = SIMIX_req_mine();
1082 req->call = REQ_COND_BROADCAST;
1083 req->cond_broadcast.cond = cond;
1085 SIMIX_request_push();
1089 smx_sem_t SIMIX_req_sem_init(int capacity)
1091 smx_req_t req = SIMIX_req_mine();
1093 req->call = REQ_SEM_INIT;
1094 req->sem_init.capacity = capacity;
1096 SIMIX_request_push();
1097 return req->sem_init.result;
1100 void SIMIX_req_sem_destroy(smx_sem_t sem)
1102 smx_req_t req = SIMIX_req_mine();
1104 req->call = REQ_SEM_DESTROY;
1105 req->sem_destroy.sem = sem;
1107 SIMIX_request_push();
1110 void SIMIX_req_sem_release(smx_sem_t sem)
1112 smx_req_t req = SIMIX_req_mine();
1114 req->call = REQ_SEM_RELEASE;
1115 req->sem_release.sem = sem;
1117 SIMIX_request_push();
1120 int SIMIX_req_sem_would_block(smx_sem_t sem)
1122 smx_req_t req = SIMIX_req_mine();
1124 req->call = REQ_SEM_WOULD_BLOCK;
1125 req->sem_would_block.sem = sem;
1127 SIMIX_request_push();
1128 return req->sem_would_block.result;
1131 void SIMIX_req_sem_acquire(smx_sem_t sem)
1133 smx_req_t req = SIMIX_req_mine();
1135 req->call = REQ_SEM_ACQUIRE;
1136 req->sem_acquire.sem = sem;
1138 SIMIX_request_push();
1141 void SIMIX_req_sem_acquire_timeout(smx_sem_t sem, double timeout)
1143 xbt_assert(isfinite(timeout), "timeout is not finite!");
1145 smx_req_t req = SIMIX_req_mine();
1147 req->call = REQ_SEM_ACQUIRE_TIMEOUT;
1148 req->sem_acquire_timeout.sem = sem;
1149 req->sem_acquire_timeout.timeout = timeout;
1151 SIMIX_request_push();
1154 int SIMIX_req_sem_get_capacity(smx_sem_t sem)
1156 smx_req_t req = SIMIX_req_mine();
1158 req->call = REQ_SEM_GET_CAPACITY;
1159 req->sem_get_capacity.sem = sem;
1161 SIMIX_request_push();
1162 return req->sem_get_capacity.result;
1164 /* ************************************************************************** */
1166 /** @brief returns a printable string representing the request kind */
1167 const char *SIMIX_request_name(int kind) {
1168 return request_names[kind];